mirror of https://github.com/sipwise/repoapi.git
django-admin command to export all jbi objects related to a BuildRelease This helps developers to import the file afterwards via admin site Change-Id: Id10ef618f18df10d6fdf066a29de40271d685cb3pull/7/head
parent
653f0e629b
commit
7bfdbb0900
@ -0,0 +1,76 @@
|
||||
- {buildnumber: 19, date: '2022-06-02 10:19:28', gerrit_change: '', gerrit_eventtype: '',
|
||||
gerrit_patchset: none_might-be-direct-push, git_commit_msg: 6a88300 Release new
|
||||
version 16.16.1+0~mr10.5.0.0, id: 444, job_url: 'https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-get-code/',
|
||||
jobname: asterisk-voicemail-get-code, param_branch: master, param_distribution: bullseye,
|
||||
param_ppa: '', param_release: release-trunk-weekly, param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf,
|
||||
param_tag: none, projectname: asterisk-voicemail, repo_name: '', result: SUCCESS,
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d}
|
||||
- {buildnumber: 19, date: '2022-06-02 10:19:29', gerrit_change: '', gerrit_eventtype: '',
|
||||
gerrit_patchset: none_might-be-direct-push, git_commit_msg: 6a88300 Release new
|
||||
version 16.16.1+0~mr10.5.0.0, id: 445, job_url: 'https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-manage-docker/',
|
||||
jobname: asterisk-voicemail-manage-docker, param_branch: master, param_distribution: bullseye,
|
||||
param_ppa: $ppa, param_release: release-trunk-weekly, param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf,
|
||||
param_tag: none, projectname: asterisk-voicemail, repo_name: '', result: SUCCESS,
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d}
|
||||
- {buildnumber: 2, date: '2022-06-02 10:19:29', gerrit_change: '', gerrit_eventtype: '',
|
||||
gerrit_patchset: none_might-be-direct-push, git_commit_msg: 6a88300 Release new
|
||||
version 16.16.1+0~mr10.5.0.0, id: 446, job_url: 'https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-debian-check/',
|
||||
jobname: asterisk-voicemail-debian-check, param_branch: master, param_distribution: bullseye,
|
||||
param_ppa: $ppa, param_release: release-trunk-weekly, param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf,
|
||||
param_tag: none, projectname: asterisk-voicemail, repo_name: '', result: SUCCESS,
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d}
|
||||
- {buildnumber: 19, date: '2022-06-02 10:19:35', gerrit_change: '', gerrit_eventtype: '',
|
||||
gerrit_patchset: none_might-be-direct-push, git_commit_msg: 6a88300 Release new
|
||||
version 16.16.1+0~mr10.5.0.0, id: 447, job_url: 'https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-tap-test/',
|
||||
jobname: asterisk-voicemail-tap-test, param_branch: master, param_distribution: bullseye,
|
||||
param_ppa: $ppa, param_release: release-trunk-weekly, param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf,
|
||||
param_tag: none, projectname: asterisk-voicemail, repo_name: '', result: SUCCESS,
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d}
|
||||
- {buildnumber: 19, date: '2022-06-02 10:19:35', gerrit_change: '', gerrit_eventtype: '',
|
||||
gerrit_patchset: none_might-be-direct-push, git_commit_msg: 6a88300 Release new
|
||||
version 16.16.1+0~mr10.5.0.0, id: 448, job_url: 'https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-source-tests/',
|
||||
jobname: asterisk-voicemail-source-tests, param_branch: master, param_distribution: bullseye,
|
||||
param_ppa: $ppa, param_release: release-trunk-weekly, param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf,
|
||||
param_tag: none, projectname: asterisk-voicemail, repo_name: '', result: SUCCESS,
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d}
|
||||
- {buildnumber: 19, date: '2022-06-02 10:19:38', gerrit_change: '', gerrit_eventtype: '',
|
||||
gerrit_patchset: none_might-be-direct-push, git_commit_msg: 6a88300 Release new
|
||||
version 16.16.1+0~mr10.5.0.0, id: 449, job_url: 'https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-source/',
|
||||
jobname: asterisk-voicemail-source, param_branch: master, param_distribution: bullseye,
|
||||
param_ppa: $ppa, param_release: release-trunk-weekly, param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf,
|
||||
param_tag: none, projectname: asterisk-voicemail, repo_name: '', result: SUCCESS,
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d}
|
||||
- {buildnumber: 19, date: '2022-06-02 10:20:07', gerrit_change: '', gerrit_eventtype: '',
|
||||
gerrit_patchset: none_might-be-direct-push, git_commit_msg: 6a88300 Release new
|
||||
version 16.16.1+0~mr10.5.0.0, id: 451, job_url: 'https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-binaries/',
|
||||
jobname: asterisk-voicemail-binaries, param_branch: master, param_distribution: bullseye,
|
||||
param_ppa: $ppa, param_release: release-trunk-weekly, param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf,
|
||||
param_tag: none, projectname: asterisk-voicemail, repo_name: '', result: SUCCESS,
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d}
|
||||
- {buildnumber: 18, date: '2022-06-02 10:20:08', gerrit_change: '', gerrit_eventtype: '',
|
||||
gerrit_patchset: none_might-be-direct-push, git_commit_msg: 6a88300 Release new
|
||||
version 16.16.1+0~mr10.5.0.0, id: 452, job_url: 'https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-repos/',
|
||||
jobname: asterisk-voicemail-repos, param_branch: master, param_distribution: bullseye,
|
||||
param_ppa: $ppa, param_release: release-trunk-weekly, param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf,
|
||||
param_tag: none, projectname: asterisk-voicemail, repo_name: '', result: SUCCESS,
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d}
|
||||
- {buildnumber: 18, date: '2022-06-02 10:20:09', gerrit_change: '', gerrit_eventtype: '',
|
||||
gerrit_patchset: none_might-be-direct-push, git_commit_msg: 6a88300 Release new
|
||||
version 16.16.1+0~mr10.5.0.0, id: 453, job_url: 'https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-docker-ppa/',
|
||||
jobname: asterisk-voicemail-docker-ppa, param_branch: master, param_distribution: bullseye,
|
||||
param_ppa: $ppa, param_release: release-trunk-weekly, param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf,
|
||||
param_tag: none, projectname: asterisk-voicemail, repo_name: '', result: SUCCESS,
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d}
|
||||
- {buildnumber: 18, date: '2022-06-02 10:21:20', gerrit_change: '', gerrit_eventtype: '',
|
||||
gerrit_patchset: none_might-be-direct-push, git_commit_msg: 6a88300 Release new
|
||||
version 16.16.1+0~mr10.5.0.0, id: 466, job_url: 'https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-piuparts/',
|
||||
jobname: asterisk-voicemail-piuparts, param_branch: master, param_distribution: bullseye,
|
||||
param_ppa: $ppa, param_release: release-trunk-weekly, param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf,
|
||||
param_tag: none, projectname: asterisk-voicemail, repo_name: '', result: SUCCESS,
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d}
|
||||
- {buildnumber: 92, date: '2022-06-02 09:57:57', gerrit_change: '', gerrit_eventtype: '',
|
||||
gerrit_patchset: none_might-be-direct-push, git_commit_msg: '', id: 336, job_url: 'https://jenkins-dev.mgm.sipwise.com/job/release-copy-debs-yml/',
|
||||
jobname: release-copy-debs-yml, param_branch: '', param_distribution: '', param_ppa: '',
|
||||
param_release: release-trunk-weekly, param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf,
|
||||
param_tag: '', projectname: release-copy-debs-yml, repo_name: '', result: SUCCESS,
|
||||
tag: e750560b-3cd9-48ff-afa3-3251fbfc7690}
|
@ -0,0 +1,231 @@
|
||||
- model: repoapi.jenkinsbuildinfo
|
||||
pk: 336
|
||||
fields:
|
||||
tag: e750560b-3cd9-48ff-afa3-3251fbfc7690
|
||||
projectname: release-copy-debs-yml
|
||||
jobname: release-copy-debs-yml
|
||||
buildnumber: 92
|
||||
date: 2022-06-02 09:57:57+00:00
|
||||
result: SUCCESS
|
||||
job_url: https://jenkins-dev.mgm.sipwise.com/job/release-copy-debs-yml/
|
||||
gerrit_patchset: none_might-be-direct-push
|
||||
gerrit_change: ''
|
||||
gerrit_eventtype: ''
|
||||
param_tag: ''
|
||||
param_branch: ''
|
||||
param_release: release-trunk-weekly
|
||||
param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf
|
||||
param_distribution: ''
|
||||
param_ppa: ''
|
||||
repo_name: ''
|
||||
git_commit_msg: ''
|
||||
- model: repoapi.jenkinsbuildinfo
|
||||
pk: 444
|
||||
fields:
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d
|
||||
projectname: asterisk-voicemail
|
||||
jobname: asterisk-voicemail-get-code
|
||||
buildnumber: 19
|
||||
date: 2022-06-02 10:19:28+00:00
|
||||
result: SUCCESS
|
||||
job_url: https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-get-code/
|
||||
gerrit_patchset: none_might-be-direct-push
|
||||
gerrit_change: ''
|
||||
gerrit_eventtype: ''
|
||||
param_tag: none
|
||||
param_branch: master
|
||||
param_release: release-trunk-weekly
|
||||
param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf
|
||||
param_distribution: bullseye
|
||||
param_ppa: ''
|
||||
repo_name: ''
|
||||
git_commit_msg: 6a88300 Release new version 16.16.1+0~mr10.5.0.0
|
||||
- model: repoapi.jenkinsbuildinfo
|
||||
pk: 445
|
||||
fields:
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d
|
||||
projectname: asterisk-voicemail
|
||||
jobname: asterisk-voicemail-manage-docker
|
||||
buildnumber: 19
|
||||
date: 2022-06-02 10:19:29+00:00
|
||||
result: SUCCESS
|
||||
job_url: https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-manage-docker/
|
||||
gerrit_patchset: none_might-be-direct-push
|
||||
gerrit_change: ''
|
||||
gerrit_eventtype: ''
|
||||
param_tag: none
|
||||
param_branch: master
|
||||
param_release: release-trunk-weekly
|
||||
param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf
|
||||
param_distribution: bullseye
|
||||
param_ppa: $ppa
|
||||
repo_name: ''
|
||||
git_commit_msg: 6a88300 Release new version 16.16.1+0~mr10.5.0.0
|
||||
- model: repoapi.jenkinsbuildinfo
|
||||
pk: 446
|
||||
fields:
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d
|
||||
projectname: asterisk-voicemail
|
||||
jobname: asterisk-voicemail-debian-check
|
||||
buildnumber: 2
|
||||
date: 2022-06-02 10:19:29+00:00
|
||||
result: SUCCESS
|
||||
job_url: https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-debian-check/
|
||||
gerrit_patchset: none_might-be-direct-push
|
||||
gerrit_change: ''
|
||||
gerrit_eventtype: ''
|
||||
param_tag: none
|
||||
param_branch: master
|
||||
param_release: release-trunk-weekly
|
||||
param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf
|
||||
param_distribution: bullseye
|
||||
param_ppa: $ppa
|
||||
repo_name: ''
|
||||
git_commit_msg: 6a88300 Release new version 16.16.1+0~mr10.5.0.0
|
||||
- model: repoapi.jenkinsbuildinfo
|
||||
pk: 447
|
||||
fields:
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d
|
||||
projectname: asterisk-voicemail
|
||||
jobname: asterisk-voicemail-tap-test
|
||||
buildnumber: 19
|
||||
date: 2022-06-02 10:19:35+00:00
|
||||
result: SUCCESS
|
||||
job_url: https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-tap-test/
|
||||
gerrit_patchset: none_might-be-direct-push
|
||||
gerrit_change: ''
|
||||
gerrit_eventtype: ''
|
||||
param_tag: none
|
||||
param_branch: master
|
||||
param_release: release-trunk-weekly
|
||||
param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf
|
||||
param_distribution: bullseye
|
||||
param_ppa: $ppa
|
||||
repo_name: ''
|
||||
git_commit_msg: 6a88300 Release new version 16.16.1+0~mr10.5.0.0
|
||||
- model: repoapi.jenkinsbuildinfo
|
||||
pk: 448
|
||||
fields:
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d
|
||||
projectname: asterisk-voicemail
|
||||
jobname: asterisk-voicemail-source-tests
|
||||
buildnumber: 19
|
||||
date: 2022-06-02 10:19:35+00:00
|
||||
result: SUCCESS
|
||||
job_url: https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-source-tests/
|
||||
gerrit_patchset: none_might-be-direct-push
|
||||
gerrit_change: ''
|
||||
gerrit_eventtype: ''
|
||||
param_tag: none
|
||||
param_branch: master
|
||||
param_release: release-trunk-weekly
|
||||
param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf
|
||||
param_distribution: bullseye
|
||||
param_ppa: $ppa
|
||||
repo_name: ''
|
||||
git_commit_msg: 6a88300 Release new version 16.16.1+0~mr10.5.0.0
|
||||
- model: repoapi.jenkinsbuildinfo
|
||||
pk: 449
|
||||
fields:
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d
|
||||
projectname: asterisk-voicemail
|
||||
jobname: asterisk-voicemail-source
|
||||
buildnumber: 19
|
||||
date: 2022-06-02 10:19:38+00:00
|
||||
result: SUCCESS
|
||||
job_url: https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-source/
|
||||
gerrit_patchset: none_might-be-direct-push
|
||||
gerrit_change: ''
|
||||
gerrit_eventtype: ''
|
||||
param_tag: none
|
||||
param_branch: master
|
||||
param_release: release-trunk-weekly
|
||||
param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf
|
||||
param_distribution: bullseye
|
||||
param_ppa: $ppa
|
||||
repo_name: ''
|
||||
git_commit_msg: 6a88300 Release new version 16.16.1+0~mr10.5.0.0
|
||||
- model: repoapi.jenkinsbuildinfo
|
||||
pk: 451
|
||||
fields:
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d
|
||||
projectname: asterisk-voicemail
|
||||
jobname: asterisk-voicemail-binaries
|
||||
buildnumber: 19
|
||||
date: 2022-06-02 10:20:07+00:00
|
||||
result: SUCCESS
|
||||
job_url: https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-binaries/
|
||||
gerrit_patchset: none_might-be-direct-push
|
||||
gerrit_change: ''
|
||||
gerrit_eventtype: ''
|
||||
param_tag: none
|
||||
param_branch: master
|
||||
param_release: release-trunk-weekly
|
||||
param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf
|
||||
param_distribution: bullseye
|
||||
param_ppa: $ppa
|
||||
repo_name: ''
|
||||
git_commit_msg: 6a88300 Release new version 16.16.1+0~mr10.5.0.0
|
||||
- model: repoapi.jenkinsbuildinfo
|
||||
pk: 452
|
||||
fields:
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d
|
||||
projectname: asterisk-voicemail
|
||||
jobname: asterisk-voicemail-repos
|
||||
buildnumber: 18
|
||||
date: 2022-06-02 10:20:08+00:00
|
||||
result: SUCCESS
|
||||
job_url: https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-repos/
|
||||
gerrit_patchset: none_might-be-direct-push
|
||||
gerrit_change: ''
|
||||
gerrit_eventtype: ''
|
||||
param_tag: none
|
||||
param_branch: master
|
||||
param_release: release-trunk-weekly
|
||||
param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf
|
||||
param_distribution: bullseye
|
||||
param_ppa: $ppa
|
||||
repo_name: ''
|
||||
git_commit_msg: 6a88300 Release new version 16.16.1+0~mr10.5.0.0
|
||||
- model: repoapi.jenkinsbuildinfo
|
||||
pk: 453
|
||||
fields:
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d
|
||||
projectname: asterisk-voicemail
|
||||
jobname: asterisk-voicemail-docker-ppa
|
||||
buildnumber: 18
|
||||
date: 2022-06-02 10:20:09+00:00
|
||||
result: SUCCESS
|
||||
job_url: https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-docker-ppa/
|
||||
gerrit_patchset: none_might-be-direct-push
|
||||
gerrit_change: ''
|
||||
gerrit_eventtype: ''
|
||||
param_tag: none
|
||||
param_branch: master
|
||||
param_release: release-trunk-weekly
|
||||
param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf
|
||||
param_distribution: bullseye
|
||||
param_ppa: $ppa
|
||||
repo_name: ''
|
||||
git_commit_msg: 6a88300 Release new version 16.16.1+0~mr10.5.0.0
|
||||
- model: repoapi.jenkinsbuildinfo
|
||||
pk: 466
|
||||
fields:
|
||||
tag: 695a834c-fac2-4706-9b73-fc7eab74c12d
|
||||
projectname: asterisk-voicemail
|
||||
jobname: asterisk-voicemail-piuparts
|
||||
buildnumber: 18
|
||||
date: 2022-06-02 10:21:20+00:00
|
||||
result: SUCCESS
|
||||
job_url: https://jenkins-dev.mgm.sipwise.com/job/asterisk-voicemail-piuparts/
|
||||
gerrit_patchset: none_might-be-direct-push
|
||||
gerrit_change: ''
|
||||
gerrit_eventtype: ''
|
||||
param_tag: none
|
||||
param_branch: master
|
||||
param_release: release-trunk-weekly
|
||||
param_release_uuid: 16726366-93fa-4050-91fd-d496bf9acabf
|
||||
param_distribution: bullseye
|
||||
param_ppa: $ppa
|
||||
repo_name: ''
|
||||
git_commit_msg: 6a88300 Release new version 16.16.1+0~mr10.5.0.0
|
@ -0,0 +1,61 @@
|
||||
# Copyright (C) 2022 The Sipwise Team - http://sipwise.com
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the Free
|
||||
# Software Foundation, either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import argparse
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import CommandError
|
||||
|
||||
from repoapi.admin import JenkinsBuildInfoResource
|
||||
|
||||
|
||||
class JenkinsBuildInfoResourceFilter(JenkinsBuildInfoResource):
|
||||
def __init__(self, **kwargs):
|
||||
self.filter = kwargs
|
||||
|
||||
def get_queryset(self):
|
||||
qs = super().get_queryset()
|
||||
return qs.filter(**self.filter)
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "export BuildRelease info"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
"--format", choices=["json", "yaml"], default="yaml"
|
||||
)
|
||||
parser.add_argument("uuid", help="release_uuid")
|
||||
parser.add_argument("file", type=argparse.FileType("w"))
|
||||
|
||||
def handle(self, *args, **options):
|
||||
params = {
|
||||
"param_release_uuid": options["uuid"],
|
||||
}
|
||||
jbi = JenkinsBuildInfoResourceFilter(**params)
|
||||
dataset = jbi.export()
|
||||
exported = len(dataset)
|
||||
if exported <= 0:
|
||||
raise CommandError(
|
||||
"no jbi objects for release_uuid:'{}' found".format(
|
||||
options["uuid"]
|
||||
)
|
||||
)
|
||||
with options["file"] as f:
|
||||
f.write(dataset.export(options["format"]))
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
"Successfully exported %s jbi objects" % exported
|
||||
)
|
||||
)
|
@ -0,0 +1,34 @@
|
||||
# Copyright (C) 2015-2022 The Sipwise Team - http://sipwise.com
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the Free
|
||||
# Software Foundation, either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import filecmp
|
||||
from difflib import unified_diff
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def check_output(output_file, test_file):
|
||||
assert Path(output_file).exists()
|
||||
assert Path(test_file).exists()
|
||||
|
||||
if not filecmp.cmp(output_file, test_file):
|
||||
with open(output_file) as out, open(test_file) as test:
|
||||
diff = unified_diff(
|
||||
out.readlines(),
|
||||
test.readlines(),
|
||||
fromfile=output_file,
|
||||
tofile=test_file,
|
||||
)
|
||||
for line in diff:
|
||||
print(line, end="")
|
||||
assert filecmp.cmp(output_file, test_file)
|
@ -0,0 +1,57 @@
|
||||
# Copyright (C) 2022 The Sipwise Team - http://sipwise.com
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the Free
|
||||
# Software Foundation, either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.core.management.base import CommandError
|
||||
|
||||
from repoapi.conf import settings
|
||||
from repoapi.models import JenkinsBuildInfo
|
||||
from repoapi.test import check_output
|
||||
from repoapi.test.base import BaseTest
|
||||
|
||||
FIXTURES_PATH = settings.BASE_DIR.joinpath("repoapi", "fixtures")
|
||||
|
||||
|
||||
class exportJBITest(BaseTest):
|
||||
fixtures = ["test_commands"]
|
||||
uuid = "16726366-93fa-4050-91fd-d496bf9acabf"
|
||||
|
||||
def setUp(self):
|
||||
self.cmd = [
|
||||
"dumpdata_release",
|
||||
]
|
||||
|
||||
def test_no_params(self):
|
||||
with self.assertRaises(CommandError):
|
||||
call_command(*self.cmd)
|
||||
|
||||
def test_wrong_uuid(self):
|
||||
with self.assertRaises(CommandError):
|
||||
with NamedTemporaryFile() as fp:
|
||||
self.cmd.append("wrong_uuid")
|
||||
self.cmd.append(fp.name)
|
||||
call_command(*self.cmd)
|
||||
|
||||
def test_ok(self):
|
||||
qs = JenkinsBuildInfo.objects.filter(param_release_uuid=self.uuid)
|
||||
self.assertTrue(qs.count() > 0)
|
||||
|
||||
checkfile = FIXTURES_PATH.joinpath("export.yml")
|
||||
with NamedTemporaryFile() as fp:
|
||||
self.cmd.append(self.uuid)
|
||||
self.cmd.append(fp.name)
|
||||
call_command(*self.cmd)
|
||||
check_output(fp.name, f"{checkfile}")
|
Loading…
Reference in new issue