dev
Andrew Cassidy 3 years ago
parent 0c11cf9ffc
commit daaf21ca8d

@ -1,9 +1,8 @@
import unittest
import yaclog.changelog
import os.path
import datetime
import textwrap
import tempfile
import unittest
import yaclog.changelog
from tests.common import log, log_segments, log_text
@ -17,16 +16,20 @@ class TestParser(unittest.TestCase):
fd.write(log_text)
cls.log = yaclog.read(cls.path)
def test_header(self):
self.assertEqual(log.header, self.log.header)
def test_path(self):
"""Test the log's path"""
self.assertEqual(self.path, self.log.path)
def test_header(self):
"""Test the header information at the top of the file"""
self.assertEqual(log.header, self.log.header)
def test_links(self):
"""Test the links at the end of the file"""
self.assertEqual({'fullversion': 'http://endless.horse', **log.links}, self.log.links)
def test_versions(self):
"""Test the version headers"""
for i in range(len(self.log.versions)):
self.assertEqual(log.versions[i].name, self.log.versions[i].name)
self.assertEqual(log.versions[i].link, self.log.versions[i].link)
@ -34,6 +37,7 @@ class TestParser(unittest.TestCase):
self.assertEqual(log.versions[i].tags, self.log.versions[i].tags)
def test_entries(self):
"""Test the change entries"""
self.assertEqual(log.versions[0].sections, self.log.versions[0].sections)
@ -49,19 +53,23 @@ class TestWriter(unittest.TestCase):
cls.log_segments = [line for line in cls.log_text.split('\n\n') if line]
def test_header(self):
"""Test the header information at the top of the file"""
self.assertEqual(log_segments[0:2], self.log_segments[0:2])
def test_links(self):
"""Test the links at the end of the file"""
self.assertEqual(
{'[fullversion]: http://endless.horse', '[id]: http://www.koalastothemax.com'},
set(self.log_segments[16:18]))
def test_versions(self):
"""Test the version headers"""
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):
"""Test the change entries"""
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])

@ -2,7 +2,7 @@ import os
from yaclog.changelog import Changelog
def read(path: os.PathLike):
def read(path):
"""
Create a new Changelog object from the given path
:param path: a path to a markdown changelog file

@ -114,7 +114,7 @@ class VersionEntry:
class Changelog:
def __init__(self, path: os.PathLike = None):
def __init__(self, path=None):
self.path: os.PathLike = path
self.header: str = ''
self.versions: List[VersionEntry] = []

Loading…
Cancel
Save