Ejemplo n.º 1
0
    def test_get_formatted_date_for_date_from_another_year(self):
        """should return the longer format when the current date and the 
        creation date are not in the same year"""
        test_channel = Channel("Black County Communion", "Glenn Hughes")
        test_channel.creation_time = datetime.fromisoformat('2017-12-22')

        result = test_channel._get_formatted_date()
        self.assertEqual(result, "on Friday, 22 Dec 2017")        
Ejemplo n.º 2
0
    def test_get_formatted_date_for_date_from_this_year(self):
        """should return the shorter format when the current date and the 
        creation date are in the same year"""
        test_channel = Channel("Dire Straits", "Mark Knopfler")
        test_channel.creation_time = datetime.today().replace(month = 2, 
                                                              day = 10)

        #splitting up the result that came in an "on _dayname_, dd mon" format
        result = test_channel._get_formatted_date()
        day_part, date_part = result.split(", ")
        on_prefix, day_name = day_part.split()

        self.assertEqual(on_prefix, "on")       #asserting the first part
        self.assertIn(day_name, self.day_names)     #checking the day name part
        self.assertEqual(date_part, "10 Feb")   #checking  the date part