Skip to content

Commit

Permalink
test: Replace test env variable with URL string
Browse files Browse the repository at this point in the history
  • Loading branch information
essteer committed Jun 29, 2024
1 parent 464fb33 commit 2d850e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ authors = [{ name = "Elliott Steer", email = "essteer@pm.me" }]
dependencies = [
"beautifulsoup4==4.12.3",
"masquer==1.2.0",
"python-dotenv==1.0.1",
"requests==2.32.3",
]
requires-python = ">=3.9"
Expand All @@ -29,6 +28,7 @@ classifiers = [
[project.optional-dependencies]
dev = [
"pre-commit==3.7.1",
"python-dotenv==1.0.1",
"ruff>=0.4.10",
]

Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ idna==3.7
# via requests
masquer==1.2.0
# via gigshk-pipeline (pyproject.toml)
python-dotenv==1.0.1
# via gigshk-pipeline (pyproject.toml)
requests==2.32.3
# via gigshk-pipeline (pyproject.toml)
soupsieve==2.5
Expand Down
10 changes: 4 additions & 6 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import sys
import unittest
from dotenv import load_dotenv

sys.path.append(os.path.join(os.path.dirname(__file__)))
from src.app import data_pipeline
Expand All @@ -11,10 +10,9 @@
from tests.assets.ex04 import HTML_4


load_dotenv()

TEST_ASSETS = os.path.abspath(os.path.join("tests", "assets"))
TEST_CASES = [HTML_1, HTML_2, HTML_3, HTML_4]
TEST_URL = "https://undergroundhk.com/gig-guide-27th-june-11th-july-2024/"


class TestDataPipeline(unittest.TestCase):
Expand All @@ -26,7 +24,7 @@ def test_all_matches_persist(self):
sum(1 for _ in data_pipeline(test_case, False)), num_matches[test_case]
)
# NOTE: this test relies on external source, check source if not found
self.assertEqual(sum(1 for _ in data_pipeline(os.environ["EXAMPLE"])), 84)
self.assertEqual(sum(1 for _ in data_pipeline(TEST_URL)), 84)

def test_matches_are_dicts(self):
"""Test all matches in dict format"""
Expand All @@ -35,7 +33,7 @@ def test_matches_are_dicts(self):
for match in matches:
self.assertIsInstance(match, dict)
# NOTE: this test relies on external source, check source if not found
matches = data_pipeline(os.environ["EXAMPLE"])
matches = data_pipeline(TEST_URL)
for match in matches:
self.assertIsInstance(match, dict)

Expand All @@ -54,7 +52,7 @@ def test_expected_fields_present(self):
self.assertIn("bands", match)
self.assertIn("tickets", match)
# NOTE: this test relies on external source, check source if not found
matches = data_pipeline(os.environ["EXAMPLE"])
matches = data_pipeline(TEST_URL)
for match in matches:
self.assertIn("weekday", match)
self.assertIn("month", match)
Expand Down

0 comments on commit 2d850e8

Please sign in to comment.