Skip to content

Commit

Permalink
Updated paths in tests for data files
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis-chambers committed Jul 3, 2024
1 parent 45a8726 commit cd17118
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
pip install .[test]
- name: Build test DB
run: |
python src/tests/data/build_database.py
python tests/data/build_database.py
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
10 changes: 5 additions & 5 deletions tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import sqlite3

CONFIG_PATH = Path(
Path(__file__).parents[1], "iotswarm", "__assets__", "config.cfg"
Path(__file__).parents[1], "src", "iotswarm", "__assets__", "config.cfg"
)
config_exists = pytest.mark.skipif(
not CONFIG_PATH.exists(),
Expand Down Expand Up @@ -210,7 +210,7 @@ async def test__repr__(self):
oracle2.__repr__(), expected2
)

CSV_PATH = Path(Path(__file__).parents[1], "iotswarm", "__assets__", "data")
CSV_PATH = Path(Path(__file__).parents[1], "src", "iotswarm", "__assets__", "data")
CSV_DATA_FILES = [Path(x) for x in glob(str(Path(CSV_PATH, "*.csv")))]
sqlite_db_exist = pytest.mark.skipif(not Path(CSV_PATH, "cosmos.db").exists(), reason="Local cosmos.db does not exist.")

Expand Down Expand Up @@ -346,7 +346,7 @@ class TestSqliteDB(unittest.TestCase):

@sqlite_db_exist
def setUp(self):
self.db_path = Path(Path(__file__).parents[1], "iotswarm", "__assets__", "data", "cosmos.db")
self.db_path = Path(Path(__file__).parents[1], "src", "iotswarm", "__assets__", "data", "cosmos.db")
self.table = CosmosTable.LEVEL_1_SOILMET_30MIN

if self.db_path.exists():
Expand Down Expand Up @@ -387,7 +387,7 @@ class TestSQLiteDBIndexing(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.db_path = Path(Path(__file__).parents[1], "iotswarm", "__assets__", "data", "cosmos.db")
cls.db_path = Path(Path(__file__).parents[1], "src", "iotswarm", "__assets__", "data", "cosmos.db")
cls.table = CosmosTable.LEVEL_1_SOILMET_30MIN
cls.site_id = "MORLY"

Expand Down Expand Up @@ -439,7 +439,7 @@ class TestLoopingSQLite3DBEndToEnd(unittest.IsolatedAsyncioTestCase):

@sqlite_db_exist
def setUp(self):
self.db_path = Path(Path(__file__).parents[1], "iotswarm", "__assets__", "data", "cosmos.db")
self.db_path = Path(Path(__file__).parents[1], "src", "iotswarm", "__assets__", "data", "cosmos.db")
if self.db_path.exists():
self.database = db.LoopingSQLite3(self.db_path)
self.maxDiff = None
Expand Down
6 changes: 3 additions & 3 deletions tests/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
from datetime import datetime, timedelta

CONFIG_PATH = Path(
Path(__file__).parents[1], "iotswarm", "__assets__", "config.cfg"
Path(__file__).parents[1], "src", "iotswarm", "__assets__", "config.cfg"
)
config_exists = pytest.mark.skipif(
not CONFIG_PATH.exists(),
reason="Config file `config.cfg` not found in root directory.",
)

DATA_DIR = Path(Path(__file__).parents[1], "iotswarm", "__assets__", "data")
DATA_DIR = Path(Path(__file__).parents[1], "src", "iotswarm", "__assets__", "data")
sqlite_db_exist = pytest.mark.skipif(not Path(DATA_DIR, "cosmos.db").exists(), reason="Local cosmos.db does not exist.")


Expand Down Expand Up @@ -335,7 +335,7 @@ async def test__get_payload(self):
class TestBaseDevicesSQLite3Used(unittest.IsolatedAsyncioTestCase):

def setUp(self):
db_path = Path(Path(__file__).parents[1], "iotswarm","__assets__", "data", "cosmos.db")
db_path = Path(Path(__file__).parents[1], "src", "iotswarm","__assets__", "data", "cosmos.db")
if db_path.exists():
self.db = LoopingSQLite3(db_path)
self.table = CosmosTable.LEVEL_1_SOILMET_30MIN
Expand Down
2 changes: 1 addition & 1 deletion tests/test_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import logging


ASSETS_PATH = Path(Path(__file__).parents[1], "iotswarm", "__assets__")
ASSETS_PATH = Path(Path(__file__).parents[1], "src", "iotswarm", "__assets__")
CONFIG_PATH = Path(ASSETS_PATH, "config.cfg")

config_exists = pytest.mark.skipif(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pathlib import Path

SQL_PATH = Path(
Path(__file__).parents[1], "iotswarm", "__assets__", "data", "cosmos.db"
Path(__file__).parents[1], "src", "iotswarm", "__assets__", "data", "cosmos.db"
)
sqlite_db_exist = pytest.mark.skipif(
not SQL_PATH.exists(), reason="Local cosmos.db does not exist."
Expand Down

0 comments on commit cd17118

Please sign in to comment.