Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.14.4'
python-version: '3.14.6'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.14.4'
python-version: '3.14.6'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
3 changes: 2 additions & 1 deletion generator/weekly_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def is_single_post(self, events):

def generate_single_post(self, events, is_morning):
# list of (weekday, country) tuples
simplified_events = list(map(lambda e: (extract_weekday_and_day_from_timestamp_string(e['dateTimeCet']), e['country'] + ('*' if "Final" in e['stage'] else '')), events))
simplified_events = list(map(lambda e: (extract_weekday_and_day_from_timestamp_string(e['dateTimeCet']), e['country'] + ('*' if "Final" in e['stage'] or "Eurovision Night" in e['stage'] else '')), events))
# indicates if any event is a final
includes_final = False

Expand All @@ -47,6 +47,7 @@ def generate_single_post(self, events, is_morning):
for weekday in calendar.keys():
# building flag emojis list
flags = ""
# countries sorted alphabetically by name
for c in sorted(list(calendar[weekday])):
final = '*' in c
country = c.replace('*', '')
Expand Down
11 changes: 11 additions & 0 deletions test/generator/test_weekly_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ def test_when_events_include_a_final_then_post_should_contain_final_indicators(s
self.assertEqual(thread[0], "\U0001F5D3 COMING UP NEXT WEEK (* = final):\n\n - Tuesday 02: \U0001F1EA\U0001F1EA\n - Saturday 06: \U0001F1F3\U0001F1F4*\U0001F1F8\U0001F1EA")


def test_when_events_include_a_eurovision_night_then_post_should_contain_final_indicators(self):
events = [
{'country': 'Estonia', 'name': 'Eesti Laul', 'stage': 'Semi-final 1', 'dateTimeCet': '2021-02-02T20:00:00', 'watchLinks': [{'link': 'https://err.tv', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Sweden', 'name': 'Melodifestivalen', 'stage': 'Heat 1', 'dateTimeCet': '2021-02-06T20:00:00', 'watchLinks': [{'link': 'https://svtplay.se', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Italy', 'name': 'Festival di Sanremo', 'stage': 'Eurovision Night', 'dateTimeCet': '2021-02-06T20:40:00', 'watchLinks': [{'link': 'https://rai.it', 'comment': 'Recommended link', 'live': 1}]}
]
thread = self.generator.generate_thread(events)
self.assertEqual(len(thread), 1)
self.assertEqual(thread[0], "\U0001F5D3 COMING UP NEXT WEEK (* = final):\n\n - Tuesday 02: \U0001F1EA\U0001F1EA\n - Saturday 06: \U0001F1EE\U0001F1F9*\U0001F1F8\U0001F1EA")


def test_when_events_include_country_without_known_flag_should_replace_by_country_name(self):
events = [
{'country': 'Estonia', 'name': 'Eesti Laul', 'stage': 'Semi-final 1', 'dateTimeCet': '2021-02-02T20:00:00', 'watchLinks': [{'link': 'https://err.tv', 'comment': 'Recommended link', 'live': 1}]},
Expand Down
5 changes: 3 additions & 2 deletions test/publisher/test_bluesky_weekly_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ def test_when_calling_weekly_publisher_should_generate_single_post_thread_with_a
{'country': 'Sweden', 'name': 'Melodifestivalen', 'stage': 'Heat 1', 'dateTimeCet': '2021-02-06T20:00:00', 'watchLinks': [{'link': 'https://svtplay.se', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Estonia', 'name': 'Eesti Laul', 'stage': 'Semi-final 1 (part 2)', 'dateTimeCet': '2021-02-02T21:30:00', 'watchLinks': [{'link': 'https://err.tv', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Estonia', 'name': 'Eesti Laul', 'stage': 'Semi-final 1', 'dateTimeCet': '2021-02-02T20:00:00', 'watchLinks': [{'link': 'https://err.tv', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Norway', 'name': 'Melodi Grand Prix', 'stage': 'Final', 'dateTimeCet': '2021-02-06T19:50:00', 'watchLinks': [{'link': 'https://nrk.no/mgp', 'comment': 'Recommended link', 'live': 1}]}
{'country': 'Norway', 'name': 'Melodi Grand Prix', 'stage': 'Final', 'dateTimeCet': '2021-02-06T19:50:00', 'watchLinks': [{'link': 'https://nrk.no/mgp', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Italy', 'name': 'Festival di Sanremo', 'stage': 'Eurovision Night', 'dateTimeCet': '2021-02-06T20:40:00', 'watchLinks': [{'link': 'https://rai.it', 'comment': 'Recommended link', 'live': 1}]}
]
summary = self.publisher.publish(events, run_date=datetime.datetime(1970, 1, 1, 9, 0, 0, 0))

expected_post = "\U0001F5D3 COMING UP NEXT WEEK (* = final):\n\n - Tuesday 02: \U0001F1EA\U0001F1EA\n - Saturday 06: \U0001F1F3\U0001F1F4*\U0001F1F8\U0001F1EA"
expected_post = "\U0001F5D3 COMING UP NEXT WEEK (* = final):\n\n - Tuesday 02: \U0001F1EA\U0001F1EA\n - Saturday 06: \U0001F1EE\U0001F1F9*\U0001F1F3\U0001F1F4*\U0001F1F8\U0001F1EA"

self.assertEqual(len(summary), 1)
self.assertEqual(summary[0]['text'], expected_post)
Expand Down
3 changes: 2 additions & 1 deletion test/publisher/test_threads_weekly_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ def test_when_calling_weekly_publisher_should_generate_single_post_thread_with_a
{'country': 'Norway', 'name': 'Melodi Grand Prix', 'stage': 'Final', 'dateTimeCet': '2021-02-06T19:50:00', 'watchLinks': [{'link': 'https://nrk.no/mgp', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Estonia', 'name': 'Eesti Laul', 'stage': 'Semi-final 1', 'dateTimeCet': '2021-02-02T20:00:00', 'watchLinks': [{'link': 'https://err.tv', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Estonia', 'name': 'Eesti Laul', 'stage': 'Semi-final 1 (part 2)', 'dateTimeCet': '2021-02-02T21:30:00', 'watchLinks': [{'link': 'https://err.tv', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Italy', 'name': 'Festival di Sanremo', 'stage': 'Eurovision Night', 'dateTimeCet': '2021-02-06T20:40:00', 'watchLinks': [{'link': 'https://rai.it', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Sweden', 'name': 'Melodifestivalen', 'stage': 'Heat 1', 'dateTimeCet': '2021-02-06T20:00:00', 'watchLinks': [{'link': 'https://svtplay.se', 'comment': 'Recommended link', 'live': 1}]}
]
summary = self.publisher.publish(events, run_date=datetime.datetime(1970, 1, 1, 9, 0, 0, 0))

expected_post = "\U0001F5D3 COMING UP NEXT WEEK (* = final):\n\n - Tuesday 02: \U0001F1EA\U0001F1EA\n - Saturday 06: \U0001F1F3\U0001F1F4*\U0001F1F8\U0001F1EA"
expected_post = "\U0001F5D3 COMING UP NEXT WEEK (* = final):\n\n - Tuesday 02: \U0001F1EA\U0001F1EA\n - Saturday 06: \U0001F1EE\U0001F1F9*\U0001F1F3\U0001F1F4*\U0001F1F8\U0001F1EA"

self.assertEqual(len(summary), 1)
self.assertEqual(summary[0], expected_post)
Expand Down
3 changes: 2 additions & 1 deletion test/publisher/test_x_weekly_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ def __init__(self, *args, **kwargs):

def test_when_calling_weekly_publisher_should_generate_single_post_thread_with_all_events_in_chronological_order(self):
events = [
{'country': 'Italy', 'name': 'Festival di Sanremo', 'stage': 'Eurovision Night', 'dateTimeCet': '2021-02-06T20:40:00', 'watchLinks': [{'link': 'https://rai.it', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Norway', 'name': 'Melodi Grand Prix', 'stage': 'Final', 'dateTimeCet': '2021-02-06T19:50:00', 'watchLinks': [{'link': 'https://nrk.no/mgp', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Estonia', 'name': 'Eesti Laul', 'stage': 'Semi-final 1', 'dateTimeCet': '2021-02-02T20:00:00', 'watchLinks': [{'link': 'https://err.tv', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Estonia', 'name': 'Eesti Laul', 'stage': 'Semi-final 1 (part 2)', 'dateTimeCet': '2021-02-02T21:30:00', 'watchLinks': [{'link': 'https://err.tv', 'comment': 'Recommended link', 'live': 1}]},
{'country': 'Sweden', 'name': 'Melodifestivalen', 'stage': 'Heat 1', 'dateTimeCet': '2021-02-06T20:00:00', 'watchLinks': [{'link': 'https://svtplay.se', 'comment': 'Recommended link', 'live': 1}]}
]
summary = self.publisher.publish(events, run_date=datetime.datetime(1970, 1, 1, 9, 0, 0, 0))

expected_post = "\U0001F5D3 COMING UP NEXT WEEK (* = final):\n\n - Tuesday 02: \U0001F1EA\U0001F1EA\n - Saturday 06: \U0001F1F3\U0001F1F4*\U0001F1F8\U0001F1EA"
expected_post = "\U0001F5D3 COMING UP NEXT WEEK (* = final):\n\n - Tuesday 02: \U0001F1EA\U0001F1EA\n - Saturday 06: \U0001F1EE\U0001F1F9*\U0001F1F3\U0001F1F4*\U0001F1F8\U0001F1EA"

self.assertEqual(len(summary), 1)
self.assertEqual(summary[0], expected_post)
Expand Down
Loading