Skip to content

Commit

Permalink
Refactored and Organized Test Modules
Browse files Browse the repository at this point in the history
- Moved test modules and data from the package directory to the root-level tests directory.
- Updated directory structure to ensure clear separation of source code and tests.
- Updated import statements in test modules to reflect new paths.
- Restructured the tests module:
  - Renamed original automatic tests to `e2e` as they primarily test the main CLI scripts.
  - Added `unit` directory for unit tests.
  - Created `data` directory for shared test data files.

This comprehensive refactoring improves project organization by clearly separating test code from application code. It facilitates easier test discovery and enhances maintainability by following common best practices.
  • Loading branch information
ladsmund committed Jun 28, 2024
1 parent 7e04574 commit 792d121
Show file tree
Hide file tree
Showing 25 changed files with 32,211 additions and 32,209 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
- name: Run unit tests
shell: bash
run: |
python3 -m unittest discover pypromice
python3 -m unittest discover tests
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8,936 changes: 4,468 additions & 4,468 deletions src/pypromice/test/test_raw1.txt → tests/data/test_raw1.txt

Large diffs are not rendered by default.

22,334 changes: 11,167 additions & 11,167 deletions src/pypromice/test/test_raw_DataTable2.txt → tests/data/test_raw_DataTable2.txt

Large diffs are not rendered by default.

Large diffs are not rendered by default.

30,822 changes: 15,411 additions & 15,411 deletions src/pypromice/test/test_raw_transmitted1.txt → tests/data/test_raw_transmitted1.txt

Large diffs are not rendered by default.

File renamed without changes.
Empty file added tests/e2e/__init__.py
Empty file.
14 changes: 8 additions & 6 deletions src/pypromice/process/test.py → tests/e2e/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""
Processing test module
"""
from pathlib import Path

from pypromice.process.aws import AWS
from pypromice.process.load import getVars, getMeta
from pypromice.process.write import addVars, addMeta
Expand All @@ -11,6 +13,11 @@
import unittest, datetime, os
from datetime import timedelta

TEST_ROOT = Path(__file__).parent.parent
TEST_DATA_ROOT_PATH = TEST_ROOT / "data"
TEST_CONFIG_PATH = TEST_DATA_ROOT_PATH / "test_config1.toml"


class TestProcess(unittest.TestCase):

def testgetVars(self):
Expand Down Expand Up @@ -48,12 +55,7 @@ def testAddAll(self):

def testL0toL3(self):
'''Test L0 to L3 processing'''
try:
import pypromice
pAWS = AWS(os.path.join(os.path.dirname(pypromice.__file__),'test/test_config1.toml'),
os.path.join(os.path.dirname(pypromice.__file__),'test'))
except:
pAWS = AWS('../test/test_config1.toml', '../test/')
pAWS = AWS(TEST_CONFIG_PATH.as_posix(), TEST_DATA_ROOT_PATH.as_posix())
pAWS.process()
self.assertIsInstance(pAWS.L2, xr.Dataset)
self.assertTrue(pAWS.L2.attrs['station_id']=='TEST1')
Expand Down
Empty file added tests/unit/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
write_station_configuration_mapping,
load_station_configuration_mapping,
)
from pypromice.test.bufr_export.test_get_bufr_integration import (
from tests.unit.bufr_export.test_get_bufr_integration import (
DATA_DIR,
run_get_bufr,
)
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 792d121

Please sign in to comment.