Ejemplo n.º 1
0
    def test_plugin_check_match(self) -> None:
        mock_config(self.config_contents)

        mirror = Mirror(Path("."), Master(url="https://foo.bar.com"))
        mirror.packages_to_sync = {"foo-good": "", "foo-evil": "", "foo-neutral": ""}
        mirror._filter_packages()

        assert list(mirror.packages_to_sync.keys()) == ["foo-good"]
Ejemplo n.º 2
0
    def test_plugin_check_match(self):
        _mock_config(self.config_contents)

        bandersnatch.filter.filter_release_plugins()

        mirror = Mirror(".", Master(url="https://foo.bar.com"))
        mirror.packages_to_sync = {"foo-good": {}, "foo-evil": {}, "foo-neutral": {}}
        mirror._filter_packages()

        assert list(mirror.packages_to_sync.keys()) == ["foo-good"]
Ejemplo n.º 3
0
    def test__filter__nomatch_package(self) -> None:
        mock_config(
            """\
        [blacklist]
        plugins =
            blacklist_project
        packages =
            foo
        """
        )

        mirror = Mirror(Path("."), Master(url="https://foo.bar.com"))
        mirror.packages_to_sync = {"foo2": ""}
        mirror._filter_packages()

        self.assertIn("foo2", mirror.packages_to_sync.keys())
Ejemplo n.º 4
0
    def test__filter__nomatch_package(self):
        with open("test.conf", "w") as testconfig_handle:
            testconfig_handle.write("""\
        [blacklist]
        plugins =
            blacklist_project
        packages =
            foo
        """)
        instance = BandersnatchConfig()
        instance.config_file = "test.conf"
        instance.load_configuration()

        mirror = Mirror(".", Master(url="https://foo.bar.com"))
        mirror.packages_to_sync = {"foo2": {}}
        mirror._filter_packages()

        self.assertIn("foo2", mirror.packages_to_sync.keys())
Ejemplo n.º 5
0
    def test__filter__matches__package(self) -> None:
        mock_config("""\
[mirror]
storage-backend = filesystem

[plugins]
enabled =
    whitelist_project

[whitelist]
packages =
    foo
""")

        mirror = Mirror(Path("."), Master(url="https://foo.bar.com"))
        mirror.packages_to_sync = {"foo": ""}
        mirror._filter_packages()

        self.assertIn("foo", mirror.packages_to_sync.keys())
Ejemplo n.º 6
0
    def test__filter__matches__package(self):
        with open(TEST_CONF, "w") as testconfig_handle:
            testconfig_handle.write("""\
[plugins]
enabled =
    whitelist_project

[whitelist]
packages =
    foo
""")
        instance = BandersnatchConfig()
        instance.config_file = TEST_CONF
        instance.load_configuration()

        mirror = Mirror(".", Master(url="https://foo.bar.com"))
        mirror.packages_to_sync = {"foo": {}}
        mirror._filter_packages()

        self.assertIn("foo", mirror.packages_to_sync.keys())
Ejemplo n.º 7
0
def test_mirror_filter_packages_nomatch_package_with_spec(tmpdir):
    """
    Package lines with a PEP440 spec on them should not be filtered from the
    list of packages.
    """
    test_configuration = """\
[blacklist]
packages =
    example3>2.0.0
"""
    Singleton._instances = {}
    with open("test.conf", "w") as testconfig_handle:
        testconfig_handle.write(test_configuration)
    BandersnatchConfig("test.conf")
    for plugin in filter_project_plugins():
        plugin.initialize_plugin()
    m = Mirror(str(tmpdir), mock.Mock())
    m.packages_to_sync = {"example1": None, "example3": None}
    m._filter_packages()
    assert "example3" in m.packages_to_sync.keys()
Ejemplo n.º 8
0
def test_mirror_filter_packages_match(tmpdir):
    """
    Packages that exist in the blacklist should be removed from the list of
    packages to sync.
    """
    test_configuration = """\
[blacklist]
packages =
    example1
"""
    Singleton._instances = {}
    with open("test.conf", "w") as testconfig_handle:
        testconfig_handle.write(test_configuration)
    BandersnatchConfig("test.conf")
    for plugin in filter_project_plugins():
        plugin.initialize_plugin()
    m = Mirror(str(tmpdir), mock.Mock())
    m.packages_to_sync = {"example1": None, "example2": None}
    m._filter_packages()
    assert "example1" not in m.packages_to_sync.keys()
Ejemplo n.º 9
0
def test_mirror_filter_packages_nomatch_package_with_spec(tmpdir: Path) -> None:
    """
    Package lines with a PEP440 spec on them should not be filtered from the
    list of packages.
    """
    test_configuration = """\
[plugins]
enable =
    blacklist_project
[blacklist]
packages =
    example3>2.0.0
"""
    Singleton._instances = {}
    with open("test.conf", "w") as testconfig_handle:
        testconfig_handle.write(test_configuration)
    BandersnatchConfig("test.conf")
    m = Mirror(tmpdir, mock.Mock())
    m.packages_to_sync = {"example1": "", "example3": ""}
    m._filter_packages()
    assert "example3" in m.packages_to_sync.keys()
Ejemplo n.º 10
0
def test_mirror_filter_packages_match(tmpdir: Path) -> None:
    """
    Packages that exist in the blacklist should be removed from the list of
    packages to sync.
    """
    test_configuration = """\
[plugins]
enabled =
    blacklist_project
[blacklist]
packages =
    example1
"""
    Singleton._instances = {}
    with open("test.conf", "w") as testconfig_handle:
        testconfig_handle.write(test_configuration)
    BandersnatchConfig("test.conf")
    m = Mirror(tmpdir, mock.Mock())
    m.packages_to_sync = {"example1": "", "example2": ""}
    m._filter_packages()
    assert "example1" not in m.packages_to_sync.keys()
Ejemplo n.º 11
0
    def test__filter__nomatch_package(self):
        _mock_config(
            """\
[mirror]
storage-backend = filesystem

[plugins]
enabled =
    whitelist_project

[whitelist]
packages =
    foo
"""
        )

        mirror = Mirror(".", Master(url="https://foo.bar.com"))
        mirror.packages_to_sync = {"foo": {}, "foo2": {}}
        mirror._filter_packages()

        self.assertIn("foo", mirror.packages_to_sync.keys())
        self.assertNotIn("foo2", mirror.packages_to_sync.keys())