From 1470b2218650070cd7c7682eacee1d4a867d171d Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Fri, 27 Nov 2020 16:35:16 +0000 Subject: [PATCH] #150: Add invalid tests for ISIS specific endpoints --- test/icat/endpoints/test_table_endpoints.py | 87 +++++++++++++++++++++ test/icat/test_isis_endpoints.py | 12 --- 2 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 test/icat/endpoints/test_table_endpoints.py delete mode 100644 test/icat/test_isis_endpoints.py diff --git a/test/icat/endpoints/test_table_endpoints.py b/test/icat/endpoints/test_table_endpoints.py new file mode 100644 index 00000000..6c784244 --- /dev/null +++ b/test/icat/endpoints/test_table_endpoints.py @@ -0,0 +1,87 @@ +class TestTableEndpoints: + """ + 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): + pass + + def test_invalid_get_facility_cycles_with_filters( + self, flask_test_app, valid_credentials_header, + ): + final_instrument_result = flask_test_app.get( + '/instruments/findone?order="id DESC"', headers=valid_credentials_header, + ) + final_instrument_id = final_instrument_result.json["id"] + + test_response = flask_test_app.get( + f"/instruments/{final_instrument_id + 100}/facilitycycles", + headers=valid_credentials_header, + ) + + assert test_response.status_code == 404 + + def test_valid_get_facility_cycles_count_with_filters(self): + pass + + def test_invalid_get_facility_cycles_count_with_filters( + self, flask_test_app, valid_credentials_header, + ): + final_instrument_result = flask_test_app.get( + '/instruments/findone?order="id DESC"', headers=valid_credentials_header, + ) + final_instrument_id = final_instrument_result.json["id"] + + test_response = flask_test_app.get( + f"/instruments/{final_instrument_id + 100}/facilitycycles/count", + headers=valid_credentials_header, + ) + + assert test_response.json == 0 + + def test_valid_get_investigations_with_filters(self): + pass + + def test_invalid_get_investigations_with_filters( + self, flask_test_app, valid_credentials_header, + ): + final_instrument_result = flask_test_app.get( + '/instruments/findone?order="id DESC"', headers=valid_credentials_header, + ) + final_instrument_id = final_instrument_result.json["id"] + final_facilitycycle_result = flask_test_app.get( + '/facilitycycles/findone?order="id DESC"', headers=valid_credentials_header, + ) + final_facilitycycle_id = final_facilitycycle_result.json["id"] + + test_response = flask_test_app.get( + f"/instruments/{final_instrument_id + 100}/facilitycycles/" + f"{final_facilitycycle_id + 100}/investigations", + headers=valid_credentials_header, + ) + + assert test_response.status_code == 404 + + def test_valid_get_investigations_count_with_filters(self): + pass + + def test_invalid_get_investigations_count_with_filters( + self, flask_test_app, valid_credentials_header, + ): + final_instrument_result = flask_test_app.get( + '/instruments/findone?order="id DESC"', headers=valid_credentials_header, + ) + final_instrument_id = final_instrument_result.json["id"] + final_facilitycycle_result = flask_test_app.get( + '/facilitycycles/findone?order="id DESC"', headers=valid_credentials_header, + ) + final_facilitycycle_id = final_facilitycycle_result.json["id"] + + test_response = flask_test_app.get( + f"/instruments/{final_instrument_id + 100}/facilitycycles/" + f"{final_facilitycycle_id + 100}/investigations/count", + headers=valid_credentials_header, + ) + + assert test_response.json == 0 diff --git a/test/icat/test_isis_endpoints.py b/test/icat/test_isis_endpoints.py deleted file mode 100644 index db39e2f1..00000000 --- a/test/icat/test_isis_endpoints.py +++ /dev/null @@ -1,12 +0,0 @@ -class TestISISEndpoints: - def test_valid_get_facility_cycles_with_filters(self): - pass - - def test_valid_get_facility_cycles_count_with_filters(self): - pass - - def test_valid_get_investigations_with_filters(self): - pass - - def test_valid_get_investigations_count_with_filters(self): - pass