-
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.
Merge pull request #191 from ral-facilities/feature/test-multiple-bac…
…kends-#150 Add Tests for ICAT Backend
- Loading branch information
Showing
63 changed files
with
4,104 additions
and
1,222 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ config.json | |
.vscode/ | ||
.nox/ | ||
.python-version | ||
.coverage |
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
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 |
---|---|---|
@@ -1,17 +1,30 @@ | ||
import sys | ||
|
||
from datagateway_api.common.backend import Backend | ||
from datagateway_api.common.config import config | ||
from datagateway_api.common.database.backend import DatabaseBackend | ||
from datagateway_api.common.icat.backend import PythonICATBackend | ||
|
||
|
||
backend_type = config.get_backend_type() | ||
def create_backend(backend_type): | ||
""" | ||
Create an instance of a backend dependent on the value parsed into the function. The | ||
value will typically be from the contents of `config.json`, however when creating a | ||
backend during automated tests the value will be from the Flask app's config (which | ||
will be set in the API's config at `common.config` | ||
if backend_type == "db": | ||
backend = DatabaseBackend() | ||
elif backend_type == "python_icat": | ||
backend = PythonICATBackend() | ||
else: | ||
sys.exit(f"Invalid config value '{backend_type}' for config option backend") | ||
backend = Backend() | ||
The API will exit if a valid value isn't given. | ||
:param backend_type: The type of backend that should be created and used for the API | ||
:type backend_type: :class:`str` | ||
:return: Either an instance of `common.database.backend.DatabaseBackend` or | ||
`common.icat.backend.PythonICATBackend` | ||
""" | ||
|
||
if backend_type == "db": | ||
backend = DatabaseBackend() | ||
elif backend_type == "python_icat": | ||
backend = PythonICATBackend() | ||
else: | ||
# Might turn to a warning so the abstract class can be tested? | ||
sys.exit(f"Invalid config value '{backend_type}' for config option backend") | ||
|
||
return backend |
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
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
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
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
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
Oops, something went wrong.