def test_render_sphinx_supported_os(readme_supported_os): expected_platforms = ["linux", "windows"] expected_html = "<p>This works on Linux and Windows!</p>\n" result = render_sphinx(readme_supported_os) assert expected_platforms == result["platforms"] assert expected_html == result["html"]
def test_render_sphinx_python_code(readme_python_code): expected_code = ('<div class="highlight-python notranslate">' '<div class="highlight"><pre><span></span>' '<span class="kn">import</span> <span class="nn">' "this</span>\n</pre></div>\n</div>\n") result = render_sphinx(readme_python_code) assert expected_code == result["html"]
def test_render_sphinx_reusable(readme_reusable): expected_reusable = True expected_html = "<p>This is a reusable role!</p>\n" result = render_sphinx(readme_reusable) assert expected_reusable == result["reusable"] assert expected_html == result["html"]
def parse_job_definitions(self, file_path, job_info): jobs_yaml = yaml.load(job_info["content"], Loader=ZuulSafeLoader) jobs = [] for list_elem in jobs_yaml: job_def = list_elem.pop("job", None) if job_def: job_name = job_def["name"] uuid = hashlib.sha1( str.encode("{}{}".format(self.repo, job_name)) ).hexdigest() # Define basic job data structure job = ZuulJob(meta={"id": uuid}) job.job_name = job_name job.repo = self.repo.name job.tenants = self.tenants["jobs"] job.private = self.repo.private job.scrape_time = self.scrape_time job.line_start = job_def["__line_start__"] job.line_end = job_def["__line_end__"] job.last_updated = last_changed_from_blame_range( job.line_start, job.line_end, job_info["blame"] ) job.url = self.repo.url_for_file( file_path, job.line_start, job.line_end ) if "description" in job_def: job.description = job_def["description"] try: doc = render_sphinx(job.description) job.description_html = doc["html"] job.platforms = doc["platforms"] job.reusable = doc["reusable"] except SphinxBuildError as exc: LOGGER.warning( "Description of job '%s' could not be " "converted to HTML: %s", job_name, exc, ) # If the repo is configured as reusable, all jobs are considered reusable job.reusable = self.is_reusable_repo or bool(job.reusable) # TODO (fschmidt): Look up the tenant.default-parent and # use this one over 'base' if no parent is defined. # If parent is explicitly set to None, we will keep it. job.parent = job_def.get("parent", "base") jobs.append(job) return jobs
def test_render_sphinx_yaml_code(readme_yaml_code): expected_code = ( '<div class="highlight-yaml notranslate"><div class="highlight">' '<pre><span></span><span class="p p-Indicator">-</span>' ' <span class="nt">job</span><span class="p">:</span>\n' ' <span class="nt">name</span><span class="p">:</span>' ' <span class="l l-Scalar l-Scalar-Plain">foo</span>\n' ' <span class="nt">parent</span><span class="p">:</span>' ' <span class="l l-Scalar l-Scalar-Plain">bar</span>\n' ' <span class="nt">playbook</span><span class="p">:</span>' ' <span class="l l-Scalar l-Scalar-Plain">foo-bar.yaml</span>\n' "</pre></div>\n" "</div>\n") result = render_sphinx(readme_yaml_code) assert expected_code == result["html"]
def test_render_sphinx_simple(readme, expected): result = render_sphinx(readme) assert expected == result["html"]