Skip to content

test: avoid local times near midnight for test_past_swap_days_buttons() - #4642

Merged
rjsparks merged 4 commits into
ietf-tools:mainfrom
painless-security:jennifer/avoid-midnight
Oct 26, 2022
Merged

test: avoid local times near midnight for test_past_swap_days_buttons()#4642
rjsparks merged 4 commits into
ietf-tools:mainfrom
painless-security:jennifer/avoid-midnight

Conversation

@jennifer-richards

Copy link
Copy Markdown
Member

Fixes occasional failure in test_past_swap_days_buttons(). That test assumed that, in the meeting time zone, a timeslot one second in the past was on the same day as one 9 minutes in the future. The time zone for the meeting was chosen at random. If the test ran at any time more than 51 minutes past the hour, there was a chance that these two meetings would fall on opposite sides of midnight in the meeting time zone. When this happened, the test failed.

This PR introduces and uses a helper method ietf.utils.timezone.timezone_not_near_midnight() that randomly chooses a time zone where timezone.now() represented in that zone is not between 23:00 and 00:59. This is done with a random guess-and-check using pytz.common_timezones. This can change to zoneinfo.available_timezones() when we drop pytz (or before, though with a small risk that zoneinfo suggests a timezone not known to pytz).

@codecov

codecov Bot commented Oct 25, 2022

Copy link
Copy Markdown

Codecov Report

Merging #4642 (85c3ad0) into main (d34e88d) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #4642      +/-   ##
==========================================
- Coverage   88.43%   88.40%   -0.03%     
==========================================
  Files         296      296              
  Lines       39716    39730      +14     
==========================================
+ Hits        35122    35125       +3     
- Misses       4594     4605      +11     
Impacted Files Coverage Δ
ietf/utils/timezone.py 91.17% <100.00%> (+6.17%) ⬆️
ietf/utils/pipe.py 82.60% <0.00%> (-4.35%) ⬇️
ietf/doc/views_search.py 88.81% <0.00%> (-1.45%) ⬇️
ietf/utils/mail.py 79.62% <0.00%> (-0.47%) ⬇️
ietf/submit/forms.py 82.70% <0.00%> (-0.18%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@rjsparks
rjsparks merged commit e290d9e into ietf-tools:main Oct 26, 2022
@jennifer-richards
jennifer-richards deleted the jennifer/avoid-midnight branch October 26, 2022 15:35
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants