(oder aber auch: https://gitlab.version.fz-juelich.de/toar/toar-db/-/tree/sabine_%2333_testfastAPI/fastAPIproject)
Besonders in dem Issue habe ich mich bemüht, alles ein bisschen klarer aufzuschreiben.
(or see code development at: https://gitlab.version.fz-juelich.de/toar/toar-db/-/tree/sabine_%2333_testfastAPI/fastAPIproject)
This issue is structured with a table of contents and aims to clarify issues that were coming up.
## installation guide (soon available in English)
Ich habe eine Test-Datenbank angelegt (noch nicht komplett belegt) und als toardb_dump.sql im Gitlab abgelegt – hier kommt gleich die Anleitung, wie man sie installiert.
## installation guide
Nach dem Download **und der Installation (siehe unten)** von toardb_fastapi kann man mittels
```
pytest
```
sehen, ob alles funktioniert
(aus einem unerklärlichen Grund kann die Datenbank beim letzten Test nicht richtig aufgeräumt werden -- Fehler wird noch behoben).
This repository holds a simple test database *toardb_dump.sql* (not yet fully filled with example data).
Also some testing examples for the running application are provided within file *production_tests.sh*, as well as corresponding pytests.
Running the tests and pytest are described after the installation guide (you need to do this first).
Wenn man eine App gestartet hat, kann man auch mittels curl die „produktive“ Schnittstelle testen.
Hierzu findet man Testbeispiele in „production_tests.sh“.
Es fehlt noch das Definieren einer übergeordneten App, so dass man alle Module gleichzeitig abfragen kann (und nicht jeweils mittels uvicorn neu starten muss).
**Nun zur Installation und Einrichtung der Datenbank:**
**Die Installation von toardb_fastapi geht folgendermaßen:**
Nach dem Clonen (`git clone https://gitlab.version.fz-juelich.de/schroeder5/toardb_fastapi.git`)
richtet man sich am besten eine virtuelle Umgebung ein und installiert hier die Requirements, also:
**installation of toardb_fastapi:**
After cloning the repository (`git clone https://gitlab.version.fz-juelich.de/toar/toardb_fastapi.git`)
it is recommended to create a virtual environment and install the requirements therein:
```
python3 –m venv venv
source venv/bin/activate
pip install –r requirements.txt
```
## Simple database interface: TOAR table data
## Running pytest
After download **and installation (see above)** of toardb_fastapi you can check, if everything is working via
```
pytest
```
(due to an unknown error the database cannot be teared down correctly -- still under investigation (very last test will throw an error for teardown of database if run as ensemble, if every module is pytested stand-alone this error will not show up)).
## Running live tests
After download **and installation (see above)** of toardb_fastapi you can check, if everything is working in the live system via the following:
From the top directory of the project (*toardb_fastapi*) open two terminals.
In the first terminal start the application via:
```
source venv/bin/activate
uvicorn toardb.toardb:app --reload
```
In the second terminal start the live tests via:
```
./production_tests.sh
```
## database interface (REST API)
(more examples can be found in file *production_tests.sh*)
run as:
```
uvicorn data.data:app --reload
uvicorn toardb.toardb:app --reload
```
after having followed the installation instructions of the TOAR database in the toar-db project.
after having followed the above installation instructions.
For example try:
get all data of table data (you should **NOT** do this!):
```
http://127.0.0.1:8000/data/
```
get 4 arbitrary rows of table data:
```
http://127.0.0.1:8000/data/?limit=4
```
get all data of timeseries with id=2:
```
http://127.0.0.1:8000/data/2
```
upload a file to the table data of the TOAR database:
(at the moment every data will be uploaded to timeseries with timeseries_id=2 -- hardwired)