2022-10-21 12:08:18 +02:00
|
|
|
import os
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
from lib.db import DB
|
|
|
|
from lib.db_revision import DBRevision
|
2022-10-22 12:03:21 +02:00
|
|
|
from lib.tree_builder import TreeBuilder
|
2022-10-21 12:08:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TestTreeMethods(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.db = DB(section="test")
|
|
|
|
path = os.path.join(os.path.dirname(__file__), "fixtures/zsh-data.yaml")
|
|
|
|
with open(path, "r") as f:
|
|
|
|
zsh_data = yaml.safe_load(f)
|
|
|
|
for rev in zsh_data["revisions"]:
|
|
|
|
DBRevision.import_fixture_dict(self.db, rev)
|
|
|
|
|
|
|
|
def test_create_tree(self):
|
2022-10-27 13:16:50 +02:00
|
|
|
revisions = TreeBuilder(self.db).build("zsh")
|
|
|
|
|
|
|
|
if False:
|
|
|
|
import sys
|
|
|
|
|
|
|
|
yaml.dump(revisions.as_list(), sys.stdout)
|
|
|
|
path = os.path.join(
|
|
|
|
os.path.dirname(__file__), "fixtures/zsh-expected-tree.yaml"
|
|
|
|
)
|
|
|
|
with open(path, "r") as f:
|
|
|
|
zsh_data = yaml.safe_load(f)
|
|
|
|
self.assertEqual(zsh_data, revisions.as_list())
|
2022-10-21 12:08:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|