2022-10-21 09:48:31 +02:00
|
|
|
import sys
|
|
|
|
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
from lib.db import DB
|
|
|
|
from lib.db_revision import DBRevision
|
|
|
|
|
|
|
|
|
2022-11-02 07:39:04 +01:00
|
|
|
class TestExporter:
|
2022-11-02 07:59:25 +01:00
|
|
|
""" "Helper class to export data from production DB for tests"""
|
|
|
|
|
2022-10-21 09:48:31 +02:00
|
|
|
def __init__(self, package):
|
|
|
|
self.package = package
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
db = DB()
|
2022-10-26 15:49:14 +02:00
|
|
|
with db.cursor() as cur:
|
|
|
|
cur.execute(
|
|
|
|
"SELECT * from revisions where package=%s ORDER BY project,rev",
|
|
|
|
(self.package,),
|
|
|
|
)
|
|
|
|
data = {"revisions": []}
|
|
|
|
for row in cur.fetchall():
|
|
|
|
data["revisions"].append(DBRevision(row).as_dict(db))
|
2022-10-21 09:48:31 +02:00
|
|
|
|
|
|
|
yaml.dump(data, sys.stdout, default_flow_style=False)
|