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

adding tests and logic #104

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rimonsh
Copy link
Collaborator

@rimonsh rimonsh commented May 16, 2023

What this PR does?

This PR I tested Poll suggestion Saving to django DB, whether it's in the past , or there's already a suggestion in the same time.

Notes for reviewer

I would be more than happy to hear more suggestions on how to check if suggested time is in the past (less than datetime.now() ).
For some reason, the line "if self.time < timezone.now():" is not passing.

Related Issue

Resolves #103

Test coverage

-Testing suggested time is not in the past.
-Testing that there's no other suggestion like it in the same poll.

@Sendy459
Copy link
Collaborator

You can try to make them both offset naive :
by using .replace(tzinfo=None) before comparing
as I did in this func in Poll model.py file
def time_remaining(self):
remaining = self.end_time.replace(tzinfo=None) - timezone.localtime().replace(tzinfo=None)
if remaining < timedelta():
return timedelta()
return remaining

poll_suggestion/models.py Outdated Show resolved Hide resolved
poll_suggestion/tests.py Show resolved Hide resolved
Copy link
Contributor

@rotem2022 rotem2022 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, I Just added a small idea

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe consider to add a field that tracks the number of votes each suggestion receives. This addition can provide valuable data for evaluating the popularity for each suggestion. Or you thought of alternative way for determining the chosen suggestion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding Poll Suggestion logic and test
5 participants