Exemplo n.º 1
0
 def test_no_image(self, *_):
     markdown = textwrap.dedent("""
         # test
         This section doesn't have an image.
         [link](this/is/not/image)
         """)
     result = copy_markdown_images(self.root, self.file, self.repo,
                                   markdown)
     expected = markdown
     assert result == expected
Exemplo n.º 2
0
    def _git_snippet(self, repository: str, file: str, ref: str,
                     section: str) -> str:
        g = Github(os.getenv("GITHUB_TOKEN"))
        repo = g.get_repo(repository)
        f = repo.get_contents(file, ref=ref)
        content = f.decoded_content.decode("utf-8")
        if section:
            content = get_markdown_section(content, section)

        root = f"{self.config['base_path']}/{self.page.url}"
        content = copy_markdown_images(root, file, repo, content)
        return content
Exemplo n.º 3
0
 def test_url_images(self, *_):
     markdown = textwrap.dedent("""
         # test
         This section has an image.
         ![img_name](http://original/img_path/img.png)
         ## section2
         This section has an image too.
         ![img_name2](https://original2/img_path2/img2.png)
         """)
     result = copy_markdown_images(self.root, self.file, self.repo,
                                   markdown)
     expected = markdown
     assert result == expected
Exemplo n.º 4
0
 def test_single_image(self, *_):
     markdown = textwrap.dedent("""
         # test
         This section has an image.
         ![img_name](original/img_path/img.png)
         """)
     result = copy_markdown_images(self.root, self.file, self.repo,
                                   markdown)
     expected = textwrap.dedent("""
         # test
         This section has an image.
         ![img_name](gen_/local/original/img_path/img.png)
         """)
     assert result == expected