Skip to content

Commit

Permalink
Implement a new test for OddpubWrapper to validate PDF processing wit…
Browse files Browse the repository at this point in the history
…hout mock API, ensuring correct data retrieval from the database.
  • Loading branch information
quang-ng committed Dec 18, 2024
1 parent 7ce9b16 commit f20dbdb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .docker/postgres-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
services:
postgres:
postgres-dsst:
image: postgres:15
container_name: postgres_db
env_file: "../.env"
Expand All @@ -13,5 +13,13 @@ services:
timeout: 5s # Added missing timeout value
retries: 5

oddpub-dsst:
build:
context: ../services/oddpub
dockerfile: Dockerfile
container_name: oddpub_service
ports:
- "8071:8071"

volumes:
postgres_data:
11 changes: 11 additions & 0 deletions tests/test_oddpub.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ def tearDown(self):
self.session.query(OddpubMetrics).delete()
self.session.commit()

def test_oddpub_wrapper_without_mock_api(self):
self.wrapper.oddpub_host_api = "http://localhost:8071"
self.wrapper.process_pdfs("tests/pdf-test")
data = self.session.query(OddpubMetrics).all()
self.assertEqual(len(data), 2)
articles = [row.article for row in data]
self.assertIn("test1.txt", articles)
self.assertIn("test2.txt", articles)



@patch("dsst_etl.oddpub_wrapper.requests.post")
def test_process_pdfs_success(self, mock_post):
# Mock the response from the API
Expand Down

0 comments on commit f20dbdb

Please sign in to comment.