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

View File

@@ -8,6 +8,7 @@ import sys
import osc.core
from lib.exporter import Exporter
from lib.importer import Importer
URL_OBS = "https://api.opensuse.org"
@@ -88,6 +89,11 @@ def main():
action="store_true",
help="Import revisions into database only",
)
parser.add_argument(
"--export",
action="store_true",
help="Export database fields for the given package as JSON",
)
args = parser.parse_args()
@@ -103,6 +109,10 @@ def main():
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
if args.export:
Exporter(args.package).run()
return
if not args.repodir:
args.repodir = pathlib.Path(args.package)
@@ -117,6 +127,7 @@ def main():
importer = Importer(
PROJECTS, args.package, args.repodir, args.search_ancestor, args.rebase_devel
)
if args.db:
importer.import_into_db()
return