예제 #1
0
 def test_create_from_values(self):
     for hash_type, source_types in hashes_test_cases.items():
         dh = DlrnHash(**source_types['dict']['valid'])
         if hash_type == "commitdistro":
             self.assertEqual(type(dh), DlrnCommitDistroHash)
         elif hash_type == 'aggregate':
             self.assertEqual(type(dh), DlrnAggregateHash)
예제 #2
0
 def test_commit_dir_component(self):
     for hash_type, source_types in hashes_test_cases.items():
         dh = DlrnHash(source=source_types['object']['valid'])
         if hash_type == "commitdistro":
             dh.component = "component1"
             self.assertEqual(dh.commit_dir,
                              "component/component1/ab/cd/abcd_defg")
예제 #3
0
 def test_commit_dir_no_label(self):
     for hash_type, source_types in hashes_test_cases.items():
         dh = DlrnHash(source=source_types['object']['valid'])
         if hash_type == "commitdistro":
             self.assertEqual(dh.commit_dir, "ab/cd/abcd_defg")
         elif hash_type == "aggregate":
             self.assertEqual(dh.commit_dir, "ab/cd/abcd")
예제 #4
0
 def test_create_from_object(self):
     # Prevent Mock class to identify as dict
     for hash_type, source_types in hashes_test_cases.items():
         source_valid = source_types['object']['valid']
         DlrnHash(source=source_valid)
         with self.assertRaises(DlrnHashError):
             source_invalid = source_types['object']['invalid']
             DlrnHash(source=source_invalid)
예제 #5
0
 def test_create_from_dict(self):
     for hash_type, source_types in hashes_test_cases.items():
         dh = DlrnHash(source=source_types['dict']['valid'])
         if hash_type == "commitdistro":
             self.assertEqual(type(dh), DlrnCommitDistroHash)
         elif hash_type == "aggregate":
             self.assertEqual(type(dh), DlrnAggregateHash)
         with self.assertRaises(DlrnHashError):
             DlrnHash(source=source_types['dict']['invalid'])
예제 #6
0
 def test_properties(self):
     for hash_type, source_types in hashes_test_cases.items():
         source = source_types['object']['valid']
         dh = DlrnHash(source=source)
         if hash_type == "commitdistro":
             full_hash = "{}_{}".format(source.commit_hash,
                                        source.distro_hash[:8])
             self.assertEqual(dh.full_hash, full_hash)
         elif hash_type == "aggregate":
             self.assertEqual(dh.full_hash, source.aggregate_hash)
예제 #7
0
 def test_dump_to_params(self):
     for hash_type, source_types in hashes_test_cases.items():
         params = Mock()
         dh = DlrnHash(source=source_types['object']['valid'])
         dh.dump_to_params(params)
         if hash_type == "commitdistro":
             self.assertEqual(params.commit_hash, dh.commit_hash)
             self.assertEqual(params.distro_hash, dh.distro_hash)
         elif hash_type == "aggregate":
             self.assertEqual(params.aggregate_hash, dh.aggregate_hash)
         self.assertEqual(params.timestamp, dh.timestamp)
예제 #8
0
 def test_comparisons(self):
     non_dh = {}
     for hash_type, source_types in hashes_test_cases.items():
         dh1 = DlrnHash(source=source_types['object']['valid'])
         dh2 = DlrnHash(source=source_types['object']['valid'])
         self.assertEqual(dh1, dh2)
         dh2 = DlrnHash(source=source_types['object']['different'])
         self.assertNotEqual(dh1, dh2)
         with self.assertRaises(TypeError):
             (dh1 == non_dh)
         with self.assertRaises(TypeError):
             (dh1 != non_dh)
         dh1 = DlrnHash(source=source_types['object']['valid_notimestamp'])
         dh2 = DlrnHash(source=source_types['object']['valid_notimestamp'])
         self.assertEqual(dh1, dh2)
예제 #9
0
 def test_build_valid_from_source(self):
     for hash_type, source_types in hashes_test_cases.items():
         values = source_types['dict']['valid']
         if hash_type == "commitdistro":
             dh = DlrnCommitDistroHash(source=values)
             self.assertEqual(dh.commit_hash,
                              source_types['dict']['valid']['commit_hash'])
             self.assertEqual(dh.distro_hash,
                              source_types['dict']['valid']['distro_hash'])
         elif hash_type == "aggregate":
             aggregate_hash = source_types['dict']['valid'][
                 'aggregate_hash']
             dh = DlrnAggregateHash(source=values)
             self.assertEqual(dh.aggregate_hash, aggregate_hash)
     self.assertEqual(dh.timestamp,
                      source_types['dict']['valid']['timestamp'])