예제 #1
0
    def test_two_mtimes_have_different_values(self):
        """Two stored modification times have different values."""
        with testutil.in_tempdir(os.getcwd(), "mtimes"):
            util.store_current_mtime_in("1")
            time.sleep(1)
            util.store_current_mtime_in("2")

            self.assertThat(util.fetch_mtime_from("2"),
                            GreaterThan(util.fetch_mtime_from("1")))
예제 #2
0
    def test_no_act_where_file_doesnt_exist(self):
        """Don't perform action when candidate file doesn't exist."""
        with testutil.in_tempdir(os.getcwd(), "mtimes"):
            callee = Mock()
            util.where_more_recent(PrepopulatedMTimeContainer(None),
                                   os.path.join(os.getcwd(), "temp"),
                                   util.fetch_mtime_from("1"),
                                   callee)

            self.assertEqual(callee.call_args_list, list())
예제 #3
0
    def test_act_on_no_mtime_file(self):
        """Perform action when modification time file doesn't exist."""
        with testutil.in_tempdir(os.getcwd(), "mtimes"):
            callee = Mock()
            with open("temporary_file", "w") as temporary_file:
                temporary_file.write("contents")
                temporary_file.flush()

            container = PrepopulatedMTimeContainer(temporary_file.name)
            util.where_more_recent(container,
                                   temporary_file.name,
                                   util.fetch_mtime_from("1"),
                                   callee)

            self.assertThat(callee.call_args_list, Not(Equals(list())))
예제 #4
0
    def test_no_act_where_file_is_up_to_date(self):
        """Don't perform action when candidate file is up to date."""
        with testutil.in_tempdir(os.getcwd(), "mtimes"):
            callee = Mock()
            with open("temporary_file", "w") as temporary_file:
                temporary_file.write("contents")
                temporary_file.flush()

            container = PrepopulatedMTimeContainer(temporary_file.name)

            time.sleep(1)
            util.store_current_mtime_in("1")

            util.where_more_recent(container,
                                   temporary_file.name,
                                   util.fetch_mtime_from("1"),
                                   callee)

            self.assertEqual(callee.call_args_list, list())