Beispiel #1
0
    def setUp(self):
        self.github_token = os.environ.get("GITHUB_TOKEN")
        self.github_user = os.environ.get("GITHUB_USER")
        self.pagure_token = os.environ.get("PAGURE_TOKEN")
        self.pagure_user = os.environ.get("PAGURE_USER")

        test_name = self.id() or "all"

        persistent_data_file = os.path.join(
            PERSISTENT_DATA_PREFIX, f"test_factory_data_{test_name}.yaml")
        self.persistent_object_storage = PersistentObjectStorage(
            persistent_data_file)

        if self.persistent_object_storage.is_write_mode and (
                not self.github_user or not self.github_token):
            raise EnvironmentError(
                "please set GITHUB_TOKEN GITHUB_USER env variables")

        if self.persistent_object_storage.is_write_mode and (
                not self.pagure_user or not self.pagure_token):
            raise EnvironmentError(
                "please set PAGURE_TOKEN PAGURE_USER env variables")

        self.github_service = GithubService(
            token=self.github_token,
            persistent_storage=self.persistent_object_storage)

        self.pagure_service = PagureMockAPI(
            token=self.pagure_token,
            persistent_storage=self.persistent_object_storage)
Beispiel #2
0
class FactoryTests(unittest.TestCase):
    def setUp(self):
        self.github_token = os.environ.get("GITHUB_TOKEN")
        self.github_user = os.environ.get("GITHUB_USER")
        self.pagure_token = os.environ.get("PAGURE_TOKEN")
        self.pagure_user = os.environ.get("PAGURE_USER")

        test_name = self.id() or "all"

        persistent_data_file = os.path.join(
            PERSISTENT_DATA_PREFIX, f"test_factory_data_{test_name}.yaml")
        self.persistent_object_storage = PersistentObjectStorage(
            persistent_data_file)

        if self.persistent_object_storage.is_write_mode and (
                not self.github_user or not self.github_token):
            raise EnvironmentError(
                "please set GITHUB_TOKEN GITHUB_USER env variables")

        if self.persistent_object_storage.is_write_mode and (
                not self.pagure_user or not self.pagure_token):
            raise EnvironmentError(
                "please set PAGURE_TOKEN PAGURE_USER env variables")

        self.github_service = GithubService(
            token=self.github_token,
            persistent_storage=self.persistent_object_storage)

        self.pagure_service = PagureMockAPI(
            token=self.pagure_token,
            persistent_storage=self.persistent_object_storage)

    def tearDown(self):
        self.persistent_object_storage.dump()

    def test_get_project_github(self):
        project = get_project(
            url="https://github.com/packit-service/ogr",
            custom_instances=[self.github_service, self.pagure_service],
        )
        assert isinstance(project, GithubProject)
        assert project.github_repo

    def test_get_project_pagure(self):
        project = get_project(
            url="https://src.fedoraproject.org/rpms/python-ogr",
            custom_instances=[self.github_service, self.pagure_service],
        )
        assert isinstance(project, PagureProject)
        assert project.exists()
Beispiel #3
0
    def setUp(self):
        self.token = os.environ.get("PAGURE_TOKEN")
        self.user = os.environ.get("PAGURE_USER")
        test_name = self.id() or "all"

        persistent_data_file = os.path.join(
            PERSISTENT_DATA_PREFIX, f"test_pagure_data_{test_name}.yaml"
        )

        persistent_object_storage = PersistentObjectStorage(persistent_data_file)

        if persistent_object_storage.is_write_mode and (
            not self.user or not self.token
        ):
            raise EnvironmentError("please set PAGURE_TOKEN PAGURE_USER env variables")

        self.service = PagureMockAPI(
            token=self.token, persistent_storage=persistent_object_storage
        )
        self.docker_py_project = self.service.get_project(
            namespace="rpms", repo="python-docker", username="******"
        )
        self.abiword_project = self.service.get_project(
            namespace="rpms", repo="abiword", username="******"
        )
        self.abiword_fork = self.service.get_project(
            namespace="rpms", repo="abiword", username="******", is_fork=True
        )
Beispiel #4
0
    def setUp(self):
        self.token = os.environ.get("GITHUB_TOKEN")
        self.user = os.environ.get("GITHUB_USER")
        test_name = self.id() or "all"

        persistent_data_file = os.path.join(
            PERSISTENT_DATA_PREFIX, f"test_github_data_{test_name}.yaml")
        persistent_object_storage = PersistentObjectStorage(
            persistent_data_file)

        if persistent_object_storage.is_write_mode and (not self.user
                                                        or not self.token):
            raise EnvironmentError(
                "please set GITHUB_TOKEN GITHUB_USER env variables")

        self.service = GithubService(
            token=self.token, persistent_storage=persistent_object_storage)
        self.colin_project = self.service.get_project(namespace="user-cont",
                                                      repo="colin")
        self.colin_fork = self.service.get_project(namespace="user-cont",
                                                   repo="colin",
                                                   is_fork=True)

        self.not_forked_project = self.service.get_project(
            namespace="fedora-modularity", repo="fed-to-brew")
Beispiel #5
0
 def setUp(self):
     self.token = os.environ.get("GITHUB_TOKEN")
     self.user = os.environ.get("GITHUB_USER")
     test_name = self.id() or "all"
     self.is_write_mode = bool(os.environ.get("FORCE_WRITE"))
     if self.is_write_mode and (not self.user or not self.token):
         raise EnvironmentError(
             "please set GITHUB_TOKEN GITHUB_USER env variables")
     persistent_data_file = os.path.join(
         PERSISTENT_DATA_PREFIX, f"test_github_data_{test_name}.yaml")
     self.service = GithubService(
         token=self.token,
         persistent_storage=PersistentObjectStorage(persistent_data_file,
                                                    self.is_write_mode),
         read_only=True,
     )
     self.colin_project = self.service.get_project(namespace="user-cont",
                                                   repo="colin")