Add the capability to export the package data as test fixture

This commit is contained in:
Stephan Kulow
2022-10-21 09:48:31 +02:00
parent 87d9fcc131
commit ce3863e1b5
5 changed files with 25546 additions and 6 deletions

21
lib/exporter.py Normal file
View File

@@ -0,0 +1,21 @@
import sys
import yaml
from lib.db import DB
from lib.db_revision import DBRevision
class Exporter:
def __init__(self, package):
self.package = package
def run(self):
db = DB()
cur = db.cursor()
cur.execute("SELECT * from revisions where package=%s", (self.package,))
data = {"revisions": []}
for row in cur.fetchall():
data["revisions"].append(DBRevision(row).as_dict(db))
yaml.dump(data, sys.stdout, default_flow_style=False)