Skip to content

Commit

Permalink
test: unit test api extension validations #256
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Bozhinov committed Nov 22, 2021
1 parent 8774537 commit c068bf3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ def test_load_with_datagateway_api_icat_backend_and_missing_icat_config_data(
with pytest.raises(SystemExit):
APIConfig.load("test/path")

def test_load_with_invalid_api_extension_does_not_start_with_slash(
self, test_config_data,
):
test_config_data["datagateway_api"]["extension"] = "datagateway-api"
with patch("builtins.open", mock_open(read_data=json.dumps(test_config_data))):
with pytest.raises(SystemExit):
APIConfig.load("test/path")

def test_load_with_invalid_api_extension_ends_with_slash(
self, test_config_data,
):
test_config_data["search_api"]["extension"] = "/search-api/"
with patch("builtins.open", mock_open(read_data=json.dumps(test_config_data))):
with pytest.raises(SystemExit):
APIConfig.load("test/path")

def test_load_with_same_api_extensions(self, test_config_data):
test_config_data["search_api"]["extension"] = "/datagateway-api"
with patch("builtins.open", mock_open(read_data=json.dumps(test_config_data))):
with pytest.raises(SystemExit):
APIConfig.load("test/path")

def test_set_backend_type(self, test_config):
test_config.datagateway_api.set_backend_type("backend_name_changed")

Expand Down

0 comments on commit c068bf3

Please sign in to comment.