From 2d850e8f476e55942af5f5874f1dab040b81fbaf Mon Sep 17 00:00:00 2001 From: essteer Date: Sun, 30 Jun 2024 02:13:45 +0800 Subject: [PATCH] test: Replace test env variable with URL string --- pyproject.toml | 2 +- requirements.txt | 2 -- tests/test_app.py | 10 ++++------ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2c51aef..c4a9908 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -29,6 +28,7 @@ classifiers = [ [project.optional-dependencies] dev = [ "pre-commit==3.7.1", + "python-dotenv==1.0.1", "ruff>=0.4.10", ] diff --git a/requirements.txt b/requirements.txt index 7f9344b..0e32de7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/tests/test_app.py b/tests/test_app.py index 8625cd9..78ed4fe 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -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 @@ -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): @@ -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""" @@ -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) @@ -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)