mirror of https://github.com/sipwise/repoapi.git
* /tracker/mapper/issue/<workfront_id>/ => https://support.../view.php?id=<mantis_id> * /tracker/mapper/task/<workfront_id>/ => https://support.../view.php?id=<mantis_id> Change-Id: I50a1fa3828db442360738a3f2e3adb803bd83907pull/9/head
parent
a67cd83f60
commit
307b549de5
@ -0,0 +1,28 @@
|
||||
- model: tracker.trackermapper
|
||||
pk: 22203
|
||||
fields:
|
||||
mapper_type: MapperType.ISSUE
|
||||
mantis_id: '33066'
|
||||
workfront_id: '1022'
|
||||
workfront_uuid: 577a4dfb004111d28a015ed5a24512a4
|
||||
- model: tracker.trackermapper
|
||||
pk: 22204
|
||||
fields:
|
||||
mapper_type: MapperType.ISSUE
|
||||
mantis_id: '33067'
|
||||
workfront_id: '1409'
|
||||
workfront_uuid: 578361d400272e6da7322db6892afad7
|
||||
- model: tracker.trackermapper
|
||||
pk: 44403
|
||||
fields:
|
||||
mapper_type: MapperType.TASK
|
||||
mantis_id: '55281'
|
||||
workfront_id: '190550'
|
||||
workfront_uuid: 631a44c3003b6b837d569b4f15a2d4dd
|
||||
- model: tracker.trackermapper
|
||||
pk: 44404
|
||||
fields:
|
||||
mapper_type: MapperType.TASK
|
||||
mantis_id: '55282'
|
||||
workfront_id: '190650'
|
||||
workfront_uuid: 631ee19a0283b8913a3ed6e6938bbd6d
|
@ -0,0 +1,42 @@
|
||||
# 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 unittest
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from django.test import SimpleTestCase
|
||||
|
||||
|
||||
class TestTrackerConf(SimpleTestCase):
|
||||
@unittest.expectedFailure
|
||||
def test_django_settings(self):
|
||||
from django.conf import settings
|
||||
|
||||
self.assertIsNotNone(settings.TRACKER_MANTIS_URL)
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_tracker_settings(self):
|
||||
from tracker.conf import settings
|
||||
|
||||
self.assertIsNotNone(settings.TRACKER_MANTIS_URL)
|
||||
|
||||
def test_dynamic(self):
|
||||
from tracker.conf import TrackerConf
|
||||
|
||||
tracker_settings = TrackerConf()
|
||||
parsed = urlparse(tracker_settings.MANTIS_URL)
|
||||
MANTIS_MAPPER_URL = (
|
||||
f"{parsed.scheme}://{parsed.netloc}/view.php?id=" + "{mantis_id}"
|
||||
)
|
||||
self.assertEqual(MANTIS_MAPPER_URL, tracker_settings.MANTIS_MAPPER_URL)
|
@ -0,0 +1,34 @@
|
||||
# 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 repoapi.test.base import BaseTest
|
||||
from tracker.models import TrackerMapper
|
||||
|
||||
|
||||
class TrackerMapperTest(BaseTest):
|
||||
fixtures = ["test_mapper"]
|
||||
ISSUE_id = "1022"
|
||||
ISSUE_uuid = "577a4dfb004111d28a015ed5a24512a4"
|
||||
TASK_id = "190650"
|
||||
TASK_uuid = "631ee19a0283b8913a3ed6e6938bbd6d"
|
||||
|
||||
def test_get_workfront_issue_qs(self):
|
||||
qs_uuid = TrackerMapper.objects.get_workfront_issue_qs(self.ISSUE_uuid)
|
||||
qs_id = TrackerMapper.objects.get_workfront_issue_qs(self.ISSUE_id)
|
||||
self.assertEqual(qs_uuid.count(), 1)
|
||||
self.assertEqual(qs_id.first(), qs_uuid.first())
|
||||
|
||||
def test_get_workfront_issue_qs_ko(self):
|
||||
qs_uuid = TrackerMapper.objects.get_workfront_issue_qs("fake")
|
||||
self.assertEqual(qs_uuid.count(), 0)
|
@ -0,0 +1,78 @@
|
||||
# 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 django.urls import reverse
|
||||
|
||||
from repoapi.test.base import BaseTest
|
||||
from tracker.conf import TrackerConf
|
||||
|
||||
tracker_settings = TrackerConf()
|
||||
|
||||
|
||||
class TrackerMapperTest(BaseTest):
|
||||
fixtures = ["test_mapper"]
|
||||
ISSUE_mantis = "33066"
|
||||
ISSUE_id = "1022"
|
||||
ISSUE_uuid = "577a4dfb004111d28a015ed5a24512a4"
|
||||
TASK_mantis = "55282"
|
||||
TASK_id = "190650"
|
||||
TASK_uuid = "631ee19a0283b8913a3ed6e6938bbd6d"
|
||||
|
||||
def test_issue_uuid(self):
|
||||
res = self.client.get(
|
||||
reverse("tracker:mapper-issues", args=[self.ISSUE_uuid])
|
||||
)
|
||||
self.assertEqual(res.status_code, 301)
|
||||
self.assertEqual(
|
||||
res.url,
|
||||
tracker_settings.MANTIS_MAPPER_URL.format(
|
||||
mantis_id=self.ISSUE_mantis
|
||||
),
|
||||
)
|
||||
|
||||
def test_issue_id(self):
|
||||
res = self.client.get(
|
||||
reverse("tracker:mapper-issues", args=[self.ISSUE_id])
|
||||
)
|
||||
self.assertEqual(res.status_code, 301)
|
||||
self.assertEqual(
|
||||
res.url,
|
||||
tracker_settings.MANTIS_MAPPER_URL.format(
|
||||
mantis_id=self.ISSUE_mantis
|
||||
),
|
||||
)
|
||||
|
||||
def test_task_uuid(self):
|
||||
res = self.client.get(
|
||||
reverse("tracker:mapper-tasks", args=[self.TASK_uuid])
|
||||
)
|
||||
self.assertEqual(res.status_code, 301)
|
||||
self.assertEqual(
|
||||
res.url,
|
||||
tracker_settings.MANTIS_MAPPER_URL.format(
|
||||
mantis_id=self.TASK_mantis
|
||||
),
|
||||
)
|
||||
|
||||
def test_task_id(self):
|
||||
res = self.client.get(
|
||||
reverse("tracker:mapper-tasks", args=[self.TASK_id])
|
||||
)
|
||||
self.assertEqual(res.status_code, 301)
|
||||
self.assertEqual(
|
||||
res.url,
|
||||
tracker_settings.MANTIS_MAPPER_URL.format(
|
||||
mantis_id=self.TASK_mantis
|
||||
),
|
||||
)
|
@ -0,0 +1,31 @@
|
||||
# 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 django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
app_name = "tracker"
|
||||
urlpatterns = [
|
||||
path(
|
||||
"mapper/issue/<str:workfront_id>/",
|
||||
views.WFIssueRedirectView.as_view(),
|
||||
name="mapper-issues",
|
||||
),
|
||||
path(
|
||||
"mapper/task/<str:workfront_id>/",
|
||||
views.WFTaskRedirectView.as_view(),
|
||||
name="mapper-tasks",
|
||||
),
|
||||
]
|
@ -0,0 +1,52 @@
|
||||
# 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 django.shortcuts import get_object_or_404
|
||||
from django.views.generic.base import RedirectView
|
||||
|
||||
from .conf import MapperType
|
||||
from .conf import TrackerConf
|
||||
from .models import TrackerMapper
|
||||
|
||||
tracker_settings = TrackerConf()
|
||||
|
||||
|
||||
class WFIssueRedirectView(RedirectView):
|
||||
permanent = True
|
||||
query_string = True
|
||||
url = tracker_settings.MANTIS_MAPPER_URL
|
||||
|
||||
def get_redirect_url(self, *args, **kwargs):
|
||||
issue = get_object_or_404(
|
||||
TrackerMapper.objects.get_workfront_issue_qs(
|
||||
kwargs["workfront_id"]
|
||||
),
|
||||
mapper_type=MapperType.ISSUE,
|
||||
)
|
||||
return self.url.format(mantis_id=issue.mantis_id)
|
||||
|
||||
|
||||
class WFTaskRedirectView(RedirectView):
|
||||
permanent = True
|
||||
query_string = True
|
||||
url = tracker_settings.MANTIS_MAPPER_URL
|
||||
|
||||
def get_redirect_url(self, *args, **kwargs):
|
||||
issue = get_object_or_404(
|
||||
TrackerMapper.objects.get_workfront_task_qs(
|
||||
kwargs["workfront_id"]
|
||||
),
|
||||
mapper_type=MapperType.TASK,
|
||||
)
|
||||
return self.url.format(mantis_id=issue.mantis_id)
|
Loading…
Reference in new issue