Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): remove swagger-codegen dependecy #230

Merged
merged 9 commits into from
Aug 2, 2019
30 changes: 8 additions & 22 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

from tests.util import assert_blank
from indexd.index.blueprint import ACCEPTABLE_HASHES


Expand Down Expand Up @@ -75,13 +76,13 @@ def test_index_list_with_params(client, user):
assert rec_1["did"] in ids
assert rec_2["did"] in ids

data_by_ids = client.get("/index/?ids=".format(",".join(ids)))
data_by_ids = client.get("/index/?ids={}".format(rec_1["did"]))
assert data_by_ids.status_code == 200
data_list_all = data_by_ids.json

ids = [record["did"] for record in data_list_all["records"]]
assert rec_1["did"] in ids
assert rec_2["did"] in ids
assert not rec_2["did"] in ids

data_with_limit = client.get("/index/?limit=1")
assert data_with_limit.status_code == 200
Expand All @@ -93,9 +94,9 @@ def test_index_list_with_params(client, user):
data_by_url_md = client.get("/index/?urls_metadata=" + json.dumps(param))
assert data_by_url_md.status_code == 200
data_list = data_by_url_md.json
assert len(data_list["records"]) == 1
assert data_list["records"][0]["did"] == rec_1["did"]
assert data_list["records"][0]["urls_metadata"] == data1["urls_metadata"]
assert len(data_list["records"]) == 1


def test_index_list_with_params_negate(client, user):
Expand Down Expand Up @@ -277,12 +278,7 @@ def test_create_blank_record(client, user):
assert not rec["records"][0]["file_name"]

# test that record is blank
assert rec["records"][0]["baseid"]
assert rec["records"][0]["did"]
assert not rec["records"][0]["size"]
assert not rec["records"][0]["acl"]
assert not rec["records"][0]["authz"]
assert not rec["records"][0]["hashes"]
assert_blank(rec)


def test_create_blank_record_with_file_name(client, user):
Expand All @@ -306,12 +302,7 @@ def test_create_blank_record_with_file_name(client, user):
assert rec["records"][0]["file_name"] == "myfile.txt"

# test that record is blank
assert rec["records"][0]["baseid"]
assert rec["records"][0]["did"]
assert not rec["records"][0]["size"]
assert not rec["records"][0]["acl"]
assert not rec["records"][0]["authz"]
assert not rec["records"][0]["hashes"]
assert_blank(rec)


def test_fill_size_n_hash_for_blank_record(client, user):
Expand Down Expand Up @@ -819,15 +810,10 @@ def test_create_blank_record_with_baseid(client, user):
assert res.status_code == 201
rec = res.json
assert rec["did"]
res = client.get("/index/" + rec["did"])
res = client.get("/index/?baseid=baseid_123")
paulineribeyre marked this conversation as resolved.
Show resolved Hide resolved
assert res.status_code == 200
rec = res.json
assert rec["acl"] == []
assert rec["authz"] == []
assert rec["urls_metadata"] == {}
assert rec["size"] is None
assert rec["version"] is None
assert rec["urls_metadata"] == {}
assert_blank(rec)


def test_index_create_with_uploader(client, user):
Expand Down
4 changes: 1 addition & 3 deletions tests/test_driver_alchemy_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def test_driver_init_does_not_create_records():
Tests for creation of records after driver init.
Tests driver init does not have unexpected side-effects.
"""
driver = SQLAlchemyAuthDriver(
"sqlite:///auth.sq3"
) # pylint: disable=unused-variable
driver = SQLAlchemyAuthDriver("sqlite:///auth.sq3") # pylint: disable=unused-variable

with sqlite3.connect("auth.sq3") as conn:

Expand Down
4 changes: 1 addition & 3 deletions tests/test_driver_alchemy_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ def test_driver_init_does_not_create_record_hashes():
"""
with sqlite3.connect("index.sq3") as conn:

driver = SQLAlchemyIndexDriver(
"sqlite:///index.sq3"
) # pylint: disable=unused-variable
driver = SQLAlchemyIndexDriver("sqlite:///index.sq3") # pylint: disable=unused-variable

count = conn.execute(
"""
Expand Down
18 changes: 8 additions & 10 deletions tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ def assert_blank(r):
Check that the fields that should be empty in a
blank record are empty.
"""
assert r.records[0].baseid
assert r.records[0].did
assert not r.records[0].size
assert not r.records[0].acl
assert not r.records[0].authz
assert not r.records[0].hashes.crc
assert not r.records[0].hashes.md5
assert not r.records[0].hashes.sha
assert not r.records[0].hashes.sha256
assert not r.records[0].hashes.sha512
assert r["records"][0]["baseid"]
assert r["records"][0]["did"]
assert not r["records"][0]["size"]
assert not r["records"][0]["acl"]
assert not r["records"][0]["authz"]
assert not r["records"][0]["hashes"]
paulineribeyre marked this conversation as resolved.
Show resolved Hide resolved
assert not r["records"][0]["urls_metadata"]
assert not r["records"][0]["version"]