Exemplo n.º 1
0
    def test_post_record(self):
        topic: FlexioTopic = FlexioTopic()
        topic.title = 'test'
        topic.body = 'dudu'
        topic.state = IssueState.OPEN

        print(topic.to_api_dict())

        r: Response = FlexioClient(
            self.config_handler).post_record(record=topic)

        topic_created: FlexioTopic = FlexioTopic.build_from_api(r.json())
        self.assertEqual(topic.title, topic_created.title)
        self.assertEqual(topic.body, topic_created.body)
        self.assertEqual(topic.state, topic_created.state)

        print(topic_created.__dict__())

        self.assertIs(r.status_code, 200)
        falsy_config_handler = ConfigHandler(CONFIG_DIR)
        falsy_config_handler.config = Config().with_flexio(
            ConfigFlexio(activate=True, user_token='dudu'))
        r: Response = FlexioClient(falsy_config_handler).post_record(
            record=topic)
        self.assertIsNot(r.status_code, 200)
Exemplo n.º 2
0
    def test_get_users(self):
        r: Response = self.github_repo.get_users()
        self.assertIs(r.status_code, 200)
        print(r.json())

        falsy_config_handler = ConfigHandler(CONFIG_DIR)
        falsy_config_handler.config = Config().with_github(
            ConfigGithub(activate=True, user='******', token='dudu'))
        r: Response = Github(falsy_config_handler).get_user()
        self.assertIsNot(r.status_code, 200)
Exemplo n.º 3
0
    def load_file_config(self) -> ConfigHandler:
        if not self.file_path().is_file():
            raise FileNotFoundError(
                self.file_path(),
                'Flexio Flow Core not initialized try : flexio-flow core config'
            )
        f: fileinput = self.file_path().open('r')
        # TODO: ensure 3.8 compatibility
        data: dict = yaml.load(f, Loader=yaml.FullLoader)
        # data: dict = yaml.load(f)
        f.close()

        self.__config = Config().with_github(
            github=ConfigGithub(
                activate=data.get('github', {}).get('activate', False),
                user=data.get('github', {}).get('user', ''),
                token=data.get('github', {}).get('token', '')
            )
        ).with_flexio(flexio=ConfigFlexio(
            activate=data.get('flexio', {}).get('activate', False),
            user_token=data.get('flexio', {}).get('user_token', '')
        )).with_branches_config(branches_config=BranchesConfig.from_dict(data.get('branches', {})))
        return self
Exemplo n.º 4
0
 def setup_config_handler(cls) -> ConfigHandler:
     config_handler: ConfigHandler = ConfigHandler(cls.DIR_PATH_TEST)
     config_handler.config = Config().with_github(
         github=ConfigGithub(activate=True, user=USER, token=TOKEN_TEST))
     return config_handler
Exemplo n.º 5
0
 def setUp(self):
     self.config_handler = ConfigHandler(CONFIG_DIR)
     self.config_handler.config = Config().with_flexio(
         ConfigFlexio(activate=True, user_token=USER_TOKEN))
Exemplo n.º 6
0
 def reset_config(self) -> ConfigHandler:
     self.__config = Config()
     return self
Exemplo n.º 7
0
 def setUp(self):
     self.config_handler = ConfigHandler(CONFIG_DIR)
     self.config_handler.config = Config().with_github(
         ConfigGithub(activate=True, user=USER, token=TOKEN_TEST))
     self.github_repo: Github = Github(self.config_handler).with_repo(
         Repo(owner='flexiooss', repo='flexio-flow-punching-ball'))