fix wrong module imports src/test that broke tests and wrong merge
This commit is contained in:
parent
782ae4e6c0
commit
cfe7193d8b
|
@ -10,7 +10,7 @@ See https://www.dokuwiki.org/wiki:syntax
|
||||||
|
|
||||||
Just use the main python class. It uses `argparse`:
|
Just use the main python class. It uses `argparse`:
|
||||||
|
|
||||||
```python src/main.py --dir='some_dokuwiki_root_dir'```
|
`python src/main.py --dir='some_dokuwiki_root_dir'`
|
||||||
|
|
||||||
Command line options:
|
Command line options:
|
||||||
|
|
||||||
|
@ -18,6 +18,10 @@ Command line options:
|
||||||
- `--frontmatter_tags=true`, whether to generate tags in the converted Hugo markdown. By default, the tool generates
|
- `--frontmatter_tags=true`, whether to generate tags in the converted Hugo markdown. By default, the tool generates
|
||||||
tags based on the path to the document.
|
tags based on the path to the document.
|
||||||
|
|
||||||
|
##### Running unittests
|
||||||
|
|
||||||
|
`python runtests.py` in root folder. `-m unittest` does not work as imports mess up `src`/`test` subfolder structures.
|
||||||
|
|
||||||
##### Including it into your python project:
|
##### Including it into your python project:
|
||||||
|
|
||||||
Main wiring in `DokuWikiToHugo` - see the tests for an elaborate example.
|
Main wiring in `DokuWikiToHugo` - see the tests for an elaborate example.
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
sys.path.append('src')
|
||||||
|
|
||||||
|
loader = unittest.TestLoader()
|
||||||
|
testSuite = loader.discover('test')
|
||||||
|
testRunner = unittest.TextTestRunner(verbosity=2)
|
||||||
|
testRunner.run(testSuite)
|
|
@ -1,13 +1,8 @@
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
<<<<<<< HEAD
|
from hugo_front_matter import HugoFrontMatter
|
||||||
from hugo_file_config import HugoFileConfig
|
|
||||||
from markdown_converter import MarkdownConverter
|
from markdown_converter import MarkdownConverter
|
||||||
=======
|
|
||||||
from src.hugo_front_matter import HugoFrontMatter
|
|
||||||
from src.markdown_converter import MarkdownConverter
|
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
|
|
||||||
class DokuWikiToHugo:
|
class DokuWikiToHugo:
|
||||||
|
|
|
@ -9,16 +9,17 @@ from src.dokuwiki_to_hugo import DokuWikiToHugo
|
||||||
class TestDokuWikiToHugo(TestCase):
|
class TestDokuWikiToHugo(TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
shutil.rmtree('output')
|
shutil.rmtree('output')
|
||||||
|
pass
|
||||||
|
|
||||||
def test_doku_to_hugo_converts_home_to_index_markdown_files(self):
|
def test_doku_to_hugo_converts_home_to_index_markdown_files(self):
|
||||||
DokuWikiToHugo().doku_to_hugo('subdir')
|
DokuWikiToHugo().doku_to_hugo('test/subdir')
|
||||||
expected = Path("output/subdir/_index.md").read_text()
|
expected = Path("output/test/subdir/_index.md").read_text()
|
||||||
|
|
||||||
self.assertIn('subdir index', expected)
|
self.assertIn('subdir index', expected)
|
||||||
|
|
||||||
def test_convert_whole_dir(self):
|
def test_convert_whole_dir(self):
|
||||||
DokuWikiToHugo().doku_to_hugo('subdir')
|
DokuWikiToHugo().doku_to_hugo('test/subdir')
|
||||||
expected = Path("output/subdir/moar/dokuwiki_header_in_subdir.md").read_text()
|
expected = Path("output/test/subdir/moar/dokuwiki_header_in_subdir.md").read_text()
|
||||||
|
|
||||||
self.assertIn('+++', expected) # header is there, check
|
self.assertIn('+++', expected) # header is there, check
|
||||||
self.assertIn('##### some header', expected) # some conversion done, check
|
self.assertIn('##### some header', expected) # some conversion done, check
|
||||||
|
|
|
@ -10,8 +10,8 @@ class TestHugoFrontMatter(TestCase):
|
||||||
def set_file_timestamp(self):
|
def set_file_timestamp(self):
|
||||||
date = datetime(2014, 10, 10, 12)
|
date = datetime(2014, 10, 10, 12)
|
||||||
u_time = mktime(date.timetuple())
|
u_time = mktime(date.timetuple())
|
||||||
utime('dokuwiki_header_example.txt', (u_time, u_time))
|
utime('test/dokuwiki_header_example.txt', (u_time, u_time))
|
||||||
utime('subdir/moar/dokuwiki_header_in_subdir.txt', (u_time, u_time))
|
utime('test/subdir/moar/dokuwiki_header_in_subdir.txt', (u_time, u_time))
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.set_file_timestamp()
|
self.set_file_timestamp()
|
||||||
|
@ -22,14 +22,16 @@ class TestHugoFrontMatter(TestCase):
|
||||||
title = "dokuwiki_header_in_subdir"
|
title = "dokuwiki_header_in_subdir"
|
||||||
draft = false
|
draft = false
|
||||||
tags = [
|
tags = [
|
||||||
|
"test",
|
||||||
"subdir",
|
"subdir",
|
||||||
"moar",
|
"moar",
|
||||||
"dokuwiki_header_in_subdir"
|
"dokuwiki_header_in_subdir"
|
||||||
]
|
]
|
||||||
|
|
||||||
date = "2014-10-10"
|
date = "2014-10-10"
|
||||||
+++"""
|
+++"""
|
||||||
|
|
||||||
actual_header = self.header.create('subdir/moar/dokuwiki_header_in_subdir.txt')
|
actual_header = self.header.create('test/subdir/moar/dokuwiki_header_in_subdir.txt')
|
||||||
self.assertEqual(expected_header, actual_header)
|
self.assertEqual(expected_header, actual_header)
|
||||||
|
|
||||||
def test_dokuwiki_header_example(self):
|
def test_dokuwiki_header_example(self):
|
||||||
|
@ -37,10 +39,12 @@ date = "2014-10-10"
|
||||||
title = "dokuwiki_header_example"
|
title = "dokuwiki_header_example"
|
||||||
draft = false
|
draft = false
|
||||||
tags = [
|
tags = [
|
||||||
|
"test",
|
||||||
"dokuwiki_header_example"
|
"dokuwiki_header_example"
|
||||||
]
|
]
|
||||||
|
|
||||||
date = "2014-10-10"
|
date = "2014-10-10"
|
||||||
+++"""
|
+++"""
|
||||||
|
|
||||||
actual_header = self.header.create('dokuwiki_header_example.txt')
|
actual_header = self.header.create('test/dokuwiki_header_example.txt')
|
||||||
self.assertEqual(expected_header, actual_header)
|
self.assertEqual(expected_header, actual_header)
|
||||||
|
|
|
@ -7,11 +7,11 @@ from src.markdown_converter import MarkdownConverter
|
||||||
|
|
||||||
class TestMarkdownHeader(TestCase):
|
class TestMarkdownHeader(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.converter = MarkdownConverter("dokuwiki_example.txt")
|
self.converter = MarkdownConverter("test/dokuwiki_example.txt")
|
||||||
|
|
||||||
def test_acceptance_test_case(self):
|
def test_acceptance_test_case(self):
|
||||||
# python 3.5 and up
|
# python 3.5 and up
|
||||||
expected = Path("expected_markdown_output.txt").read_text()
|
expected = Path("test/expected_markdown_output.txt").read_text()
|
||||||
actual = self.converter.convert()
|
actual = self.converter.convert()
|
||||||
|
|
||||||
print(actual)
|
print(actual)
|
||||||
|
|
Loading…
Reference in New Issue