Ejemplo n.º 1
0
    def test_get_day_of_creation_from_yesterday(self):
        """should return 'yesterday' if the creation date is a day before the
        current date"""
        test_channel = Channel("Cream", "Strange Brew")
        test_channel.creation_time = datetime.today() - timedelta(1)

        self.assertEqual(test_channel._get_day_of_creation(), "yesterday")
Ejemplo n.º 2
0
    def test_get_day_of_creation_more_than_a_year_ago(self):
        """should return the correct format with year if the creation date was
       more than a year before the current date"""
        test_channel = Channel("Cream", "Strange Brew")
        test_channel.creation_time = datetime.fromisoformat("2017-12-22")

        self.assertEqual(test_channel._get_day_of_creation(), 
                         "on Friday, 22 Dec 2017")
Ejemplo n.º 3
0
    def test_get_day_of_creation_from_6_days_back(self):
        """should return the correct format without year if the creation date 
        was within a week of the current date"""
        test_channel = Channel("Cream", "Strange Brew")
        test_channel.creation_time = datetime.today() - timedelta(6)

        expected_result = test_channel.creation_time.strftime("on %A")
        self.assertEqual(test_channel._get_day_of_creation(), expected_result)
        self.assertIn(expected_result.split()[1], self.day_names)
Ejemplo n.º 4
0
    def test_get_day_of_creation_from_7_days_back(self):
        """should return the correct format without year if the creation date 
        was at least a week before the current date
        """
        test_channel = Channel("Cream", "Strange Brew")
        test_channel.creation_time = datetime.today() - timedelta(7)

        #WARNING! in the first week of the year this case is not tested
        if test_channel.creation_time.year == datetime.today().year:
            expected_result = test_channel.creation_time.strftime(
                "on %A, %#d %b")
        else:
            expected_result = test_channel.creation_time.strftime(
                "on %A, %#d %b %Y")

        self.assertEqual(test_channel._get_day_of_creation(), expected_result)
Ejemplo n.º 5
0
    def test_get_day_of_creation_on_same_day(self):
        """should return 'today' if the creation date is the same as the
        current date"""
        test_channel = Channel("Cream", "Strange Brew")

        self.assertEqual(test_channel._get_day_of_creation(), "today")