diff --git a/tests/conftest.py b/tests/conftest.py index b82aa5a..eb7d50f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -118,6 +118,14 @@ def repo_data(): }, "changelog_file": None, }, + "foobar/baz": { + "last_changed": "2018-09-17 15:15:15", + "readme_file": { + "path": "roles/foobar/baz/README.rst", + "content": raw_file("repo_files/roles/foobar/baz/README.rst"), + }, + "changelog_file": None, + }, } return repo, tenants, job_files, role_files diff --git a/tests/scraper/test_integration.py b/tests/scraper/test_integration.py index dc583ef..66f2038 100644 --- a/tests/scraper/test_integration.py +++ b/tests/scraper/test_integration.py @@ -73,6 +73,7 @@ class MockContents: DIR = "dir" def __init__(self, path, type): + self.name = path.split("/")[-1] self.path = path self.type = type @@ -101,9 +102,10 @@ class MockGitHubRepository(GitHubRepository): "zuul.d/jobs.yaml": MOCKED_JOB_CONTENT, "roles": {"docker-run": MockContents("roles/docker-run", MockContents.DIR)}, "roles/docker-run": { + "tasks": MockContents("roles/docker-run/tasks", MockContents.DIR), "README.rst": MockContents( "roles/docker-run/README.rst", MockContents.FILE - ) + ), }, "roles/docker-run/README.rst": MOCKED_ROLE_DESCRIPTION, "roles/ignored": MockContents("not a valid role", MockContents.FILE), @@ -117,25 +119,40 @@ class MockGitHubRepository(GitHubRepository): "bar": MockContents("roles/bar", MockContents.DIR), "foobar": MockContents("roles/foobar", MockContents.DIR), "empty-dir": MockContents("roles/empty-dir", MockContents.DIR), + "foobaz": MockContents("roles/foobaz", MockContents.DIR), }, "roles/foo": { - "README.md": MockContents("roles/foo/README.md", MockContents.FILE) + "defaults": MockContents("roles/foo/defaults", MockContents.DIR), + "README.md": MockContents("roles/foo/README.md", MockContents.FILE), }, "roles/bar": { - "README.txt": MockContents("roles/bar/README.txt", MockContents.FILE) + "library": MockContents("roles/bar/library", MockContents.DIR), + "README.txt": MockContents("roles/bar/README.txt", MockContents.FILE), }, "roles/foobar": { - "README": MockContents("roles/foobar/README", MockContents.FILE) + "handlers": MockContents("roles/foobar/handlers", MockContents.DIR), + "README": MockContents("roles/foobar/README", MockContents.FILE), }, "roles/empty-dir": { + "meta": MockContents("roles/empty-dir/meta", MockContents.DIR), "README.whatever": MockContents( "roles/empty-dir/README.whatever", MockContents.FILE - ) + ), + }, + "roles/foobaz": { + "baz": MockContents("roles/foobaz/baz", MockContents.DIR), + }, + "roles/foobaz/baz": { + "vars": MockContents("roles/foobaz/baz/vars", MockContents.DIR), + "README.rst": MockContents( + "roles/foobaz/baz/README.rst", MockContents.FILE + ), }, "roles/foo/README.md": "# Just some Markdown", "roles/bar/README.txt": "Just some simple text\nwith a line break", "roles/foobar/README": "Simple text in a file without extension", - "roles/empty-dir/REAMDE.whatever": "This file won't be checked out", + "roles/empty-dir/README.whatever": "This file won't be checked out", + "roles/foobaz/baz/README.rst": "Simple readme file from nested role", }, "orga1/repo3": { REPO_ROOT: { @@ -215,19 +232,24 @@ def test_scrape(): "orga1/repo2": ( {}, { - "foo": { + "bar": { "last_changed": "2018-09-17 15:15:15", "readme_file": { - "path": "roles/foo/README.md", - "content": "# Just some Markdown", + "path": "roles/bar/README.txt", + "content": "Just some simple text\nwith a line break", }, "changelog_file": None, }, - "bar": { + "empty-dir": { + "last_changed": "2018-09-17 15:15:15", + "readme_file": None, + "changelog_file": None, + }, + "foo": { "last_changed": "2018-09-17 15:15:15", "readme_file": { - "path": "roles/bar/README.txt", - "content": "Just some simple text\nwith a line break", + "path": "roles/foo/README.md", + "content": "# Just some Markdown", }, "changelog_file": None, }, @@ -239,9 +261,12 @@ def test_scrape(): }, "changelog_file": None, }, - "empty-dir": { + "foobaz/baz": { "last_changed": "2018-09-17 15:15:15", - "readme_file": None, + "readme_file": { + "path": "roles/foobaz/baz/README.rst", + "content": "Simple readme file from nested role", + }, "changelog_file": None, }, }, diff --git a/tests/scraper/test_repo_parser.py b/tests/scraper/test_repo_parser.py index 8434775..baf5201 100644 --- a/tests/scraper/test_repo_parser.py +++ b/tests/scraper/test_repo_parser.py @@ -47,6 +47,7 @@ def test_parse(repo_data): job_5 = jobs[4] role_1 = [r for r in roles if r["role_name"] == "foo"][0] role_2 = [r for r in roles if r["role_name"] == "bar"][0] + role_3 = [r for r in roles if r["role_name"] == "foobar/baz"][0] expected_job_1 = { "job_name": "my-cool-new-job", @@ -215,6 +216,39 @@ def test_parse(repo_data): "last_updated": "2018-09-17 15:15:15", } + expected_role_3 = { + "role_name": "foobar/baz", + "repo": "my/project", + "tenants": ["foo", "bar"], + "description": ( + "Yet another simple description\n\n" + "**Role variables**\n\n" + ".. zuul:rolevar:: my_mandatory_variable\n\n" + " This variable is mandatory.\n" + ), + "description_html": ( + "
Yet another simple description
\n" + "Role variables
\n" + 'This variable is mandatory.
\n" + "