コード例 #1
0
def test_find_file_name_base():
    repository = dummy_repository_plugin()
    repository.tree = [
        AIOGitHubAPIRepositoryTreeContent({
            "path": "test.js",
            "type": "blob"
        }, "test/test", "master")
    ]
    find_file_name(repository)
    assert repository.data.file_name == "test.js"
    assert repository.content.path.remote == ""
コード例 #2
0
ファイル: theme.py プロジェクト: vampirete/integration
    async def update_repository(self, ignore_issues=False):
        """Update."""
        await self.common_update(ignore_issues)

        # Get theme objects.
        if self.data.content_in_root:
            self.content.path.remote = ""

        # Update name
        find_file_name(self)
        self.content.path.local = self.localpath
コード例 #3
0
def test_find_file_name_base_python_script():
    repository = dummy_repository_python_script()
    repository.tree = [
        AIOGitHubAPIRepositoryTreeContent(
            {
                "path": "python_scripts/test.py",
                "type": "blob"
            }, "test/test", "master")
    ]
    find_file_name(repository)
    assert repository.data.file_name == "test.py"
    assert repository.data.name == "test"
コード例 #4
0
def test_find_file_name_base_theme():
    repository = dummy_repository_theme()
    repository.tree = [
        AIOGitHubAPIRepositoryTreeContent(
            {
                "path": "themes/test.yaml",
                "type": "blob"
            }, "test/test", "master")
    ]
    find_file_name(repository)
    assert repository.data.file_name == "test.yaml"
    assert repository.data.name == "test"
コード例 #5
0
def test_find_file_release():
    repository = dummy_repository_plugin()
    repository.releases.objects = [
        AIOGitHubAPIRepositoryRelease({
            "tag_name": "3",
            "assets": [{
                "name": "test.js"
            }]
        })
    ]
    find_file_name(repository)
    assert repository.data.file_name == "test.js"
    assert repository.content.path.remote == "release"
コード例 #6
0
    async def update_repository(self, ignore_issues=False):
        """Update."""
        await self.common_update(ignore_issues)

        # Get plugin objects.
        find_file_name(self)

        if self.content.path.remote is None:
            self.validate.errors.append(
                f"Repostitory structure for {self.ref.replace('tags/','')} is not compliant"
            )

        if self.content.path.remote == "release":
            self.content.single = True
コード例 #7
0
def test_gather_plugin_different_card_name():
    repository = dummy_repository_plugin()
    repository.content.path.remote = ""
    repository.data.file_name = "card.js"
    repository.tree = [
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "card.js", "type": "blob"}, "test/test", "master"
        ),
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "info.md", "type": "blob"}, "test/test", "master"
        ),
    ]
    find_file_name(repository)
    files = [x.path for x in gather_files_to_download(repository)]
    assert "card.js" in files
    assert "info.md" not in files
コード例 #8
0
def test_find_file_release_no_asset():
    repository = dummy_repository_plugin()
    repository.releases.objects = [
        AIOGitHubAPIRepositoryRelease({
            "tag_name": "3",
            "assets": []
        })
    ]
    repository.tree = [
        AIOGitHubAPIRepositoryTreeContent({
            "path": "test.js",
            "type": "blob"
        }, "test/test", "master")
    ]
    find_file_name(repository)
    assert repository.data.file_name == "test.js"
    assert repository.content.path.remote == ""
コード例 #9
0
    async def update_repository(self, ignore_issues=False):
        """Update."""
        await self.common_update(ignore_issues)

        # Get python_script objects.
        if self.data.content_in_root:
            self.content.path.remote = ""

        compliant = False
        for treefile in self.treefiles:
            if treefile.startswith(f"{self.content.path.remote}"
                                   ) and treefile.endswith(".py"):
                compliant = True
                break
        if not compliant:
            raise HacsException(
                f"Repository structure for {self.ref.replace('tags/','')} is not compliant"
            )

        # Update name
        find_file_name(self)
コード例 #10
0
    async def validate_repository(self):
        """Validate."""
        # Run common validation steps.
        await self.common_validate()

        # Custom step 1: Validate content.
        find_file_name(self)

        if self.content.path.remote is None:
            raise HacsException(
                f"Repostitory structure for {self.ref.replace('tags/','')} is not compliant"
            )

        if self.content.path.remote == "release":
            self.content.single = True

        # Handle potential errors
        if self.validate.errors:
            for error in self.validate.errors:
                if not self.hacs.system.status.startup:
                    self.logger.error(error)
        return self.validate.success
コード例 #11
0
def test_gather_plugin_files_from_root():
    repository = dummy_repository_plugin()
    repository.content.path.remote = ""
    repository.tree = [
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "test.js", "type": "blob"}, "test/test", "master"
        ),
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "dir", "type": "tree"}, "test/test", "master"
        ),
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "aaaa.js", "type": "blob"}, "test/test", "master"
        ),
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "dist/test.js", "type": "blob"}, "test/test", "master"
        ),
    ]
    find_file_name(repository)
    files = [x.path for x in gather_files_to_download(repository)]
    assert "test.js" in files
    assert "dir" not in files
    assert "aaaa.js" in files
    assert "dist/test.js" not in files
コード例 #12
0
 async def async_post_registration(self):
     """Registration."""
     # Set name
     find_file_name(self)
コード例 #13
0
ファイル: theme.py プロジェクト: vampirete/integration
 async def async_post_registration(self):
     """Registration."""
     # Set name
     find_file_name(self)
     self.content.path.local = self.localpath