From d36a1f0ac01cfa7fe746cbb3656b07ff7bdd4960 Mon Sep 17 00:00:00 2001 From: Joshua Taillon Date: Tue, 25 Oct 2022 17:38:55 -0600 Subject: [PATCH] fix some tests --- Makefile | 11 +++++++++++ Makefile.config | 2 ++ fittrackee/tests/users/test_auth_api.py | 2 ++ fittrackee/users/auth.py | 2 +- fittrackee_client/tests/unit/utils/records.spec.ts | 10 +++++----- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 41ff13c9..e623b095 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,9 @@ clean-install: clean rm -rf dist/ ## Docker commands for evaluation purposes +docker-bandit: + docker-compose -f docker-compose-dev.yml exec fittrackee $(DOCKER_BANDIT) -r fittrackee -c pyproject.toml + docker-build: docker-compose -f docker-compose-dev.yml build fittrackee @@ -50,11 +53,15 @@ docker-build-all: docker-build docker-build-client docker-build-client: docker-compose -f docker-compose-dev.yml build fittrackee_client +docker-check-all: docker-bandit docker-lint-all docker-type-check docker-test-client docker-test-python + docker-init: docker-run docker-init-db docker-restart docker-run-workers docker-init-db: docker-compose -f docker-compose-dev.yml exec fittrackee docker/init-database.sh +docker-lint-all: docker-lint-client docker-lint-python + docker-lint-client: docker-compose -f docker-compose-dev.yml up -d fittrackee_client docker-compose -f docker-compose-dev.yml exec fittrackee_client yarn lint @@ -110,6 +117,10 @@ docker-test-e2e: docker-run docker-test-python: docker-run docker-compose -f docker-compose-dev.yml exec fittrackee docker/test-python.sh $(PYTEST_ARGS) +docker-type-check: + echo 'Running mypy in docker...' + docker-compose -f docker-compose-dev.yml exec fittrackee $(DOCKER_MYPY) fittrackee + docker-up: docker-compose -f docker-compose-dev.yml up fittrackee diff --git a/Makefile.config b/Makefile.config index 84c85fb2..c4b5f7c2 100644 --- a/Makefile.config +++ b/Makefile.config @@ -32,6 +32,8 @@ export DOCKER_APP_DIR = /usr/src/app export DOCKER_MIGRATIONS = $(DOCKER_APP_DIR)/fittrackee/migrations export DOCKER_FLASK = /usr/local/bin/flask export DOCKER_FTCLI = /usr/local/bin/ftcli +export DOCKER_BANDIT = /usr/local/bin/bandit +export DOCKER_MYPY = /usr/local/bin/mypy # Node env NODE_MODULES = $(PWD)/fittrackee_client/node_modules diff --git a/fittrackee/tests/users/test_auth_api.py b/fittrackee/tests/users/test_auth_api.py index 875c6895..2c8f66cf 100644 --- a/fittrackee/tests/users/test_auth_api.py +++ b/fittrackee/tests/users/test_auth_api.py @@ -1394,6 +1394,7 @@ class TestUserPreferencesUpdate(ApiTestCaseMixin): language=input_language, imperial_units=True, display_ascent=False, + date_format='yyyy-MM-dd' ) ), headers=dict(Authorization=f'Bearer {auth_token}'), @@ -1407,6 +1408,7 @@ class TestUserPreferencesUpdate(ApiTestCaseMixin): assert data['data']['imperial_units'] is True assert data['data']['language'] == expected_language assert data['data']['timezone'] == 'America/New_York' + assert data['data']['date_format'] == 'yyyy-MM-dd' assert data['data']['weekm'] is True @pytest.mark.parametrize( diff --git a/fittrackee/users/auth.py b/fittrackee/users/auth.py index 4a0efea1..1359b435 100644 --- a/fittrackee/users/auth.py +++ b/fittrackee/users/auth.py @@ -856,7 +856,7 @@ def edit_user_preferences(auth_user: User) -> Union[Dict, HttpResponse]: } : { workout_id: 'hvYBqYBRa7wwXpaStWR4V2', }, timezone: 'Europe/Paris', - date_format: 'dd/MM/yyyy' + date_format: 'yyyy/dd/MM' }, expected: { id: 9, @@ -181,7 +181,7 @@ describe('formatRecord after conversion', () => { id: 10, record_type: 'FD', value: '11.185 mi', - workout_date: '2019/07/08', + workout_date: '2019/08/07', workout_id: 'hvYBqYBRa7wwXpaStWR4V2', }, }, @@ -227,7 +227,7 @@ describe('formatRecord after conversion', () => { id: 12, record_type: 'MS', value: '11.18 mi/h', - workout_date: '2019/07/08', + workout_date: '2019/08/07', workout_id: 'hvYBqYBRa7wwXpaStWR4V2', }, }, @@ -401,7 +401,7 @@ describe('getRecordsBySports', () => { id: 10, record_type: 'FD', value: '18 km', - workout_date: '2019/07/08', + workout_date: '2019/08/07', workout_id: 'n6JcLPQt3QtZWFfiSnYm4C', }, ], @@ -536,7 +536,7 @@ describe('getRecordsBySports after conversion', () => { id: 10, record_type: 'FD', value: '11.185 mi', - workout_date: '2019/07/08', + workout_date: '2019/08/07', workout_id: 'n6JcLPQt3QtZWFfiSnYm4C', }, ],