Skip to content

Commit

Permalink
Merge pull request #15 from uc-cdis/chore/tests
Browse files Browse the repository at this point in the history
feat(test): setup test
  • Loading branch information
philloooo authored Feb 27, 2018
2 parents 9fc4e09 + 7232bf8 commit b42f4e8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ sudo: false

install:
- "pip install . --force --upgrade"
- "pip install -r test-requirements.txt"

script: "py.test -vv tests"
7 changes: 5 additions & 2 deletions indexclient/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import json
from urlparse import urljoin
try:
from urlparse import urljoin
except ImportError:
from urllib.parse import urljoin

import requests

Expand Down Expand Up @@ -205,7 +208,7 @@ def _load(self, json=None):
self._check_deleted()
json = json or self.client._get("index", self.did).json()
# set attributes to current Document
for k,v in json.iteritems():
for k,v in json.items():
self.__dict__[k] = v
self._attrs = json.keys()
self._fetched = True
Expand Down
4 changes: 4 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pytest==3.0.6
-e git+https://github.com/uc-cdis/[email protected]#egg=cdisutilstest
-e git+https://github.com/uc-cdis/[email protected]#egg=cdispyutils
-e git+https://github.com/uc-cdis/[email protected]#egg=indexd
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import pytest

from cdisutilstest.code.indexd_fixture import indexd_server
from indexclient.client import IndexClient


@pytest.fixture
def index_client(indexd_server):
yield IndexClient(
baseurl=indexd_server.baseurl, auth=indexd_server.auth)
9 changes: 9 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def test_instantiate(index_client):
hashes = {'md5': 'ab167e49d25b488939b1ede42752458b'}
doc = index_client.create(
hashes=hashes,
size=5,
urls=[]
)
assert doc.size == 5
assert doc.hashes == hashes

0 comments on commit b42f4e8

Please sign in to comment.