コード例 #1
0
def test_calculate_hash_different_ordering(tmpdir, all_files):
    root = tmpdir

    all_files_diff_order = random.sample(all_files, k=len(all_files))
    hash1 = _calculate_hash(map(str, all_files), str(root))
    hash2 = _calculate_hash(map(str, all_files_diff_order), str(root))
    assert hash1 == hash2
コード例 #2
0
ファイル: test_lambda.py プロジェクト: sbraverman/stacker
 def test_calculate_hash_diff_filename_same_contents(self):
     files = ["file1.txt", "f2/file2.txt"]
     file1, file2 = files
     with TempDirectory() as d:
         root = d.path
         for fname in files:
             d.write(fname, "data")
         hash1 = _calculate_hash([file1], root)
         hash2 = _calculate_hash([file2], root)
     self.assertNotEqual(hash1, hash2)
コード例 #3
0
ファイル: test_aws_lambda.py プロジェクト: acmcelwee/stacker
 def test_calculate_hash_diff_filename_same_contents(self):
     files = ["file1.txt", "f2/file2.txt"]
     file1, file2 = files
     with TempDirectory() as d:
         root = d.path
         for fname in files:
             d.write(fname, b"data")
         hash1 = _calculate_hash([file1], root)
         hash2 = _calculate_hash([file2], root)
     self.assertNotEqual(hash1, hash2)
コード例 #4
0
def test_calculate_hash_diff_filename_same_contents(tmpdir, all_files):
    root = tmpdir

    files = all_files[:2]
    tmpdir.join(files[0]).write('data', ensure=True)
    tmpdir.join(files[1]).write('data', ensure=True)

    hash1 = _calculate_hash([str(files[0])], str(root))
    hash2 = _calculate_hash([str(files[1])], str(root))

    assert hash1 != hash2
コード例 #5
0
def test_calculate_hash(tmpdir, all_files, f1_files, f2_files):
    root = tmpdir

    all_hash_1 = _calculate_hash(map(str, all_files), str(root))
    all_hash_2 = _calculate_hash(map(str, all_files), str(root))
    f1_hash = _calculate_hash(map(str, f1_files), str(root))
    f2_hash = _calculate_hash(map(str, f2_files), str(root))

    assert all_hash_1 == all_hash_2
    assert f1_hash != all_hash_1
    assert f2_hash != all_hash_1
    assert f1_hash != f2_hash
コード例 #6
0
ファイル: test_lambda.py プロジェクト: sbraverman/stacker
 def test_calculate_hash_different_ordering(self):
     files1 = ALL_FILES
     files2 = random.sample(ALL_FILES, k=len(ALL_FILES))
     with TempDirectory() as d1:
         root1 = d1.path
         for fname in files1:
             d1.write(fname, "")
         with TempDirectory() as d2:
             root2 = d2.path
             for fname in files2:
                 d2.write(fname, "")
             hash1 = _calculate_hash(files1, root1)
             hash2 = _calculate_hash(files2, root2)
             self.assertEqual(hash1, hash2)
コード例 #7
0
ファイル: test_aws_lambda.py プロジェクト: acmcelwee/stacker
 def test_calculate_hash_different_ordering(self):
     files1 = ALL_FILES
     files2 = random.sample(ALL_FILES, k=len(ALL_FILES))
     with TempDirectory() as d1:
         root1 = d1.path
         for fname in files1:
             d1.write(fname, b"")
         with TempDirectory() as d2:
             root2 = d2.path
             for fname in files2:
                 d2.write(fname, b"")
             hash1 = _calculate_hash(files1, root1)
             hash2 = _calculate_hash(files2, root2)
             self.assertEqual(hash1, hash2)
コード例 #8
0
ファイル: test_lambda.py プロジェクト: sbraverman/stacker
    def test_calculate_hash(self):
        with self.temp_directory_with_files() as d1:
            root = d1.path
            hash1 = _calculate_hash(ALL_FILES, root)

        with self.temp_directory_with_files() as d2:
            root = d2.path
            hash2 = _calculate_hash(ALL_FILES, root)

        with self.temp_directory_with_files() as d3:
            root = d3.path
            with open(os.path.join(root, ALL_FILES[0]), "w") as fd:
                fd.write("modified file data")
            hash3 = _calculate_hash(ALL_FILES, root)

        self.assertEqual(hash1, hash2)
        self.assertNotEqual(hash1, hash3)
        self.assertNotEqual(hash2, hash3)
コード例 #9
0
ファイル: test_aws_lambda.py プロジェクト: acmcelwee/stacker
    def test_calculate_hash(self):
        with self.temp_directory_with_files() as d1:
            root = d1.path
            hash1 = _calculate_hash(ALL_FILES, root)

        with self.temp_directory_with_files() as d2:
            root = d2.path
            hash2 = _calculate_hash(ALL_FILES, root)

        with self.temp_directory_with_files() as d3:
            root = d3.path
            with open(os.path.join(root, ALL_FILES[0]), "w") as fd:
                fd.write("modified file data")
            hash3 = _calculate_hash(ALL_FILES, root)

        self.assertEqual(hash1, hash2)
        self.assertNotEqual(hash1, hash3)
        self.assertNotEqual(hash2, hash3)