TT#88250 release_changed: import settings from conf

* import settings from app.conf everywhere

Change-Id: I1bcc659320545f1a12a57245d28f6d50d582f11f
pull/3/head
Victor Seva 5 years ago
parent 72cfecd34c
commit e77012cd42

@ -1,4 +1,4 @@
# Copyright (C) 2017 The Sipwise Team - http://sipwise.com
# Copyright (C) 2017-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
@ -14,12 +14,12 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
import re
from django.conf import settings
from django.test import override_settings
from django.test import SimpleTestCase
from mock import patch
from build import exceptions as err
from build.conf import settings
from build.utils import get_common_release
from build.utils import get_simple_release
from build.utils import ReleaseConfig

@ -1,4 +1,4 @@
# Copyright (C) 2017 The Sipwise Team - http://sipwise.com
# Copyright (C) 2017-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
@ -13,7 +13,6 @@
# 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 django_filters
from django.conf import settings
from django.http import JsonResponse
from django.shortcuts import get_object_or_404
from rest_framework import generics
@ -25,6 +24,7 @@ from rest_framework_api_key.permissions import HasAPIAccess
from . import models
from . import serializers
from . import tasks
from .conf import settings
from repoapi.serializers import JenkinsBuildInfoSerializer as JBISerializer

@ -14,6 +14,18 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
from django.db import models
from .conf import settings # noqa
# This is needed due to:
#
# AppConf classes depend on being imported during startup of the Django
# process. Even though there are multiple modules loaded automatically, only
# the models modules (usually the models.py file of your app) are guaranteed
# to be loaded at startup. Therefore its recommended to put your AppConf
# subclass(es) there, too.
#
# https://django-appconf.readthedocs.io/en/latest/
class ReleaseChanged(models.Model):
VMTYPE_CHOICES = (("CE", "spce"), ("PRO", "sppro"))

@ -1,4 +1,4 @@
# Copyright (C) 2017 The Sipwise Team - http://sipwise.com
# Copyright (C) 2017-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
@ -12,7 +12,6 @@
#
# 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.conf import settings
from django.test import override_settings
from django.urls import reverse
from mock import call
@ -21,6 +20,7 @@ from rest_framework import status
from rest_framework.test import APITestCase
from release_dashboard import models
from release_dashboard.conf import settings
from repoapi.test.base import APIAuthenticatedTestCase

@ -25,7 +25,7 @@ app = Celery("repoapi")
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object("django.conf:settings", namespace="CELERY")
app.config_from_object("repoapi.conf:settings", namespace="CELERY")
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()

@ -1,22 +1,26 @@
# Copyright (C) 2015 The Sipwise Team - http://sipwise.com
# Copyright (C) 2015-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.db.models import signals
from django.conf import settings
from .jbi import JenkinsBuildInfo, jbi_manage
from .gri import GerritRepoInfo, gerrit_repo_manage
from .wni import WorkfrontNoteInfo, workfront_note_manage
from .gri import gerrit_repo_manage
from .gri import GerritRepoInfo # noqa
from .jbi import jbi_manage
from .jbi import JenkinsBuildInfo
from .wni import workfront_note_manage
from .wni import WorkfrontNoteInfo # noqa
from repoapi.conf import settings
post_save = signals.post_save.connect
post_save(jbi_manage, sender=JenkinsBuildInfo)

@ -1,4 +1,4 @@
# Copyright (C) 2015 The Sipwise Team - http://sipwise.com
# Copyright (C) 2015-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
@ -19,10 +19,10 @@ from datetime import datetime
from datetime import timedelta
from urllib.parse import urlparse
from django.conf import settings
from django.db import models
from django.forms.models import model_to_dict
from repoapi.conf import settings
from repoapi.tasks import get_jbi_files
logger = logging.getLogger(__name__)

@ -1,28 +1,29 @@
# Copyright (C) 2015 The Sipwise Team - http://sipwise.com
# Copyright (C) 2015-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 logging
import re
from django.db import models
from django.conf import settings
from repoapi import utils
from release_dashboard.utils.build import is_ngcp_project
from repoapi import utils
from repoapi.conf import settings
logger = logging.getLogger(__name__)
workfront_re = re.compile(r"TT#(\d+)")
workfront_re_branch = re.compile('^mr[0-9]+\.[0-9]+\.[0-9]+$')
workfront_re_branch = re.compile(r"^mr[0-9]+\.[0-9]+\.[0-9]+$")
commit_re = re.compile(r"^(\w{7}) ")
@ -62,8 +63,9 @@ class WorkfrontNoteInfo(models.Model):
def workfront_release_target(instance, wid):
if not is_ngcp_project(instance.projectname):
logger.info("%s not a NGCP project, skip release_target",
instance.projectname)
logger.info(
"%s not a NGCP project, skip release_target", instance.projectname
)
return
branch = instance.param_branch
if workfront_re_branch.search(branch):
@ -82,15 +84,14 @@ def workfront_note_add(instance, message, release_target=False):
if not instance.gerrit_eventtype:
change = WorkfrontNoteInfo.getCommit(instance.git_commit_msg)
url = settings.GITWEB_URL.format(instance.projectname, change)
eventtype = 'git-commit'
eventtype = "git-commit"
else:
change = instance.gerrit_change
url = settings.GERRIT_URL.format(instance.gerrit_change)
eventtype = instance.gerrit_eventtype
note, created = wni.get_or_create(
workfront_id=wid,
gerrit_change=change,
eventtype=eventtype)
workfront_id=wid, gerrit_change=change, eventtype=eventtype
)
if created:
if not utils.workfront_note_send(wid, "%s %s " % (message, url)):
logger.error("remove related WorkfrontNoteInfo")
@ -106,16 +107,19 @@ def workfront_note_manage(sender, **kwargs):
"""
if kwargs["created"]:
instance = kwargs["instance"]
if instance.jobname.endswith("-get-code") and \
instance.result == "SUCCESS":
if instance.result != "SUCCESS":
return
if instance.jobname.endswith("-get-code"):
set_release_target = True
if instance.gerrit_eventtype == 'change-merged':
if instance.gerrit_eventtype == "change-merged":
msg = "%s.git[%s] review merged"
elif instance.gerrit_eventtype == 'patchset-created':
elif instance.gerrit_eventtype == "patchset-created":
msg = "%s.git[%s] review created"
set_release_target = False
else:
msg = "%s.git[%s] commit created"
workfront_note_add(instance, msg % (instance.projectname,
instance.param_branch),
set_release_target)
workfront_note_add(
instance,
msg % (instance.projectname, instance.param_branch),
set_release_target,
)

@ -29,12 +29,12 @@ JBI_BASEDIR = mkdtemp(dir=os.environ.get("RESULTS"))
@override_settings(DEBUG=True, JBI_BASEDIR=JBI_BASEDIR)
class BaseTest(TestCase):
def setUp(self):
from django.conf import settings
from repoapi.conf import settings
mkpath(settings.JBI_BASEDIR, verbose=True)
def tearDown(self):
from django.conf import settings
from repoapi.conf import settings
if os.path.exists(settings.JBI_BASEDIR):
remove_tree(settings.JBI_BASEDIR, verbose=True)

@ -0,0 +1,27 @@
# 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.test import SimpleTestCase
class TestRepoAPIConf(SimpleTestCase):
def test_django_settings(self):
from django.conf import settings
self.assertIsNotNone(settings.RELEASE_CHANGED_JOBS)
def test_repoapi_settings(self):
from repoapi.conf import settings
self.assertIsNotNone(settings.RELEASE_CHANGED_JOBS)
Loading…
Cancel
Save