示例#1
0
    def test_get_formatted_creation_time_today_0_02(self):
        """should return the correct formatted creation time when creation was
        today"""
        test_channel = Channel("The Well-dressed Guitar", "Steve Morse")
        test_channel.creation_time = datetime.today().replace(hour=0, minute=2)

        self.assertEqual(test_channel._get_formatted_creation_time(),
                         "today at 0:02")    
示例#2
0
    def test_get_formatted_creation_time_more_than_a_year_ago(self):
        """should return the correct formatted creation time when creation was
        at 10:02 on 22/12/2017"""
        test_channel = Channel("The Well-dressed Guitar", "Steve Morse")
        test_channel.creation_time = datetime.fromisoformat(
            "2017-12-22 10:02:00.000")

        self.assertEqual(test_channel._get_formatted_creation_time(),
                         "on Friday, 22 Dec 2017 at 10:02")    
示例#3
0
    def test_get_formatted_creation_time_yesterday_9_35(self):
        """should return the correct formatted creation time when creation was
        yesterday"""
        test_channel = Channel("The Well-dressed Guitar", "Steve Morse")
        test_channel.creation_time = (datetime.today() - 
            timedelta(1)).replace(hour=9, minute=35)

        self.assertEqual(test_channel._get_formatted_creation_time(),
                         "yesterday at 9:35")
示例#4
0
    def test_get_formatted_creation_time_6_days_ago(self):
        """should return the correct formatted creation time when creation was
        a week ago at 14:30"""
        test_channel = Channel("The Well-dressed Guitar", "Steve Morse")
        test_channel.creation_time = (datetime.today() - 
            timedelta(6)).replace(hour=14, minute=30)

        #splitting up the result that came in an "on _dayname_, dd mon" format
        expected_result = test_channel._get_formatted_creation_time()
        on_prefix, result_without_prefix = expected_result.split(maxsplit=1)
        day_part, time_part = result_without_prefix.split(maxsplit=1)

        self.assertEqual(on_prefix, "on")           #checking the 'on' part
        self.assertIn(day_part, self.day_names)     #checking the day name part
        self.assertEqual(time_part, "at 14:30")     #checking the time part