Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
test: add test for should_dump_item in course_published
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Feb 12, 2024
1 parent 0a1ceaf commit f8d341d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_course_published.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,29 @@ def test_no_last_published_date():
assert reason == "No last modified date in CourseOverview"


@responses.activate(registry=OrderedRegistry) # pylint: disable=unexpected-keyword-arg,no-value-for-parameter
def test_should_dump_item():
"""
Test that we get the expected results from should_dump_item.
"""
course_overview = fake_course_overview_factory(modified=datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f+00:00"))

# should_dump_course will reach out to ClickHouse for the last dump date
# we'll fake the response here to have any date, such that we'll exercise
# all the "no modified date" code.
responses.get(
"https://foo.bar/",
body="2023-05-03 15:47:39.331024+00:00"
)

# Confirm that the string date we get back is a valid date
sink = CourseOverviewSink(connection_overrides={}, log=logging.getLogger())
should_dump_course, reason = sink.should_dump_item(course_overview)

assert should_dump_course is True
assert "Course has been published since last dump time - " in reason


@responses.activate(registry=OrderedRegistry) # pylint: disable=unexpected-keyword-arg,no-value-for-parameter
def test_course_not_present_in_clickhouse():
"""
Expand Down

0 comments on commit f8d341d

Please sign in to comment.