Skip to content

Commit

Permalink
๊Update travis
Browse files Browse the repository at this point in the history
  • Loading branch information
ohmrefresh committed Aug 7, 2019
1 parent 32de682 commit 2499720
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ python:
install:
- pip install -r requirements.txt
script:
- pytest
- pytest -vv --cov=./ --cov-report=xml
- codecov
- make clean docs dist
deploy:
provider: pypi
Expand All @@ -15,6 +16,4 @@ deploy:
on:
tags: true
distributions: sdist bdist_wheel
repo: ohmrefresh/GrafanaSnapshot
after_success:
- codecov
repo: ohmrefresh/GrafanaSnapshot
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ python-dotenv
pytest
grafana_api
codecov
pytest-cov
requests_mock
54 changes: 54 additions & 0 deletions tests/test_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,60 @@ def test_generate(self, m):
results = grafana.generate(tags="test_tag", time_from=1563183710618, time_to=1563185212275)
self.assertEqual(len(results), 1)

@requests_mock.Mocker()
def test_generate_with_expire(self, m):
m.get(
"http://localhost:3000/api/search?tag=test_tag",
json=[
{
"id": 163,
"uid": "cIBgcSjkk",
"title": "Folder",
"url": "/dashboards/f/000000163/folder",
"type": "dash-folder",
"tags": [],
"isStarred": 'false',
"uri": "db/folder"
}
]
)
m.get(
"http://localhost:3000/api/dashboards/uid/cIBgcSjkk",
json={
"dashboard": {
"id": 1,
"uid": "cIBgcSjkk",
"title": "Production Overview",
"tags": ["templated"],
"timezone": "browser",
"schemaVersion": 16,
"version": 0,
"time": {
"from": "now-15m",
"to": "now"
}
},
"meta": {
"isStarred": 'false',
"url": "/d/cIBgcSjkk/production-overview",
"slug": "production-overview"
}
}
)
m.post(
"http://localhost:3000/api/snapshots",
json={
"deleteKey": "XXXXXXX",
"deleteUrl": "myurl/api/snapshots.py-delete/XXXXXXX",
"key": "YYYYYYY",
"url": "myurl/dashboard/snapshot/YYYYYYY"
},
)

grafana = GenerateSnapshot(auth="xxxxx", port=3000, host="localhost", protocol="http")
results = grafana.generate(tags="test_tag", time_from=1563183710618, time_to=1563185212275, expires=500)
self.assertEqual(len(results), 1)


if __name__ == "__main__":
import xmlrunner
Expand Down

0 comments on commit 2499720

Please sign in to comment.