Skip to content

Commit

Permalink
Api testing fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
garosap committed Feb 25, 2022
2 parents 75bda91 + c736a20 commit 30f4bfd
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 15 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ $ npm start
$ mongorestore -d tldb database
```

- Then, you will have a copy of the database and the server running on your local machine
- Then, you will have a copy of the database and the server running on your local machine

- If you wish to use the **CLI**, please follow the instructions documented on the **/cli** README.md.

- If you wish to test the **API**, **backend** or **CLI**, please follow the instruction documented on the **/test-api**, **/test-backend** or **/test-cli** README.md.
3 changes: 1 addition & 2 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Back-end

# API
Περιεχόμενα:

- RESTful API
16 changes: 8 additions & 8 deletions api/postmanDocumentation.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"method": "GET",
"header": [],
"url": {
"raw": "localhost:9103/interoperability/api/PassesPerStation/KO01/20290312/20290312?format=json",
"raw": "localhost:9103/interoperability/api/PassesPerStation/KO01/20190312/20290312?format=json",
"host": [
"localhost"
],
Expand All @@ -22,7 +22,7 @@
"api",
"PassesPerStation",
"KO01",
"20290312",
"20190312",
"20290312"
],
"query": [
Expand All @@ -42,7 +42,7 @@
"method": "GET",
"header": [],
"url": {
"raw": "localhost:9103/interoperability/api/PassesAnalysis/aodos/kentriki_odos/20211005/20211110?format=csv",
"raw": "localhost:9103/interoperability/api/PassesAnalysis/aodos/kentriki_odos/20211005/20211110?format=json",
"host": [
"localhost"
],
Expand All @@ -59,7 +59,7 @@
"query": [
{
"key": "format",
"value": "csv"
"value": "json"
}
]
},
Expand Down Expand Up @@ -104,7 +104,7 @@
"method": "GET",
"header": [],
"url": {
"raw": "localhost:9103/interoperability/api/ChargesBy/aodos/20211005/20211110?format=json",
"raw": "localhost:9103/interoperability/api/ChargesBy/aodos/20191005/20211110?format=json",
"host": [
"localhost"
],
Expand All @@ -114,7 +114,7 @@
"api",
"ChargesBy",
"aodos",
"20211005",
"20191005",
"20211110"
],
"query": [
Expand Down Expand Up @@ -156,7 +156,7 @@
"method": "GET",
"header": [],
"url": {
"raw": "localhost:9103/interoperability/api/OperatorBalances/aodos/20191005/20171110?format=json",
"raw": "localhost:9103/interoperability/api/OperatorBalances/aodos/20191005/20201110?format=json",
"host": [
"localhost"
],
Expand All @@ -167,7 +167,7 @@
"OperatorBalances",
"aodos",
"20191005",
"20171110"
"20201110"
],
"query": [
{
Expand Down
4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"test_backend": "env-cmd -f ./configuration/test.env jest ./tests_backend",
"test_api": "env-cmd -f ./configuration/test.env jest ./tests_api",
"test_backend": "env-cmd -f ./configuration/test.env jest ./tests_backend",
"test_api": "env-cmd -f ./configuration/test.env jest ./tests_api",
"start": "env-cmd -f ./configuration/dev.env nodemon src/index.js",
"test_cli":"env-cmd -f ./configuration/test.env nodemon src/index.js"
},
Expand Down
2 changes: 1 addition & 1 deletion backend/tests_api/apitesting.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("API Testing", () => {
afterAll(async () => {
await db.dropDatabase();
await db.close();
await connection.close;
await connection.close();
//we reset the timeout value in the default value
jest.setTimeout(5 * 1000);
});
Expand Down
2 changes: 1 addition & 1 deletion backend/tests_backend/db-connection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Backend Testing", () => {
afterAll(async () => {
await db.dropDatabase();
await db.close();
await connection.close;
await connection.close();
});


Expand Down
23 changes: 23 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# CLI

## Instructions
- Install [python3](https://www.python.org/downloads/), if not already installed.

- Install requests python package, if not already installed:
```
$ pip install requests
```

- Add the CLI path to your OS $PATH to be able to run the CLI commands without the prefix "./" for the executables (e.g. as shown below, valid for one session):
```
$ PATH=$PATH:/home/username/TL21-23/cli
```

- Make sure the ```mongod``` process is running and that you have started the server and that it has connected to the database, as shown in the project README.md.

- Use the CLI as specified in the documents, examples shown below:
```
$ se2123 healthcheck
$ se2123 chargesby --op1 aodos --datefrom 20211005 --dateto 20211110 --format json
$ se2123 admin --passesupd --source /home/username/TL21-23/backend/passes.csv
```
20 changes: 20 additions & 0 deletions test-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# test-cli

## Instructions
- Follow the instructions documented on the cli README.md

- This time, use the tldb-test database, by running the following on **/backend**:
```
$ npm run test_cli
```

- Install pytest framework, if not already installed:
```
$ pip install pytest
```

- Run the admin and main tests using pytest, as shown below (follow this order):
```
$ pytest admin.py
$ pytest main.py
```

0 comments on commit 30f4bfd

Please # to comment.