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-21 15:02:02 +02:00
|
|
|
from lib.request import Request
|
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):
|
|
|
|
factory_revisions = DBRevision.all_revisions(self.db, "openSUSE:Factory", "zsh")
|
2022-10-21 15:02:02 +02:00
|
|
|
source_revisions = dict()
|
|
|
|
for rev in sorted(factory_revisions):
|
|
|
|
print(rev, rev.fileshash(self.db))
|
|
|
|
if rev.request_id:
|
|
|
|
req = Request.find(self.db, rev.request_id)
|
|
|
|
print(" ", req)
|
|
|
|
key = f"{req.source_project}/{req.source_package}"
|
|
|
|
if key not in source_revisions:
|
|
|
|
source_revisions[key] = sorted(
|
|
|
|
DBRevision.all_revisions(
|
|
|
|
self.db, req.source_project, req.source_package
|
|
|
|
)
|
|
|
|
)
|
|
|
|
for rev2 in source_revisions.get(key):
|
|
|
|
print(rev2, rev2.fileshash(self.db))
|
2022-10-21 12:08:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|