-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#150: Add ISIS endpoint testing for DB backend
- Loading branch information
1 parent
c5a867c
commit 0c59b58
Showing
3 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
class TestDBTableEndpoints: | ||
""" | ||
This class tests the endpoints defined in table_endpoints.py, commonly referred to | ||
as the ISIS specific endpoints | ||
""" | ||
|
||
def test_valid_get_facility_cycles_with_filters( | ||
self, | ||
flask_test_app_db, | ||
valid_db_credentials_header, | ||
isis_specific_endpoint_data_db, | ||
): | ||
|
||
print(int(isis_specific_endpoint_data_db[0])) | ||
test_response = flask_test_app_db.get( | ||
f"/instruments/{int(isis_specific_endpoint_data_db[0])}/facilitycycles", | ||
headers=valid_db_credentials_header, | ||
) | ||
|
||
assert test_response.json == [isis_specific_endpoint_data_db[1].to_dict()] | ||
|
||
def test_invalid_get_facility_cycles_with_filters( | ||
self, flask_test_app_db, valid_db_credentials_header, | ||
): | ||
final_instrument_result = flask_test_app_db.get( | ||
'/instruments/findone?order="ID DESC"', headers=valid_db_credentials_header, | ||
) | ||
final_instrument_id = final_instrument_result.json["ID"] | ||
|
||
test_response = flask_test_app_db.get( | ||
f"/instruments/{final_instrument_id + 100}/facilitycycles", | ||
headers=valid_db_credentials_header, | ||
) | ||
|
||
assert test_response.json == [] | ||
|
||
def test_valid_get_facility_cycles_count_with_filters( | ||
self, | ||
flask_test_app_db, | ||
valid_db_credentials_header, | ||
isis_specific_endpoint_data_db, | ||
): | ||
test_response = flask_test_app_db.get( | ||
f"/instruments/{isis_specific_endpoint_data_db[0]}/facilitycycles/count", | ||
headers=valid_db_credentials_header, | ||
) | ||
|
||
assert test_response.json == 1 | ||
|
||
def test_invalid_get_facility_cycles_count_with_filters( | ||
self, flask_test_app_db, valid_db_credentials_header, | ||
): | ||
final_instrument_result = flask_test_app_db.get( | ||
'/instruments/findone?order="ID DESC"', headers=valid_db_credentials_header, | ||
) | ||
final_instrument_id = final_instrument_result.json["ID"] | ||
|
||
test_response = flask_test_app_db.get( | ||
f"/instruments/{final_instrument_id + 100}/facilitycycles/count", | ||
headers=valid_db_credentials_header, | ||
) | ||
|
||
assert test_response.json == 0 | ||
|
||
def test_valid_get_investigations_with_filters( | ||
self, | ||
flask_test_app_db, | ||
valid_db_credentials_header, | ||
isis_specific_endpoint_data_db, | ||
): | ||
test_response = flask_test_app_db.get( | ||
f"/instruments/{isis_specific_endpoint_data_db[0]}/facilitycycles/" | ||
f"{isis_specific_endpoint_data_db[1].to_dict()['ID']}/investigations", | ||
headers=valid_db_credentials_header, | ||
) | ||
|
||
assert test_response.json == [isis_specific_endpoint_data_db[2].to_dict()] | ||
|
||
def test_invalid_get_investigations_with_filters( | ||
self, flask_test_app_db, valid_db_credentials_header, | ||
): | ||
final_instrument_result = flask_test_app_db.get( | ||
'/instruments/findone?order="ID DESC"', headers=valid_db_credentials_header, | ||
) | ||
final_instrument_id = final_instrument_result.json["ID"] | ||
final_facilitycycle_result = flask_test_app_db.get( | ||
'/facilitycycles/findone?order="ID DESC"', | ||
headers=valid_db_credentials_header, | ||
) | ||
final_facilitycycle_id = final_facilitycycle_result.json["ID"] | ||
|
||
test_response = flask_test_app_db.get( | ||
f"/instruments/{final_instrument_id + 100}/facilitycycles/" | ||
f"{final_facilitycycle_id + 100}/investigations", | ||
headers=valid_db_credentials_header, | ||
) | ||
|
||
assert test_response.json == [] | ||
|
||
def test_valid_get_investigations_count_with_filters( | ||
self, | ||
flask_test_app_db, | ||
valid_db_credentials_header, | ||
isis_specific_endpoint_data_db, | ||
): | ||
test_response = flask_test_app_db.get( | ||
f"/instruments/{isis_specific_endpoint_data_db[0]}/facilitycycles/" | ||
f"{isis_specific_endpoint_data_db[1].to_dict()['ID']}/investigations/count", | ||
headers=valid_db_credentials_header, | ||
) | ||
|
||
assert test_response.json == 1 | ||
|
||
def test_invalid_get_investigations_count_with_filters( | ||
self, flask_test_app_db, valid_db_credentials_header, | ||
): | ||
final_instrument_result = flask_test_app_db.get( | ||
'/instruments/findone?order="id DESC"', headers=valid_db_credentials_header, | ||
) | ||
final_instrument_id = final_instrument_result.json["ID"] | ||
final_facilitycycle_result = flask_test_app_db.get( | ||
'/facilitycycles/findone?order="ID DESC"', | ||
headers=valid_db_credentials_header, | ||
) | ||
final_facilitycycle_id = final_facilitycycle_result.json["ID"] | ||
|
||
test_response = flask_test_app_db.get( | ||
f"/instruments/{final_instrument_id + 100}/facilitycycles/" | ||
f"{final_facilitycycle_id + 100}/investigations/count", | ||
headers=valid_db_credentials_header, | ||
) | ||
|
||
assert test_response.json == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters