コード例 #1
0
 def test_is_published_with_old_and_recent_question(self):
     """is_published() returns True for questions whose pub_date is in the older or within the last day."""
     old_time = timezone.now() - datetime.timedelta(days=1, seconds=1)
     new_time = timezone.now() - datetime.timedelta(seconds=1)
     old_question = Question(pub_date=old_time)
     new_question = Question(pub_date=new_time)
     self.assertIs(old_question.is_published(), True)
     self.assertIs(new_question.is_published(), True)
コード例 #2
0
ファイル: tests_model.py プロジェクト: LevNut/ku-polls
 def test_published_after_end_time(self):
     """Check that the vote is currently allowed after publication date."""
     pub = \
         timezone.now() - datetime.timedelta(hours=23, minutes=59)
     end = pub + abs(datetime.timedelta(hours=22, minutes=59))
     recent_question = Question(pub_date=pub, end_date=end)
     self.assertIs(recent_question.is_published(), True)
コード例 #3
0
ファイル: tests_model.py プロジェクト: LevNut/ku-polls
 def test_published_before_pub_time(self):
     """Check the vote is currently allowed before publication date."""
     pub = \
         timezone.now() + datetime.timedelta(hours=23, minutes=59)
     end = pub + abs(datetime.timedelta(days=2))
     recent_question = Question(pub_date=pub, end_date=end)
     self.assertIs(recent_question.is_published(), False)
コード例 #4
0
 def test_is_published_with_future_question(self):
     """
     Test published question by future. If yes, return False.
     """
     time = timezone.now() + datetime.timedelta(days=30)
     future_question = Question(pub_date=time)
     self.assertFalse(future_question.is_published())
コード例 #5
0
 def test_is_published_with_old_question(self):
     """
     Test published question by past. If yes, return True.
     """
     time = timezone.now() - datetime.timedelta(days=1, seconds=1)
     old_question = Question(pub_date=time)
     self.assertTrue(old_question.is_published())
コード例 #6
0
 def test_is_published_with_future_question(self):
     """is_published() returns False for questions whose pub_date is in the future."""
     time = timezone.now() + datetime.timedelta(days=30)
     future_question = Question(pub_date=time)
     self.assertFalse(
         future_question.is_published(),
         "is_published should be False because it's not release yet")
コード例 #7
0
 def test_can_vote_before_pub_date(self):
     """The user could not vote before pub date."""
     now = timezone.now()
     question = Question("Test1", pub_date=now + datetime.timedelta(days=1))
     self.assertTrue(now < question.pub_date)
     self.assertFalse(question.is_published())
     self.assertFalse(question.can_vote())
コード例 #8
0
 def test_is_published_with_future_question(self):
     """
     is_published() return False for questions whose pub_date
     is in the future.
     """
     time = timezone.now() + datetime.timedelta(days=30)
     future_question = Question(pub_date=time)
     self.assertIs(future_question.is_published(), False)
コード例 #9
0
ファイル: tests_model.py プロジェクト: LevNut/ku-polls
 def test_published_between_pub_and_end_time(self):
     """Check the vote is currently allowed\
         between publication and end date."""
     pub = \
         timezone.now() - datetime.timedelta(hours=23, minutes=59)
     end = pub + abs(datetime.timedelta(days=2))
     recent_question = Question(pub_date=pub, end_date=end)
     self.assertIs(recent_question.is_published(), True)
コード例 #10
0
 def test_is_published_with_recent_question(self):
     """
     Test published question by now. If yes, return True.
     """
     time = timezone.now() - datetime.timedelta(
         hours=23, minutes=59, seconds=59)
     recent_question = Question(pub_date=time)
     self.assertTrue(recent_question.is_published())
コード例 #11
0
 def test_is_published_after_pub_date(self):
     """The question is not published after pub date."""
     now = timezone.now()
     question = Question("Test1",
                         pub_date=now - datetime.timedelta(days=2),
                         end_date=now - datetime.timedelta(days=1))
     self.assertTrue(now > question.end_date)
     self.assertTrue(question.is_published())
コード例 #12
0
 def test_is_publish_with_one_year_question(self):
     """
     is_published() return True for questions whose pub_date
     is older than current time no matter how old it is.
     """
     time = timezone.now() - datetime.timedelta(days=365)
     very_old_question = Question(pub_date=time)
     self.assertIs(very_old_question.is_published(), True)
コード例 #13
0
 def test_can_vote_after_end_date(self):
     """The user could not vote after end date."""
     now = timezone.now()
     question = Question("Test1",
                         pub_date=now - datetime.timedelta(days=2),
                         end_date=now - datetime.timedelta(days=1))
     self.assertTrue(now > question.end_date)
     self.assertTrue(question.is_published())
     self.assertFalse(question.can_vote())
コード例 #14
0
 def test_is_published_on_date(self):
     """The question is published on pub date time."""
     now = timezone.now()
     question = Question("Test1",
                         pub_date=now - datetime.timedelta(days=1),
                         end_date=now + datetime.timedelta(days=3))
     self.assertTrue(now >= question.pub_date)
     self.assertTrue(now <= question.end_date)
     self.assertTrue(question.is_published())
コード例 #15
0
    def test_is_published(self):
        """Test if question is published.

        Test if the question can vote.

        """
        time = timezone.now() + datetime.timedelta(days=-1)
        past_question = Question(pub_date=time)
        self.assertIs(past_question.is_published(), True)
