Esempio n. 1
0
    def test_dir_missing(self):
        """Hashing a missing dir"""
        checker_1 = FileHash(file_hash_mock_path(self.MOCK_DIR_EMPTY))
        checker_2 = FileHash(file_hash_mock_path(self.MOCK_DIR_MISSING))
        self.assert_paths(checker_1.state(), checker_2.state(), False)

        checker_1 = FileHash(file_hash_mock_path(self.MOCK_DIR))
        checker_2 = FileHash(file_hash_mock_path(self.MOCK_DIR_MISSING))
        self.assert_paths(checker_1.state(), checker_2.state(), False)
Esempio n. 2
0
    def test_file_empty(self):
        """Empty file should not hash the same as a missing file"""
        checker_1 = FileHash(file_hash_mock_path(self.MOCK_FILE_1))
        checker_2 = FileHash(file_hash_mock_path(self.MOCK_FILE_EMPTY))
        self.assert_paths(checker_1.state(), checker_2.state(), False)

        checker_1 = FileHash(file_hash_mock_path(self.MOCK_FILE_EMPTY))
        checker_2 = FileHash(file_hash_mock_path(self.MOCK_FILE_MISSING))
        self.assert_paths(checker_1.state(), checker_2.state(), False)
Esempio n. 3
0
 def test_file_rename(self):
     """Testing changing a file's name"""
     # file hash
     file_1 = file_hash_mock_path(self.MOCK_FILE_1)
     file_2 = file_hash_mock_path(self.MOCK_FILE_1_RENAMED)
     # make sure flags are identical
     assert get_flags(file_1) == get_flags(file_2)
     checker_1 = FileHash(file_1)
     checker_2 = FileHash(file_2)
     assert list(checker_1.state().values())[0] == list(checker_2.state().values())[0]
Esempio n. 4
0
 def test_nested_dir_missing_dir(self):
     """A nested dir that is missing a dir"""
     checker_1 = FileHash(file_hash_mock_path(self.MOCK_DIR))
     checker_2 = FileHash(file_hash_mock_path(self.MOCK_NESTED_DIR_MISSING))
     self.assert_paths(checker_1.state(), checker_2.state(), False)
Esempio n. 5
0
 def test_nested_dir_rename(self):
     """rename dir in nested dir"""
     checker_1 = FileHash(file_hash_mock_path(self.MOCK_DIR))
     checker_2 = FileHash(file_hash_mock_path(self.MOCK_NESTED_DIR_RENAME))
     self.assert_paths(checker_1.state(), checker_2.state(), False)
Esempio n. 6
0
 def test_nested_dir_permission_change(self):
     """changing permissions on a nested dir"""
     checker_1 = FileHash(file_hash_mock_path(self.MOCK_DIR))
     checker_2 = FileHash(file_hash_mock_path(self.MOCK_NESTED_DIR_PERM_CHANGE))
     self.assert_paths(checker_1.state(), checker_2.state(), False)
Esempio n. 7
0
 def test_dir_dir_empty(self):
     """Missing and empty file in nested directory are not the same"""
     checker_1 = FileHash(file_hash_mock_path(self.MOCK_DIR_DIR_MISSING))
     checker_2 = FileHash(file_hash_mock_path(self.MOCK_DIR_DIR_EMPTY))
     self.assert_paths(checker_1.state(), checker_2.state(), False)
Esempio n. 8
0
 def test_dir_file_change(self):
     """A dir containing renamed file"""
     checker_1 = FileHash(file_hash_mock_path(self.MOCK_NESTED))
     checker_2 = FileHash(file_hash_mock_path(self.MOCK_DIR_FILE_CHANGE))
     self.assert_paths(checker_1.state(), checker_2.state(), False)
Esempio n. 9
0
 def test_dir_dir_rename(self):
     """A dir containing renamed dir"""
     checker_1 = FileHash(file_hash_mock_path(self.MOCK_NESTED))
     checker_2 = FileHash(file_hash_mock_path(self.MOCK_DIR_DIR_RENAME))
     self.assert_paths(checker_1.state(), checker_2.state(), False)
Esempio n. 10
0
 def test_dir_missing_dir(self):
     """A dir missing from a dir"""
     checker_1 = FileHash(file_hash_mock_path(self.MOCK_NESTED))
     checker_2 = FileHash(file_hash_mock_path(self.MOCK_DIR_DIR_MISSING))
     self.assert_paths(checker_1.state(), checker_2.state(), False)
Esempio n. 11
0
 def test_dir_permission_change(self):
     """Changing permissions on a dir changes it's hash"""
     checker_1 = FileHash(file_hash_mock_path(self.MOCK_DIR))
     checker_2 = FileHash(file_hash_mock_path(self.MOCK_DIR_DIFF_PERMISSIONS))
     self.assert_paths(checker_1.state(), checker_2.state(), False)
Esempio n. 12
0
 def test_dir_rename(self):
     """Test changing a directory's name"""
     checker_1 = FileHash(file_hash_mock_path(self.MOCK_DIR))
     checker_2 = FileHash(file_hash_mock_path(self.MOCK_DIR_COPY))
     assert list(checker_1.state().values())[0] == list(checker_2.state().values())[0]
Esempio n. 13
0
 def test_dir_hash_test(self):
     """Test hashing a directory"""
     path = file_hash_mock_path(self.MOCK_DIR)
     checker_1 = FileHash(path)
     expected = {path: "f443aa643743df88ff39648d3cc04973813be298bee1c29372a9e103ad20fb47"}
     assert checker_1.state() == expected
Esempio n. 14
0
 def test_file_contents_change(self):
     """Changing file contents should change file and parent dir hash"""
     checker_1 = FileHash(file_hash_mock_path(self.MOCK_FILE_1))
     checker_2 = FileHash(file_hash_mock_path(self.MOCK_FILE_2))
     self.assert_paths(checker_1.state(), checker_2.state(), False)
Esempio n. 15
0
 def test_file_hash(self):
     """Test hashing a single file"""
     path = file_hash_mock_path(self.MOCK_FILE_1)
     checker_1 = FileHash(path)
     expected = {path: "529208ab580d05f4e081d2da2cde8b80da46c39ae8f0a31d20b905057bf2f2bc"}
     assert checker_1.state() == expected