Beispiel #1
0
    def test_should_overwrite_existing_file(self):
        file_put_contents(get_deploy_timestamp_filename(), 'hello world')
        save_deploy_timestamp()

        timestamp = datetime.strptime(
            file_get_contents(get_deploy_timestamp_filename()),
            '%Y-%m-%dT%H:%M:%S'
        )
        self.assertEqual(datetime.now(), timestamp)
Beispiel #2
0
    def test_should_save_timestamp_in_iso_format(self):
        ts = save_deploy_timestamp()

        timestamp = datetime.strptime(
            file_get_contents(get_deploy_timestamp_filename()),
            '%Y-%m-%dT%H:%M:%S'
        )
        self.assertEqual(datetime.now(), timestamp)
        self.assertEqual(datetime.now(), ts)
Beispiel #3
0
 def test_should_return_none_if_incorrect_timestamp_format(self):
     file_put_contents(get_deploy_timestamp_filename(), 'not an ISO formatted timestamp')
     self.assertIsNone(load_deploy_timestamp())
Beispiel #4
0
 def test_should_return_none_if_file_does_not_exist(self):
     delete_deploy_timestamp()
     self.assertFalse(os.path.exists(get_deploy_timestamp_filename()))
     self.assertIsNone(load_deploy_timestamp())
Beispiel #5
0
 def test_should_return_correct_path_to_timestamp_file(self):
     self.assertEqual(
         os.path.join(settings.STATIC_ROOT, 'deployts'),
         get_deploy_timestamp_filename()
     )