mirror of https://github.com/sipwise/repoapi.git
to be able to build mrX.Y as release-mrX.Y-update we need to have a previous build. This tools allows to create a fake build * don't trigger old BuildRelease instance * create_build_release() add fake option Change-Id: I99293a1c41a567d920a086bcaec329defdcf235bpull/3/head
parent
821c4aff49
commit
8dc31922b0
@ -0,0 +1,37 @@
|
|||||||
|
# Copyright (C) 2020 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 uuid
|
||||||
|
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from django.core.management.base import CommandError
|
||||||
|
|
||||||
|
from build.models import BuildRelease
|
||||||
|
from build.models.br import regex_mrXX
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = "generates fake BuildRelease info. Useful just for mrX.Y builds"
|
||||||
|
|
||||||
|
def add_arguments(self, parser):
|
||||||
|
parser.add_argument("version")
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
ver = options["version"]
|
||||||
|
if not regex_mrXX.match(ver):
|
||||||
|
raise CommandError("'{}'' not mrX.Y version".format(ver))
|
||||||
|
release = "release-{}".format(ver)
|
||||||
|
if BuildRelease.objects.release(release).count() > 0:
|
||||||
|
raise CommandError("'{}' has already instances".format(release))
|
||||||
|
BuildRelease.objects.create_build_release(uuid.uuid4(), ver, fake=True)
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.29 on 2020-07-24 14:53
|
||||||
|
import django.utils.timezone
|
||||||
|
from django.db import migrations
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("build", "0003_buildrelease_triggered_projects"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="buildrelease",
|
||||||
|
name="start_date",
|
||||||
|
field=models.DateTimeField(
|
||||||
|
blank=True, default=django.utils.timezone.now, editable=False
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
# Copyright (C) 2020 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 django.core.management import call_command
|
||||||
|
from django.core.management.base import CommandError
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
from build.models import BuildRelease
|
||||||
|
|
||||||
|
|
||||||
|
class createFakeBuildReleaseTest(TestCase):
|
||||||
|
fixtures = ["test_models"]
|
||||||
|
|
||||||
|
def test_mrXXX_ko(self):
|
||||||
|
with self.assertRaises(CommandError):
|
||||||
|
call_command("create_fake_buildrelease", "mr8.1.1")
|
||||||
|
|
||||||
|
def test_mrXX_ko(self):
|
||||||
|
with self.assertRaises(CommandError):
|
||||||
|
call_command("create_fake_buildrelease", "mr8.1")
|
||||||
|
|
||||||
|
def test_mrXX_ok(self):
|
||||||
|
self.assertEqual(
|
||||||
|
BuildRelease.objects.release("release-mr7.5").count(), 0
|
||||||
|
)
|
||||||
|
call_command("create_fake_buildrelease", "mr7.5")
|
||||||
|
qs = BuildRelease.objects.release("release-mr7.5")
|
||||||
|
self.assertEqual(qs.count(), 1)
|
||||||
|
br = qs.first()
|
||||||
|
self.assertTrue(br.done)
|
||||||
Loading…
Reference in new issue