Ejemplo n.º 1
0
def test_gather_plugin_files_from_dist():
    repository = dummy_repository_plugin()
    repository.content.path.remote = "dist"
    repository.data.file_name = "test.js"
    repository.tree = [
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "test.js", "type": "blob"}, "test/test", "master"
        ),
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "dist/image.png", "type": "blob"}, "test/test", "master"
        ),
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "dist/test.js", "type": "blob"}, "test/test", "master"
        ),
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "dist/subdir", "type": "tree"}, "test/test", "master"
        ),
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "dist/subdir/file.file", "type": "blob"}, "test/test", "master"
        ),
    ]
    files = [x.path for x in gather_files_to_download(repository)]
    assert "test.js" not in files
    assert "dist/image.png" in files
    assert "dist/subdir/file.file" in files
    assert "dist/subdir" not in files
    assert "dist/test.js" in files
Ejemplo n.º 2
0
def test_gather_plugin_multiple_files_in_root():
    repository = dummy_repository_plugin()
    repository.content.path.remote = ""
    repository.data.file_name = "test.js"
    repository.tree = [
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "test.js", "type": "blob"}, "test/test", "master"
        ),
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "dep1.js", "type": "blob"}, "test/test", "master"
        ),
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "dep2.js", "type": "blob"}, "test/test", "master"
        ),
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "dep3.js", "type": "blob"}, "test/test", "master"
        ),
        AIOGitHubAPIRepositoryTreeContent(
            {"path": "info.md", "type": "blob"}, "test/test", "master"
        ),
    ]
    files = [x.path for x in gather_files_to_download(repository)]
    assert "test.js" in files
    assert "dep1.js" in files
    assert "dep2.js" in files
    assert "dep3.js" in files
    assert "info.md" not in files
Ejemplo n.º 3
0
def test_gather_plugin_files_from_root():
    repository = dummy_repository_plugin()
    repository.content.path.remote = ""
    repository.tree = [
        AIOGithubTreeContent({
            "path": "test.js",
            "type": "blob"
        }, "test/test", "master"),
        AIOGithubTreeContent({
            "path": "dir",
            "type": "tree"
        }, "test/test", "master"),
        AIOGithubTreeContent({
            "path": "aaaa.js",
            "type": "blob"
        }, "test/test", "master"),
        AIOGithubTreeContent({
            "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
Ejemplo n.º 4
0
def test_gather_plugin_files_from_release():
    repository = dummy_repository_plugin()
    repository.data.file_name = "test.js"
    repository.data.releases = True
    release = AIOGitHubAPIRepositoryRelease(
        {"tag_name": "3", "assets": [{"name": "test.js"}]}
    )
    repository.releases.objects = [release]
    files = [x.name for x in gather_files_to_download(repository)]
    assert "test.js" in files
Ejemplo n.º 5
0
def test_gather_zip_release():
    repository = dummy_repository_plugin()
    repository.data.file_name = "test.zip"
    repository.data.zip_release = True
    repository.data.filename = "test.zip"
    repository.releases.objects = [
        AIOGithubRepositoryRelease({"tag_name": "3", "assets": [{"name": "test.zip"}]})
    ]
    files = [x.name for x in gather_files_to_download(repository)]
    assert "test.zip" in files
Ejemplo n.º 6
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 == ""
Ejemplo n.º 7
0
def test_gather_plugin_files_from_release_multiple():
    repository = dummy_repository_plugin()
    repository.data.file_name = "test.js"
    repository.releases.releases = True
    repository.releases.objects = [
        AIOGithubRepositoryRelease(
            {"tag_name": "3", "assets": [{"name": "test.js"}, {"name": "test.png"}]}
        )
    ]
    files = [x.name for x in gather_files_to_download(repository)]
    assert "test.js" in files
    assert "test.png" in files
Ejemplo n.º 8
0
def test_find_file_name_different_name():
    repository = dummy_repository_plugin()
    repository.data.filename = "card.js"
    repository.tree = [
        AIOGithubTreeContent({
            "path": "card.js",
            "type": "blob"
        }, "test/test", "master")
    ]
    find_file_name(repository)
    assert repository.data.file_name == "card.js"
    assert repository.content.path.remote == ""
Ejemplo n.º 9
0
def test_find_file_name_root():
    repository = dummy_repository_plugin()
    repository.data.content_in_root = True
    repository.tree = [
        AIOGithubTreeContent({
            "path": "test.js",
            "type": "blob"
        }, "test/test", "master")
    ]
    find_file_name(repository)
    assert repository.data.file_name == "test.js"
    assert repository.content.path.remote == ""
Ejemplo n.º 10
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"
Ejemplo n.º 11
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
Ejemplo n.º 12
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 == ""
Ejemplo n.º 13
0
def test_gather_plugin_multiple_plugin_files_from_dist():
    repository = dummy_repository_plugin()
    repository.content.path.remote = "dist"
    repository.data.file_name = "test.js"
    repository.tree = [
        AIOGithubTreeContent(
            {"path": "test.js", "type": "blob"}, "test/test", "master"
        ),
        AIOGithubTreeContent(
            {"path": "dist/test.js", "type": "blob"}, "test/test", "master"
        ),
        AIOGithubTreeContent(
            {"path": "dist/something_other.js", "type": "blob"}, "test/test", "master"
        ),
    ]
    files = [x.path for x in gather_files_to_download(repository)]
    assert "test.js" not in files
    assert "dist/test.js" in files
    assert "dist/something_other.js" in files