コード例 #16
0
 def test_can_vote(self):
     """The user could vote between pub date and end date interval."""
     now = timezone.now()
     question = Question("Test1",
                         pub_date=now - datetime.timedelta(days=1),
                         end_date=now + datetime.timedelta(days=3))
     self.assertTrue(now >= question.pub_date)
     self.assertTrue(now <= question.end_date)
     self.assertTrue(question.is_published())
     self.assertTrue(question.can_vote())
コード例 #17
0
ファイル: test_poll_dates.py プロジェクト: ZEZAY/ku-polls
    def test_is_published_is_work(self):
        """Test for is_published().

        is_published() must returns True for questions
        whose pub_date is already published.
        """
        time = timezone.now()
        day_before = time - self.add_time_one_year
        after_day = time + self.add_time_one_year
        question1 = Question(pub_date=time, end_date=after_day)
        self.assertIs(question1.is_published(), True)
        question2 = Question(pub_date=day_before, end_date=after_day)
        self.assertIs(question2.is_published(), True)
        question3 = Question(pub_date=after_day,
                             end_date=after_day + self.add_time_one_year)
        self.assertIs(question3.is_published(), False)
        question4 = Question(pub_date=after_day, end_date=time)
        self.assertIs(question4.is_published(), False)
        question5 = Question(pub_date=time, end_date=time)
        self.assertIs(question5.is_published(), True)
コード例 #18
0
ファイル: test_models.py プロジェクト: nuttapol-kor/ku-polls
 def test_is_published_with_old_question(self):
     """is_published() return True for questions when reach to pub_date."""
     time = timezone.now() - datetime.timedelta(days=1, seconds=1)
     old_question = Question(pub_date=time)
     self.assertIs(old_question.is_published(), True)
コード例 #19
0
 def test_is_published_with_recent_question(self):
     """is_published() returns True for questions whose pub_date is in the past."""
     time = timezone.now()
     future_question = Question(pub_date=time)
     self.assertTrue(future_question.is_published(),
                     "is_published should be True because it's release")
コード例 #20
0
 def test_is_published_with_old_question(self):
     """is_published() returns True for questions whose pub_date is in the past."""
     time = timezone.now() - datetime.timedelta(days=30)
     future_question = Question(pub_date=time)
     self.assertTrue(future_question.is_published(),
                     "is_published should be False because it's release")
コード例 #21
0
 def tsst_not_published_question(self):
     """is_published() method will return False if poll not published."""
     pub = timezone.now() + datetime.timedelta(days=1)
     end = timezone.now() + datetime.timedelta(days=5)
     not_published_question = Question(pub_date=pub, end_date=end)
     self.assertIs(not_published_question.is_published(), False)
コード例 #22
0
 def test_published_question(self):
     """is_published() method will return True if poll already published."""
     pub = timezone.now() + datetime.timedelta(days=-1)
     end = timezone.now() + datetime.timedelta(days=5)
     published_question = Question(pub_date=pub, end_date=end)
     self.assertIs(published_question.is_published(), True)
コード例 #23
0
 def test_is_published_with_current_date_is_before_publication_date(self):
     """is_published() returns False if current date is before question’s publication date."""
     time = timezone.now() + datetime.timedelta(
         hours=23, minutes=59, seconds=59)
     recent_question = Question(pub_date=time)
     self.assertIs(recent_question.is_published(), False)
コード例 #24
0
 def test_is_published_with_future_question(self):
     """ return False if the current time is before the question was published """
     time = timezone + datetime.timedelta(days=30)
     future_question = Question(pub_date=time)
     self.assertIs(future_question.is_published(), False)
コード例 #25
0
ファイル: test_models.py プロジェクト: nuttapol-kor/ku-polls
 def test_is_published_with_recent_question(self):
     """is_published() return True for questions when reach to pub_date."""
     time = timezone.now() - datetime.timedelta(
         hours=23, minutes=59, seconds=59)
     recent_question = Question(pub_date=time)
     self.assertIs(recent_question.is_published(), True)
コード例 #26
0
ファイル: test_models.py プロジェクト: bleachjade/ku-polls
 def test_is_published_with_old_question(self):
     """is_published() return Ture if current date is after question's publication date."""
     time = timezone.now() - datetime.timedelta(days=1)
     old_question = Question(pub_date=time)
     self.assertIs(old_question.is_published(), True)
コード例 #27
0
ファイル: test_models.py プロジェクト: bleachjade/ku-polls
 def test_is_published_with_future_question(self):
     """is_published() return False if current date is before question's publication date."""
     time = timezone.now() + datetime.timedelta(days=10)
     future_question = Question(pub_date=time)
     self.assertIs(future_question.is_published(), False)
コード例 #28
0
 def test_is_published_with_not_published_question(self):
     """Check is_published with not published question."""
     end_time = timezone.now() + datetime.timedelta(days=1)
     question = Question(pub_date=end_time)
     self.assertFalse(question.is_published())
コード例 #29
0
ファイル: test_models.py プロジェクト: bleachjade/ku-polls
 def test_is_published_with_present_question(self):
     """is_published() return Ture if current date is on question's publication date."""
     time = timezone.now()
     present_question = Question(pub_date=time)
     self.assertIs(present_question.is_published(), True)
コード例 #30
0
 def test_is_published(self):
     """Check for normal is_published."""
     time = timezone.now() - datetime.timedelta(days=1)
     question = Question(pub_date=time)
     self.assertTrue(question.is_published())