def test_should_read_dependency_with_snapshot_as_version(self): rawDependency = """dummy-snapshot = 1.30-SNAPSHOT20100819155634""" dep = Dependency(True) dep.add(rawDependency) result = repr(dep) self.assertEqual("dummy-snapshot = 1.30-SNAPSHOT20100819155634", result)
def test_should_multiple_completly_equal_dependencies_get_always_overwritten_but_differing_version_spec_count_as_not_equal(self): rawDependency = "httpd httpd httpd a b httpd a httpd > 4" dep = Dependency(accumulate_dependencies=True) dep.add(rawDependency) result = str(dep) self.assertEqual(result.count("a"), 1, msg="Don't have the right amount of 'a' <" + result + ">") self.assertEqual(result.count("b"), 1, msg="Don't have the right amount of 'b' <" + result + ">") self.assertEqual(result.count("httpd"), 2, msg="Don't have the right amount of 'httpd' <" + result + ">")
def test_should_read_dependency_with_snapshot_as_version_mixed_with_digits_only_collapse( self): rawDependency = "a= 12 dummy-snapshot = 1.30-SNAPSHOT20100819155634 a = 13" dep = Dependency(True) dep.add(rawDependency) result = repr(dep) self.assertEquals( "a = 13, dummy-snapshot = 1.30-SNAPSHOT20100819155634", result)
def test_multipleCompletlyEqualDependenciesGetAlwaysCollapsedButDifferingVersionSpecCountAsNotEqual(self): rawDependency = "httpd httpd httpd a b httpd a httpd > 4" dep = Dependency(False) dep.add(rawDependency) result = repr(dep) self.assertEqual(result.count("a"), 1, msg="Don't have the right amount of 'a' <" + result + ">") self.assertEqual(result.count("b"), 1, msg="Don't have the right amount of 'b' <" + result + ">") self.assertEqual(result.count("httpd"), 2, msg="Don't have the right amount of 'httpd' <" + result + ">")
def test_negative_filter_for_repos(self): rawDependency = "yadt-foo yadt-dev-snapshots-repo yadt-bla yadt-boo-repo" dep = Dependency(False, "^yadt-.*-repo$", False) dep.add(rawDependency) result = repr(dep) self.assertEqual(result.count("yadt-dev-snapshots-repo"), 0, msg="Filter don't work. Found yadt-dev-snaphosts-repo in <" + result + ">") self.assertEqual(result.count("yadt-boo-repo"), 0, msg="Filter don't work. Found yadt-boo-repo in <" + result + ">") self.assertEqual(result.count("yadt-foo"), 1, msg="Filter don't work. Not found yadt-foo <" + result + ">") self.assertEqual(result.count("yadt-bla"), 1, msg="Filter don't work. Not found yadt-bla <" + result + ">")
def test_filter_for_repos(self): rawDependency = "is24-foo is24-dev-snapshots-repo is24-bla is24-boo-repo" dep = Dependency(False, "^is24-.*-repo$") dep.add(rawDependency) result = repr(dep) self.assertEqual(result.count("is24-dev-snapshots-repo"), 1, msg="Don't have is24-dev-snaphosts-repo in <" + result + ">") self.assertEqual(result.count("is24-boo-repo"), 1, msg="Don't have is24-boo-repo in <" + result + ">") self.assertEqual(result.count("is24-foo"), 0, msg="Filter don't work. Found is24-foo <" + result + ">") self.assertEqual(result.count("is24-bla"), 0, msg="Filter don't work. Found is24-bla <" + result + ">")
def test_should_negative_filter_for_repos(self): rawDependency = "yadt-foo yadt-dev-snapshots-repo yadt-bla yadt-boo-repo" dep = Dependency(accumulate_dependencies=False, filter_regex="^yadt-.*-repo$", positive_filter=False) dep.add(rawDependency) result = str(dep) self.assertEqual(result.count("yadt-dev-snapshots-repo"), 0, msg="Filter don't work. Found yadt-dev-snaphosts-repo in <" + result + ">") self.assertEqual(result.count("yadt-boo-repo"), 0, msg="Filter don't work. Found yadt-boo-repo in <" + result + ">") self.assertEqual(result.count("yadt-foo"), 1, msg="Filter don't work. Not found yadt-foo <" + result + ">") self.assertEqual(result.count("yadt-bla"), 1, msg="Filter don't work. Not found yadt-bla <" + result + ">")
def test_should_remove_duplicates(self): rawDependency = "httpd httpd>42 httpd" dep = Dependency(accumulate_dependencies=True) dep.add(rawDependency) result = str(dep) # Duplicate "httpd" must have been removed. Since set() is used to remove # duplices, we cannot rely on the exact order. one = "httpd, httpd > 42" two = "httpd > 42, httpd" self.assertTrue(result in (one, two))
def _write_dependency_file(self, dependencies, file_path, collapse_duplicates=False, filter_regex='.*', positive_filter=True): dep = Dependency(collapse_dependencies=collapse_duplicates, filter_regex=filter_regex, positive_filter=positive_filter) dep.add(dependencies) self._write_file(file_path, dep.__repr__())
def test_should_multiple_completly_equal_dependencies_get_always_collapsed_but_differing_version_spec_count_as_not_equal( self): rawDependency = "httpd httpd httpd a b httpd a httpd > 4" dep = Dependency(False) dep.add(rawDependency) result = repr(dep) self.assertEqual(result.count("a"), 1, msg="Don't have the right amount of 'a' <" + result + ">") self.assertEqual(result.count("b"), 1, msg="Don't have the right amount of 'b' <" + result + ">") self.assertEqual(result.count("httpd"), 2, msg="Don't have the right amount of 'httpd' <" + result + ">")
def test_should_filter_for_repos(self): rawDependency = "yadt-foo yadt-dev-snapshots-repo yadt-bla yadt-boo-repo" dep = Dependency(False, "^yadt-.*-repo$") dep.add(rawDependency) result = repr(dep) self.assertEqual(result.count("yadt-dev-snapshots-repo"), 1, msg="Don't have yadt-dev-snaphosts-repo in <" + result + ">") self.assertEqual(result.count("yadt-boo-repo"), 1, msg="Don't have yadt-boo-repo in <" + result + ">") self.assertEqual(result.count("yadt-foo"), 0, msg="Filter don't work. Found yadt-foo <" + result + ">") self.assertEqual(result.count("yadt-bla"), 0, msg="Filter don't work. Found yadt-bla <" + result + ">")
def _write_dependency_file(self, dependencies, file_path, collapse_duplicates = False, filter_regex='.*', positive_filter=True): dep = Dependency(collapseDependencies=collapse_duplicates, filterRegex=filter_regex, positiveFilter=positive_filter) dep.add(dependencies) self._write_file(file_path, dep.__repr__())
def __readDependencies(self, rawDependencies, collapseDuplicates): dep = Dependency(collapseDuplicates) dep.add(rawDependencies) return repr(dep)
def test_readDependencyWithSnapshotAsVersionMixedWithDigitsOnlyCollapse(self): rawDependency = "a= 12 dummy-snapshot = 1.30-SNAPSHOT20100819155634 a = 13" dep = Dependency(True) dep.add(rawDependency) result = repr(dep) self.assertEquals("a = 13, dummy-snapshot = 1.30-SNAPSHOT20100819155634", result)
def test_should_read_dependency_with_snapshot_as_version(self): rawDependency = """dummy-snapshot = 1.30-SNAPSHOT20100819155634""" dep = Dependency(accumulate_dependencies=False) dep.add(rawDependency) result = str(dep) self.assertEqual("dummy-snapshot = 1.30-SNAPSHOT20100819155634", result)
def test_should_read_dependency_with_snapshot_as_version_mixed_with_digits_only_overwrite(self): rawDependency = "a= 12 dummy-snapshot = 1.30-SNAPSHOT20100819155634 a = 13" dep = Dependency(accumulate_dependencies=False) dep.add(rawDependency) result = str(dep) self.assertEquals("a = 13, dummy-snapshot = 1.30-SNAPSHOT20100819155634", result)
def test_readDependencyWithSnapshotAsVersion(self): rawDependency = """dummy-snapshot = 1.30-SNAPSHOT20100819155634""" dep = Dependency(True) dep.add(rawDependency) result = repr(dep) self.assertEqual("dummy-snapshot = 1.30-SNAPSHOT20100819155634", result)
def __readDependencies(self, rawDependencies, overwriteDuplicates): dep = Dependency(accumulate_dependencies=overwriteDuplicates) dep.add(rawDependencies) return str(dep)