Skip to content

Commit

Permalink
fix travis ci error gdcc#17
Browse files Browse the repository at this point in the history
  • Loading branch information
skasberger committed May 20, 2019
1 parent b7f7c94 commit 82162b7
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
from pyDataverse.utils import read_file_json
import pytest
from requests import Response
from time import sleep


TEST_DIR = os.path.dirname(os.path.realpath(__file__))
SLEEP_TIME = 1

if 'API_TOKEN' in os.environ:
API_TOKEN = os.environ['API_TOKEN']
Expand All @@ -31,7 +29,6 @@ class TestApiConnect(object):
def test_api_connect(self):
"""Test successfull connection without api_token."""
api = Api(BASE_URL)
sleep(SLEEP_TIME)
time_window_start = datetime.now() - timedelta(seconds=10)
assert isinstance(api, Api)
assert not api.api_token
Expand All @@ -49,7 +46,6 @@ def test_api_connect_base_url_wrong(self):
with pytest.raises(ApiResponseError):
base_url = 'http://wikipedia.org'
api = Api(base_url)
sleep(SLEEP_TIME)
time_window_start = datetime.now() - timedelta(seconds=10)
assert not api.api_token
assert api.api_version == 'v1'
Expand All @@ -62,7 +58,6 @@ def test_api_connect_base_url_wrong(self):
with pytest.raises(ApiUrlError):
base_url = None
api = Api(base_url)
sleep(SLEEP_TIME)
time_window_start = datetime.now() - timedelta(seconds=10)
assert not api.api_token
assert api.api_version == 'v1'
Expand All @@ -84,7 +79,6 @@ def setup_class(cls):
cls.filename_dataverse = TEST_DIR+'/data/create_dataverse.json'
cls.filename_dataset = TEST_DIR+'/data/create_dataset.json'
cls.api = Api(BASE_URL, api_token=API_TOKEN)
sleep(SLEEP_TIME)
assert cls.api
assert cls.api.api_token
assert cls.api.base_url
Expand All @@ -94,7 +88,6 @@ def test_make_get_request(self):
# TODO: test params und auth default
query_str = '/info/server'
resp = self.api.make_get_request(query_str)
sleep(SLEEP_TIME)
assert self.api.status == 'OK'
assert isinstance(resp, Response)

Expand All @@ -105,9 +98,6 @@ def test_create_dataverse(self):
self.dataverse_id, dict_to_json(metadata))
assert isinstance(resp, Response)
assert self.api.get_dataverse(self.dataverse_id).json()
sleep(SLEEP_TIME)
resp = self.api.delete_dataverse(self.dataverse_id)
sleep(SLEEP_TIME)

def test_get_dataverse(self):
"""Test successfull `.get_dataverse()` request`."""
Expand All @@ -130,3 +120,8 @@ def test_delete_dataset(self):
"""Test successfull `.delete_dataset()` request`."""
resp = self.api.delete_dataset(TestApiRequests.dataset_id)
assert isinstance(resp, Response)

def test_delete_dataverse(self):
"""Test successfull `.delete_dataverse()` request`."""
resp = self.api.delete_dataverse(self.dataverse_id)
assert isinstance(resp, Response)

0 comments on commit 82162b7

Please sign in to comment.