Beispiel #1
0
    def test_parse_time(self):
        self.assertEqual(ftp_parse._parse_time('JUL 05 1974'), 142128000.0)

        year = time.localtime().tm_year
        self.assertEqual(ftp_parse._parse_time('JUL 05 02:00'), 1467597600.0)

        self.assertEqual(ftp_parse._parse_time("notadate"), None)
    def test_parse_time(self, mock_localtime):
        self.assertEqual(ftp_parse._parse_time('JUL 05 1974'), 142214400.0)

        mock_localtime.return_value = time2017
        self.assertEqual(ftp_parse._parse_time('JUL 05 02:00'), 1499220000.0)

        self.assertEqual(ftp_parse._parse_time("notadate"), None)
    def test_parse_time(self, mock_localtime):
        self.assertEqual(
            ftp_parse._parse_time("JUL 05 1974", formats=["%b %d %Y"]),
            142214400.0)

        mock_localtime.return_value = time2017
        self.assertEqual(
            ftp_parse._parse_time("JUL 05 02:00", formats=["%b %d %H:%M"]),
            1499220000.0)

        self.assertEqual(
            ftp_parse._parse_time("05-07-17  02:00AM",
                                  formats=["%d-%m-%y %I:%M%p"]), 1499220000.0)

        self.assertEqual(
            ftp_parse._parse_time("notadate", formats=["%b %d %Y"]), None)