Example #1
0
 def is_completed(self):
     if self.action == FileActionType.COPY:
         return is_copied(self.origin, self.destination)
     elif self.action == FileActionType.SYMLINK:
         return is_linked(self.origin, self.destination)
     else:
         raise NotImplementedError(
             f"File Action: The action `{self.action}` is not supported yet (feel free to open a ticket on github!)"
         )
Example #2
0
def test_copy_check_fail_no_destination_file(tmpdir):
    # Setup
    original_file = tmpdir.join("origin.somefile")
    destination_file = tmpdir.join("destination.somefile")

    # System under test
    is_files_copied = is_copied(original_file, destination_file)

    # Verification
    assert is_files_copied is False
Example #3
0
def test_copy_check_fail_symlink(tmpdir):
    # Setup
    original_file = tmpdir.join("origin.somefile")
    destination_file = tmpdir.join("destination.somefile")
    original_file_content = "some content"
    original_file.write(original_file_content)
    symlink_file(original_file, destination_file)

    # System under test
    is_files_copied = is_copied(original_file, destination_file)

    # Verification
    assert is_files_copied is False
Example #4
0
def test_copy_check_fail_different_file_sizes(tmpdir):
    # Setup
    original_file = tmpdir.join("origin.somefile")
    destination_file = tmpdir.join("destination.somefile")
    original_file_content = "some content"
    original_file.write(original_file_content)
    destination_file_content = "some other content"
    destination_file.write(destination_file_content)

    # System under test
    is_files_copied = is_copied(original_file, destination_file)

    # Verification
    assert is_files_copied is False
Example #5
0
def test_copy_check_fail_different_metadata(tmpdir):
    # Setup
    original_file = tmpdir.join("origin.somefile")
    destination_file = tmpdir.join("destination.somefile")
    same_file_content = "same content"
    original_file.write(same_file_content)
    destination_file.write(same_file_content)

    original_file_modified_time = os.path.getmtime(original_file)
    modified_time = original_file_modified_time + 1
    os.utime(destination_file, (modified_time, modified_time))

    # System under test
    is_files_copied = is_copied(original_file, destination_file)

    # Verification
    assert is_files_copied is False