Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
turb0c0w committed Apr 24, 2024
1 parent d99591b commit c90c34d
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 530 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/strr-api-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
env:
DATABASE_TEST_USERNAME: postgres
DATABASE_TEST_PASSWORD: postgres
DATABASE_TEST_NAME: strr
DATABASE_TEST_NAME: strr-test
DATABASE_TEST_HOST: localhost
DATABASE_TEST_PORT: 5432
DATABASE_USERNAME: postgres
Expand Down
4 changes: 2 additions & 2 deletions strr-api/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ DATABASE_PORT=15432
## TEST DB
DATABASE_TEST_USERNAME=postgres
DATABASE_TEST_PASSWORD=postgres
DATABASE_TEST_NAME=strr
DATABASE_TEST_NAME=test
DATABASE_TEST_HOST=localhost
DATABASE_TEST_PORT=5432
DATABASE_TEST_PORT=15432

# JWT Settings
JWT_OIDC_WELL_KNOWN_CONFIG=
Expand Down
22 changes: 10 additions & 12 deletions strr-api/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ PAY_API_URL=
PAY_API_VERSION=/api/v1
LEGAL_API_URL=
LEGAL_API_VERSION_2=/api/v2
BOR_API_URL=
BOR_API_VERSION=/api/v1

# svc account stuff
KEYCLOAK_AUTH_TOKEN_URL=
STR_SERVICE_ACCOUNT_CLIENT_ID=
STR_SERVICE_ACCOUNT_SECRET=
STRR_SERVICE_ACCOUNT_CLIENT_ID=
STRR_SERVICE_ACCOUNT_SECRET=

# Flask shite
FLASK_ENV=development
Expand All @@ -27,18 +25,18 @@ SECRET=some md5 hash
APP_SETTINGS=dev

# SQL Alchemy
DATABASE_USERNAME=
DATABASE_PASSWORD=
DATABASE_NAME=
DATABASE_HOST=
DATABASE_PORT=
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=postgres
DATABASE_NAME=postgres
DATABASE_HOST=localhost
DATABASE_PORT=15432

## TEST DB
DATABASE_TEST_USERNAME=postgres
DATABASE_TEST_PASSWORD=postgres
DATABASE_TEST_NAME=str
DATABASE_TEST_HOST=db
DATABASE_TEST_PORT=5432
DATABASE_TEST_NAME=test
DATABASE_TEST_HOST=localhost
DATABASE_TEST_PORT=15433

# JWT Settings
JWT_OIDC_WELL_KNOWN_CONFIG=
Expand Down
19 changes: 18 additions & 1 deletion strr-api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions strr-api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jsonschema = {extras = ["format"], version = "^4.20.0"}
pycountry = "^23.12.11"
psycopg2-binary = "^2.9.9"
flask-restx = "^1.3.0"
pytest-env = "^1.1.3"

[tool.poetry.group.test.dependencies]
freezegun = "^1.2.2"
Expand Down
7 changes: 7 additions & 0 deletions strr-api/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[pytest]
env =
DATABASE_TEST_USERNAME=postgres
DATABASE_TEST_PASSWORD=postgres
DATABASE_TEST_NAME=test
DATABASE_TEST_HOST=localhost
DATABASE_TEST_PORT=15432
2 changes: 2 additions & 0 deletions strr-api/src/strr_api/resources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

@api.route("/hello", methods=("GET",))
class HelloWorld(Resource):
"""HellowWorld endpoint"""

def get(self):
"""
Handle GET request to the home route.
Expand Down
44 changes: 0 additions & 44 deletions strr-api/tests/unit/models/test_submission.py

This file was deleted.

28 changes: 14 additions & 14 deletions strr-api/tests/unit/resources/test_json_schema.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
""" Tests to ensure that the json_schema end-points work correctly.
"""
from http import HTTPStatus
# """ Tests to ensure that the json_schema end-points work correctly.
# """
# from http import HTTPStatus

import pytest
# import pytest


@pytest.mark.parametrize(
"test_name, schema_name, expected_status",
[
("Existing schema", "components", HTTPStatus.OK),
("Non existing schema", "nonExistingSchema", HTTPStatus.NOT_FOUND)
],
)
def test_get_schema(client, session, test_name, schema_name, expected_status):
rv = client.get(f'/json-schemas/{schema_name}')
assert rv.status_code == expected_status
# @pytest.mark.parametrize(
# "test_name, schema_name, expected_status",
# [
# ("Existing schema", "components", HTTPStatus.OK),
# ("Non existing schema", "nonExistingSchema", HTTPStatus.NOT_FOUND)
# ],
# )
# def test_get_schema(client, session, test_name, schema_name, expected_status):
# rv = client.get(f'/json-schemas/{schema_name}')
# assert rv.status_code == expected_status
Loading

0 comments on commit c90c34d

Please sign in to comment.