From 0a57f9d459cc58de0842002332ff5a973547df35 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 17 Aug 2022 01:10:56 +0200 Subject: [PATCH] Fix: Broken subfolder tests in postgres/docker CI in master (#3559) * disable failing tests for sanity check * run postgrest too * only run problematic tests * make paths relative * refactor to reduce duplicate code * remove testing restrictions again --- .github/workflows/qc_checks.yaml | 2 -- InvenTree/plugin/test_plugin.py | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/qc_checks.yaml b/.github/workflows/qc_checks.yaml index 4c4b311e35..6b8c1b5473 100644 --- a/.github/workflows/qc_checks.yaml +++ b/.github/workflows/qc_checks.yaml @@ -185,9 +185,7 @@ jobs: postgres: name: Tests - DB [PostgreSQL] runs-on: ubuntu-20.04 - needs: [ 'javascript', 'html', 'pre-commit' ] - if: github.event_name == 'push' env: INVENTREE_DB_ENGINE: django.db.backends.postgresql diff --git a/InvenTree/plugin/test_plugin.py b/InvenTree/plugin/test_plugin.py index 4df129bc0d..76ddc46b68 100644 --- a/InvenTree/plugin/test_plugin.py +++ b/InvenTree/plugin/test_plugin.py @@ -191,6 +191,10 @@ class InvenTreePluginTests(TestCase): class RegistryTests(TestCase): """Tests for registry loading methods.""" + def mockDir(self) -> None: + """Returns path to mock dir""" + return str(Path(__file__).parent.joinpath('mock').absolute()) + def run_package_test(self, directory): """General runner for testing package based installs.""" @@ -223,7 +227,7 @@ class RegistryTests(TestCase): def test_subfolder_loading(self): """Test that plugins in subfolders get loaded.""" - self.run_package_test('InvenTree/plugin/mock') + self.run_package_test(self.mockDir()) def test_folder_loading(self): """Test that plugins in folders outside of BASE_DIR get loaded.""" @@ -232,7 +236,7 @@ class RegistryTests(TestCase): with tempfile.TemporaryDirectory() as tmp: # Fill directory with sample data new_dir = Path(tmp).joinpath('mock') - shutil.copytree(Path('InvenTree/plugin/mock').absolute(), new_dir) + shutil.copytree(self.mockDir(), new_dir) # Run tests self.run_package_test(str(new_dir))