Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Portal 2361 #2371

Merged
merged 5 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 10 additions & 6 deletions portal/templates/portal/coding_club.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,16 @@ <h4 class="mt-0">Python coding club</h4>
</p>
</div>
<div>
<form method="post", action="{% url 'download_student_pack' 4 %}" class="non-styled--form">
{% csrf_token %}
<button id="python_pack" download type="submit" class="button button--primary button--icon">
Download the Python coding club pack<span class="iconify" data-icon="mdi:tray-arrow-down"></span>
</button>
</form>
<!-- TODO: improve responsiveness -->
<a id="grass_snakes_pack" download class="button button--primary button--icon" href="https://3289537671-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS5kw31UTGL8CPHU9skBS%2Fuploads%2FKsC7tdyT6htj5JX1ig28%2FGrass%20Snakes%20Club.zip?alt=media&token=1f6e6f0e-1a10-4bef-a8f8-a20b0a59e4c0">
Lvl 1: Grass Snakes<span class="iconify" data-icon="mdi:tray-arrow-down"></span>
</a>
<a id="tiger_snakes_pack" download type="submit" class="button button--primary button--icon" href="https://3289537671-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS5kw31UTGL8CPHU9skBS%2Fuploads%2FSIeSsvz348nXjNMcVPxx%2FTiger%20Snakes%20Club.zip?alt=media&token=872b383f-a209-4864-a0e0-26d7ba3a8d74">
Lvl 2: Tiger Snakes<span class="iconify" data-icon="mdi:tray-arrow-down"></span>
</a>
<a id="cobra_snakes_pack" download type="submit" class="button button--primary button--icon" href="https://3289537671-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS5kw31UTGL8CPHU9skBS%2Fuploads%2FITTbTC8DVwr8LdCkN82d%2FCobra%20Club.zip?alt=media&token=bfd94842-cba9-45c7-892b-331bc82c33e9">
Lvl 3: Cobra Snakes<span class="iconify" data-icon="mdi:tray-arrow-down"></span>
</a>
</div>
</div>
</div>
Expand Down
59 changes: 29 additions & 30 deletions portal/tests/test_daily_activities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import timedelta, datetime
from datetime import datetime, timedelta

from common.models import DailyActivity
from selenium.webdriver.common.by import By
Expand All @@ -7,35 +7,34 @@

from portal.tests.base_test import BaseTest

# class TestDailyActivities(BaseTest):
# def test_coding_club_increment(self):

class TestDailyActivities(BaseTest):
def test_coding_club_increment(self):
# # first create dailyActivity one day before datetime.now()
# # to check if it can handle incrementing on different days
# # then check if increments are done on the same day
# old_date = datetime.now() - timedelta(days=1)
# old_daily_activity = DailyActivity(date=old_date)
# old_daily_activity.save()

# first create dailyActivity one day before datetime.now()
# to check if it can handle incrementing on different days
# then check if increments are done on the same day
old_date = datetime.now() - timedelta(days=1)
old_daily_activity = DailyActivity(date=old_date)
old_daily_activity.save()
# for i in range(4):
# # check both buttons
# self.go_to_homepage()
# button_id = "primary_pack" if i < 2 else "python_pack"
# find_out_more_button = WebDriverWait(self.selenium, 10).until(
# EC.element_to_be_clickable((By.ID, "find_out_more"))
# )
# find_out_more_button.click()

for i in range(4):
# check both buttons
self.go_to_homepage()
button_id = "primary_pack" if i < 2 else "python_pack"
find_out_more_button = WebDriverWait(self.selenium, 10).until(
EC.element_to_be_clickable((By.ID, "find_out_more"))
)
find_out_more_button.click()

daily_count_button = WebDriverWait(self.selenium, 10).until(
EC.visibility_of_element_located((By.ID, button_id))
)
daily_count_button.click()
# check the old_date is still the same
old_daily_activity = DailyActivity.objects.get(date=old_date)
assert old_daily_activity.primary_coding_club_downloads == 0
assert old_daily_activity.python_coding_club_downloads == 0
# check the current_date is incremented to 2
current_daily_activity = DailyActivity.objects.get(date=datetime.now())
assert current_daily_activity.primary_coding_club_downloads == 2
assert current_daily_activity.python_coding_club_downloads == 2
# daily_count_button = WebDriverWait(self.selenium, 10).until(
# EC.visibility_of_element_located((By.ID, button_id))
# )
# daily_count_button.click()
# # check the old_date is still the same
# old_daily_activity = DailyActivity.objects.get(date=old_date)
# assert old_daily_activity.primary_coding_club_downloads == 0
# assert old_daily_activity.python_coding_club_downloads == 0
# # check the current_date is incremented to 2
# current_daily_activity = DailyActivity.objects.get(date=datetime.now())
# assert current_daily_activity.primary_coding_club_downloads == 2
# assert current_daily_activity.python_coding_club_downloads == 2
Loading