def test_put_tags_to_map__should_increment_values_for_keys(self): actual = { 'TAG_1': Tag(['file']), 'TAG_2': Tag(['file']), 'TAG_3': Tag(['file']) } tags = ['TAG_1', 'TAG_2', 'TAG_3'] files_controller.put_tags_to_map(actual, tags, File('', None, 5, 5)) self.assertEquals(2, actual['TAG_1'].get_files_count()) self.assertEquals(2, actual['TAG_2'].get_files_count()) self.assertEquals(2, actual['TAG_3'].get_files_count())
def test_sort_tags__should_sort_by_tags_count(self): controller = FilesController( '', [File('name.java', None, 20, 4), File('name2.java', None, 3, 1)], self.language) controller.tags = { 'TAG_1': Tag([File]), 'TAG_2': Tag([File, File, File]) } sorted_tags = files_controller.sort(controller.tags, False) self.assertEqual('TAG_1', sorted_tags[0][0]) self.assertEqual('TAG_2', sorted_tags[1][0])
class TestTag(TestCase): def setUp(self): self.tag = Tag(['SyncManager', 'SyncConfig', 'SyncFactory']) def test_get_files_count_should_return_three(self): actual = self.tag.get_files_count() expected = 3 self.assertEqual(expected, actual) def test_add_file_should_add_one_file(self): self.tag.add_file('SyncFoo') actual = self.tag.files expected = ['SyncManager', 'SyncConfig', 'SyncFactory', 'SyncFoo'] self.assertEqual(expected, actual)
def test_add_test_files_to_files_in_tags__should_pair_correctly(self): tags = { 'TAG_1': Tag([ File( 'MedicalSampleSeriesQuantitySpentPerMedicalClientForProducer.java', None, 0, 0), File( 'MedicalSampleSeriesQuantitySpentPerMedicalClientForProducerOnObjectParsed.kt', None, 0, 0), ]) } test_files = [ File( 'MedicalSampleSeriesQuantitySpentPerMedicalClientForProducerOnObjectParsedTest.groovy', None, 0, 0), File('HelloWorldTest.java', None, 0, 0) ] files_controller.match_test_files_to_files_in_tags(tags, test_files) files = tags['TAG_1'].files self.assertEqual(None, files[0].test_file) self.assertEqual( 'MedicalSampleSeriesQuantitySpentPerMedicalClientForProducerOnObjectParsedTest.groovy', files[1].test_file.file_path)
def test_add_tags_to_existing_map__should_not_add_same_file_to_existing_tag( self): # GIVEN existing_tag_key = 'TAG_1' existing_tag = Tag([File('file1.java', None, 0, 0)]) # AND new_tags = {existing_tag_key: existing_tag} existing_tags = { existing_tag_key: Tag([File('file1.java', None, 0, 0)]) } # WHEN files_controller.add_tags_to_existing_map(existing_tags, new_tags) # THEN self.assertEqual(existing_tag, existing_tags.get(existing_tag_key)) self.assertEqual(1, existing_tags.get(existing_tag_key).get_files_count())
def test_add_tags_to_existing_map__should_add_file_to_existing_tag(self): # GIVEN existing_tag_key = 'TAG_1' new_tag_value = Tag([File('new_file1.java', None, 0, 0)]) # AND new_tags = {existing_tag_key: new_tag_value} existing_tags = { existing_tag_key: Tag([ File('file1.java', None, 0, 0), File('file2.java', None, 0, 0), ]) } # WHEN files_controller.add_tags_to_existing_map(existing_tags, new_tags) # THEN self.assertEqual(new_tag_value.files[0], existing_tags.get(existing_tag_key).files[-1]) self.assertEqual(3, existing_tags.get(existing_tag_key).get_files_count())
def test_add_tags_to_existing_map__should_insert_new_tag(self): # GIVEN new_tag_key = 'TAG_3' new_tag_value = Tag([File('new_file1.java', None, 0, 0)]) # AND new_tags = {new_tag_key: new_tag_value} existing_tags = {} # WHEN files_controller.add_tags_to_existing_map(existing_tags, new_tags) # THEN self.assertEqual(new_tag_value, existing_tags.get(new_tag_key))
def put_tags_to_map(tags_map, tags, diff_file): for tag in tags: if tag in tags_map: tags_map[tag].add_file(diff_file) else: tags_map[tag] = Tag([diff_file])
def setUp(self): self.tag = Tag(['SyncManager', 'SyncConfig', 'SyncFactory'])