diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index d68697e5c3..4759d9df99 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -124,10 +124,10 @@ jobs: - name: Run Unit Tests run: | echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> contrib/container/docker.dev.env - docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run --rm inventree-dev-server invoke dev.test --disable-pty --translations + docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run --rm inventree-dev-server invoke dev.test --check --disable-pty --translations - name: Run Migration Tests run: | - docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run --rm inventree-dev-server invoke dev.test --migrations --translations + docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run --rm inventree-dev-server invoke dev.test --check --migrations --translations - name: Clean up test folder run: | rm -rf InvenTree/_testfolder diff --git a/.github/workflows/qc_checks.yaml b/.github/workflows/qc_checks.yaml index 039fb837a4..edd055cccd 100644 --- a/.github/workflows/qc_checks.yaml +++ b/.github/workflows/qc_checks.yaml @@ -341,7 +341,7 @@ jobs: - name: Check Migration Files run: python3 .github/scripts/check_migration_files.py - name: Coverage Tests - run: invoke dev.test --coverage --translations + run: invoke dev.test --check --coverage --translations - name: Upload raw coverage to artifacts uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # pin@v4.6.2 with: @@ -400,7 +400,7 @@ jobs: dev-install: true update: true - name: Run Tests - run: invoke dev.test --translations + run: invoke dev.test --check --translations - name: Data Export Test uses: ./.github/actions/migration @@ -448,7 +448,7 @@ jobs: dev-install: true update: true - name: Run Tests - run: invoke dev.test --translations + run: invoke dev.test --check --translations - name: Data Export Test uses: ./.github/actions/migration @@ -490,7 +490,7 @@ jobs: dev-install: true update: true - name: Run Tests - run: invoke dev.test --migrations --report --coverage --translations + run: invoke dev.test --check --migrations --report --coverage --translations - name: Upload coverage reports to Codecov uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # pin@v5.4.3 if: always() diff --git a/src/backend/InvenTree/InvenTree/ready.py b/src/backend/InvenTree/InvenTree/ready.py index 9d35445cd4..8875520098 100644 --- a/src/backend/InvenTree/InvenTree/ready.py +++ b/src/backend/InvenTree/InvenTree/ready.py @@ -47,6 +47,12 @@ def isRunningBackup(): def isGeneratingSchema(): """Return true if schema generation is being executed.""" + if isInServerThread() or isInWorkerThread(): + return False + + if isInTestMode(): + return False + if 'schema' in sys.argv: return True diff --git a/src/backend/InvenTree/InvenTree/settings.py b/src/backend/InvenTree/InvenTree/settings.py index fd3feceffb..1c53aff9c0 100644 --- a/src/backend/InvenTree/InvenTree/settings.py +++ b/src/backend/InvenTree/InvenTree/settings.py @@ -814,7 +814,7 @@ inventree_tags = { } # sentry.io integration for error reporting -SENTRY_ENABLED = get_boolean_setting( +SENTRY_ENABLED = not TESTING and get_boolean_setting( 'INVENTREE_SENTRY_ENABLED', 'sentry_enabled', False ) diff --git a/tasks.py b/tasks.py index ab9af72bd7..aa885a66c3 100644 --- a/tasks.py +++ b/tasks.py @@ -1212,33 +1212,29 @@ def test_translations(c): @task( help={ + 'check': 'Run sanity check on the django install (default = False)', 'disable_pty': 'Disable PTY', 'runtest': 'Specify which tests to run, in format ...', 'migrations': 'Run migration unit tests', 'report': 'Display a report of slow tests', 'coverage': 'Run code coverage analysis (requires coverage package)', + 'translations': 'Compile translations before running tests', + 'keepdb': 'Keep the test database after running tests (default = False)', } ) def test( c, + check=False, disable_pty=False, runtest='', migrations=False, report=False, coverage=False, translations=False, + keepdb=False, ): """Run unit-tests for InvenTree codebase. - Args: - c: Command line context. - disable_pty (bool): Disable PTY (default = False) - runtest (str): Specify which tests to run, in format ... (default = '') - migrations (bool): Run migration unit tests (default = False) - report (bool): Display a report of slow tests (default = False) - coverage (bool): Run code coverage analysis (requires coverage package) (default = False) - translations (bool): Compile translations before running tests (default = False) - To run only certain test, use the argument --runtest. This can filter all the way down to: ... @@ -1248,7 +1244,8 @@ def test( will run tests in the company/test_api.py file. """ # Run sanity check on the django install - manage(c, 'check') + if check: + manage(c, 'check') if translations: try: @@ -1272,6 +1269,9 @@ def test( if report: cmd += ' --slowreport' + if keepdb: + cmd += ' --keepdb' + if migrations: cmd += ' --tag migration_test' else: