mirror of
https://github.com/drewcassidy/yaclog.git
synced 2024-09-01 14:58:58 +00:00
Add tests for log writer
This commit is contained in:
parent
a13fa34c0c
commit
0c11cf9ffc
@ -39,7 +39,7 @@ log_segments = [
|
||||
'[FullVersion] - 1969-07-20 [TAG1] [TAG2]\n-----', # 14
|
||||
'## Long Version Name', # 15
|
||||
|
||||
'[FullVersion]: http://endless.horse\n[id]: http://www.koalastothemax.com'
|
||||
'[fullVersion]: http://endless.horse\n[id]: http://www.koalastothemax.com'
|
||||
]
|
||||
|
||||
log_text = '\n\n'.join(log_segments)
|
||||
|
@ -33,9 +33,41 @@ class TestParser(unittest.TestCase):
|
||||
self.assertEqual(log.versions[i].date, self.log.versions[i].date)
|
||||
self.assertEqual(log.versions[i].tags, self.log.versions[i].tags)
|
||||
|
||||
def test_Entries(self):
|
||||
def test_entries(self):
|
||||
self.assertEqual(log.versions[0].sections, self.log.versions[0].sections)
|
||||
|
||||
|
||||
class TestWriter(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
cls.path = os.path.join(td, 'changelog.md')
|
||||
log.write(cls.path)
|
||||
with open(cls.path) as fd:
|
||||
cls.log_text = fd.read()
|
||||
cls.log_segments = [line for line in cls.log_text.split('\n\n') if line]
|
||||
|
||||
def test_header(self):
|
||||
self.assertEqual(log_segments[0:2], self.log_segments[0:2])
|
||||
|
||||
def test_links(self):
|
||||
self.assertEqual(
|
||||
{'[fullversion]: http://endless.horse', '[id]: http://www.koalastothemax.com'},
|
||||
set(self.log_segments[16:18]))
|
||||
|
||||
def test_versions(self):
|
||||
self.assertEqual('## [Tests]', self.log_segments[2])
|
||||
self.assertEqual('## [FullVersion] - 1969-07-20 [TAG1] [TAG2]', self.log_segments[14])
|
||||
self.assertEqual('## Long Version Name', self.log_segments[15])
|
||||
|
||||
def test_entries(self):
|
||||
self.assertEqual(log_segments[3], self.log_segments[3])
|
||||
self.assertEqual('### Bullet Points', self.log_segments[4])
|
||||
self.assertEqual(log_segments[5], self.log_segments[5])
|
||||
self.assertEqual('### Blocks', self.log_segments[6])
|
||||
self.assertEqual(log_segments[7:14], self.log_segments[7:14])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user