コード例 #1
0
 def test_request_contents_of_language_directory(
         self, mock_api: MagicMock,
         kata_template_repo: KataTemplateRepo):
     kata_template_repo.get_for_language(KataLanguage('javascript'))
     mock_api.contents.assert_called_with(
         DEFAULT_CONFIG['KataGRepo']['User'],
         DEFAULT_CONFIG['KataGRepo']['Repo'], 'javascript')
コード例 #2
0
ファイル: test_sandbox.py プロジェクト: FlorianKempenich/kata
    def test_kata_template_repo(self):
        repo = KataTemplateRepo()

        assert repo.get_all() == [
            KataTemplate('java', 'junit5'),
            KataTemplate('java', 'some-other'),
            KataTemplate('js', 'jasminesomething'),
            KataTemplate('js', 'maybe-mocha')
        ]
        assert repo.get_for_language('java') == [
            KataTemplate('java', 'junit5'),
            KataTemplate('java', 'some-other')
        ]
コード例 #3
0
ファイル: test_sandbox.py プロジェクト: FlorianKempenich/kata
 def __init__(self):
     self.executor = ThreadPoolExecutor(100)
     self.api = GithubApi()
     self.file_writer = FileWriter()
     self.grepo = GRepo(self.api, self.file_writer, self.executor)
     self.kata_template_repo = HardCoded.KataTemplateRepo()
     self.real_kata_template_repo = KataTemplateRepo(self.api)
     self.sandbox_dir = Path('../sandbox')
     self.init_kata_service = InitKataService(self.kata_template_repo,
                                              self.grepo)
コード例 #4
0
        def test_template_is_not_at_root(self, mock_api: MagicMock,
                                         kata_template_repo: KataTemplateRepo):
            # Given: There are multiple directories at root of the language dir
            mock_api.contents.return_value = [
                mock_dir_entry('java/junit5'),
                mock_dir_entry('java/hamcrest')
            ]

            # When: Fetching the available templates for java
            available_java_templates = kata_template_repo.get_for_language(
                KataLanguage('java'))

            # Then: All available templates are returned
            assert available_java_templates == [
                KataTemplate(KataLanguage('java'), 'junit5'),
                KataTemplate(KataLanguage('java'), 'hamcrest')
            ]
コード例 #5
0
                def test_template_at_root(
                        self, mock_api: MagicMock, config_repo,
                        kata_template_repo: KataTemplateRepo):
                    # Given: 'rust' is explicitly stated as having the template at its root
                    config_repo.config['HasTemplateAtRoot'] = {'rust': True}
                    mock_api.contents.return_value = [
                        mock_file_entry('rust/some_random_file.txt'),
                        mock_dir_entry('rust/some_dir')
                    ]

                    # When: Fetching the available templates for rust
                    rust_available_templates = kata_template_repo.get_for_language(
                        KataLanguage('rust'))

                    # Then: Only one is available and it is the root template (template_name == None)
                    assert rust_available_templates == [
                        KataTemplate(KataLanguage('rust'), template_name=None)
                    ]
コード例 #6
0
                def test_check_if_has_readme(
                        self, mock_api: MagicMock, config_repo,
                        kata_template_repo: KataTemplateRepo):
                    # If there's no information in the config whether this language has its template at root,
                    # try to guess by checking if there's a 'README.md' in the language root dir

                    # Given:
                    # - 'golang' isn't included in the list of languages w/ a template at root
                    # - there's a 'README.md' at 'golang' dir root
                    config_repo.config['HasTemplateAtRoot'] = {}
                    mock_api.contents.return_value = [
                        mock_file_entry('golang/README.md')
                    ]

                    # When: Fetching the available templates for java
                    available_java_templates = kata_template_repo.get_for_language(
                        KataLanguage('golang'))

                    # Then: Only one is available and it is the root template (template_name == None)
                    assert len(available_java_templates) == 1
                    assert available_java_templates[0] == KataTemplate(
                        KataLanguage('golang'), template_name=None)
コード例 #7
0
                def test_template_not_at_root(
                        self, mock_api: MagicMock, config_repo,
                        kata_template_repo: KataTemplateRepo):
                    # Given: 'java' is explicitly stated as not having the template at its root
                    config_repo.config['HasTemplateAtRoot'] = {'java': False}
                    mock_api.contents.return_value = [
                        mock_file_entry('java/some_random_file.txt'),
                        mock_file_entry('java/README.md'),
                        mock_dir_entry('java/template1'),
                        mock_dir_entry('java/template2')
                    ]

                    # When: Fetching the available templates for java
                    java_available_templates = kata_template_repo.get_for_language(
                        KataLanguage('java'))

                    # Then: Only one is available and it is the root template (template_name == None)
                    assert java_available_templates == [
                        KataTemplate(KataLanguage('java'),
                                     template_name='template1'),
                        KataTemplate(KataLanguage('java'),
                                     template_name='template2')
                    ]
コード例 #8
0
 def kata_template_repo(self, mock_api, config_repo):
     return KataTemplateRepo(mock_api, config_repo)
コード例 #9
0
 def init_repos():
     self.kata_template_repo = KataTemplateRepo(self.api,
                                                self.config_repo)
     self.kata_language_repo = KataLanguageRepo(self.api,
                                                self.config_repo)