spacepaste

  1.  
  2. @pytest.fixture(scope='session')
  3. def setup():
  4. settings = load_settings()
  5. _token = settings['token']
  6. headers = {
  7. 'user-agent': 'application/json',
  8. 'Authorization': 'Bearer ' + str(_token),
  9. }
  10. def test_fetching_datafile_via_cdn(setup):
  11. url = f'https://abc.com/public/{settings["accountId"]}/s/{settings["project_id"]}_production.json'
  12. r = requests.get(url, headers=headers)
  13. assert r.status_code == 200
  14. cdn_datafile = r.text
  15. # TODO to add assertions once 400 error is fixed
  16. def test_fetching_datafile_via_rest_api(setup):
  17. url = f'https://www.abc.com/experiment/v1/projects/{settings["project_id"]}/json'
  18. r = requests.get(url, headers=headers)
  19. assert r.status_code == 200
  20. rest_datafile = r.json()
  21. # convert dict-string to dict
  22. cdn_datafile = json.loads(get_datafile())
  23. # comparing dicts of datafiles
  24. assert rest_datafile == cdn_datafile
  25.