示例#1
0
    def test_get_file_returns_more_recent_file(self, tmp_path):
        old_file = tmp_path.joinpath("log_1-1-2021-00:00:00_test_file.log")
        old_file.write_text("hello")

        new_file = tmp_path.joinpath("log_2-1-2021-00:00:00_test_file.log")
        new_file.write_text("hello2")

        assert file_utils.get_file(tmp_path, self.filename) == new_file
        assert file_utils.get_file(tmp_path, self.filename).read_text() == "hello2"
示例#2
0
    def test_get_file_returns_smaller_file(self, tmp_path):
        kilobyte_filepath = tmp_path.joinpath("log_1-1-2021-00:00:00_test_file.log")
        with kilobyte_filepath.open(mode="w+") as file:
            file.seek(1024)
            file.write('\0')

        assert file_utils.get_file(tmp_path, self.filename, 512) != kilobyte_filepath
示例#3
0
    def test_get_file_returns_file_if_it_exists(self, tmp_path):
        test_text = "Hello World"

        expected_file = tmp_path.joinpath("log_1-1-2021-00:00:00_test_file.log")
        expected_file.write_text(test_text)

        test_file = file_utils.get_file(tmp_path, self.filename)

        assert expected_file == test_file
        assert expected_file.read_text() == test_text
示例#4
0
 def test_get_file_return_is_not_none(self, tmp_path):
     assert file_utils.get_file(tmp_path, self.filename) is not None
示例#5
0
 def test_get_file_returns_file_with_correct_prefix(self, tmp_path):
     assert file_utils.get_file(tmp_path, self.filename).name.startswith("log_")
示例#6
0
 def test_get_file_returns_new_file(self, tmp_path):
     assert file_utils.get_file(tmp_path, self.filename).exists() is False
示例#7
0
 def test_get_file_is_in_correct_directory(self, tmp_path):
     assert file_utils.get_file(tmp_path, self.filename).parent == tmp_path
示例#8
0
 def test_get_file_return_is_a_path(self, tmp_path):
     assert isinstance(file_utils.get_file(tmp_path, self.filename), Path)