TT#43813 tests: unify tests

settings.DEBUG doesn't have the proper value defined at settings.dev
use override_settings in BaseTest to fix it and use it on all apps
if necessary

Add a test and mark as expectedFailure to document this

Change-Id: I2017bf695469f4d98db9e5278e43a9e89b5a6be5
changes/56/38756/2
Victor Seva 5 years ago
parent 7647cfcc48
commit 772681bdf6

@ -12,10 +12,10 @@
# #
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
from django.test import TestCase from django.test import SimpleTestCase
class TestBuildConf(TestCase): class TestBuildConf(SimpleTestCase):
def test_django_settings(self): def test_django_settings(self):
from django.conf import settings from django.conf import settings

@ -16,14 +16,13 @@ from unittest.mock import MagicMock
from unittest.mock import patch from unittest.mock import patch
from django.test import override_settings from django.test import override_settings
from django.test import TestCase
from build.models import BuildRelease from build.models import BuildRelease
from repoapi.models import JenkinsBuildInfo from repoapi.models import JenkinsBuildInfo
from repoapi.test.base import BaseTest from repoapi.test.base import BaseTest
@override_settings(DEBUG=True, JBI_ALLOWED_HOSTS=["fake.local"]) @override_settings(JBI_ALLOWED_HOSTS=["fake.local"])
@patch("repoapi.utils.dlfile") @patch("repoapi.utils.dlfile")
class BuildReleaseManagerTestCase(BaseTest): class BuildReleaseManagerTestCase(BaseTest):
fixtures = ["test_models", "test_models_jbi"] fixtures = ["test_models", "test_models_jbi"]
@ -61,8 +60,7 @@ class BuildReleaseManagerTestCase(BaseTest):
) )
@override_settings(DEBUG=True) class BuildReleaseTestCase(BaseTest):
class BuildReleaseTestCase(TestCase):
fixtures = [ fixtures = [
"test_models", "test_models",
] ]
@ -136,8 +134,7 @@ class BuildReleaseTestCase(TestCase):
self.assertListEqual(build.build_deps, build_deps) self.assertListEqual(build.build_deps, build_deps)
@override_settings(DEBUG=True) class BuildReleaseStepsTest(BaseTest):
class BuildReleaseStepsTest(TestCase):
fixtures = [ fixtures = [
"test_models", "test_models",
] ]
@ -300,10 +297,10 @@ class BuildReleaseStepsTest(TestCase):
self.assertIsNone(self.br.next) self.assertIsNone(self.br.next)
@override_settings(DEBUG=True, JBI_ALLOWED_HOSTS=["fake.local"]) @override_settings(JBI_ALLOWED_HOSTS=["fake.local"])
@patch("repoapi.utils.dlfile") @patch("repoapi.utils.dlfile")
@patch("build.models.build_resume") @patch("build.models.build_resume")
class JBIManageTest(TestCase): class JBIManageTest(BaseTest):
fixtures = [ fixtures = [
"test_models", "test_models",
] ]
@ -375,8 +372,7 @@ class JBIManageTest(TestCase):
self.assertEqual(br.triggered_projects, "kamailio") self.assertEqual(br.triggered_projects, "kamailio")
@override_settings(DEBUG=True) class BRManageTest(BaseTest):
class BRManageTest(TestCase):
@patch("build.tasks.trigger_copy_deps") @patch("build.tasks.trigger_copy_deps")
@patch("build.models.build_resume") @patch("build.models.build_resume")
def test_br_manage(self, build_resume, trigger_copy_deps): def test_br_manage(self, build_resume, trigger_copy_deps):
@ -387,8 +383,7 @@ class BRManageTest(TestCase):
) )
@override_settings(DEBUG=True) class BuildReleaseRetriggerTest(BaseTest):
class BuildReleaseRetriggerTest(TestCase):
fixtures = [ fixtures = [
"test_models", "test_models",
] ]

@ -15,14 +15,11 @@
from copy import deepcopy from copy import deepcopy
from unittest.mock import MagicMock from unittest.mock import MagicMock
from django.test import override_settings
from django.test import TestCase
from build.models import BuildRelease from build.models import BuildRelease
from repoapi.test.base import BaseTest
@override_settings(DEBUG=True) class BuildReleaseStepsTest(BaseTest):
class BuildReleaseStepsTest(TestCase):
fixtures = [ fixtures = [
"test_change_build_deps", "test_change_build_deps",
] ]

@ -35,7 +35,7 @@ class APIAuthenticatedTestCase(BaseTest, APITestCase):
self.client.credentials(HTTP_API_KEY=self.app_key.key) self.client.credentials(HTTP_API_KEY=self.app_key.key)
@override_settings(DEBUG=True, JBI_ALLOWED_HOSTS=["fake.local"]) @override_settings(JBI_ALLOWED_HOSTS=["fake.local"])
class TestRest(APIAuthenticatedTestCase): class TestRest(APIAuthenticatedTestCase):
def setUp(self): def setUp(self):
super(TestRest, self).setUp() super(TestRest, self).setUp()
@ -103,7 +103,7 @@ class TestRest(APIAuthenticatedTestCase):
self.assertEqual(len(projects), 75) self.assertEqual(len(projects), 75)
@override_settings(DEBUG=True, JBI_ALLOWED_HOSTS=["fake.local"]) @override_settings(JBI_ALLOWED_HOSTS=["fake.local"])
class TestBuildRest(APIAuthenticatedTestCase): class TestBuildRest(APIAuthenticatedTestCase):
fixtures = [ fixtures = [
"test_models", "test_models",
@ -120,7 +120,7 @@ class TestBuildRest(APIAuthenticatedTestCase):
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
@override_settings(DEBUG=True, JBI_ALLOWED_HOSTS=["fake.local"]) @override_settings(JBI_ALLOWED_HOSTS=["fake.local"])
class TestBuildDeleteRest(APIAuthenticatedTestCase): class TestBuildDeleteRest(APIAuthenticatedTestCase):
fixtures = [ fixtures = [
"test_models", "test_models",
@ -184,7 +184,7 @@ class TestBuildDeleteRest(APIAuthenticatedTestCase):
) )
@override_settings(DEBUG=True, JBI_ALLOWED_HOSTS=["fake.local"]) @override_settings(JBI_ALLOWED_HOSTS=["fake.local"])
class TestBuildPatchRest(APIAuthenticatedTestCase): class TestBuildPatchRest(APIAuthenticatedTestCase):
fixtures = [ fixtures = [
"test_models", "test_models",

@ -16,16 +16,16 @@ from unittest.mock import call
from unittest.mock import patch from unittest.mock import patch
from django.test import override_settings from django.test import override_settings
from django.test import TestCase
from build.models import BuildRelease from build.models import BuildRelease
from repoapi.models import JenkinsBuildInfo from repoapi.models import JenkinsBuildInfo
from repoapi.test.base import BaseTest
@override_settings(DEBUG=True, JBI_ALLOWED_HOSTS=["fake.local"]) @override_settings(JBI_ALLOWED_HOSTS=["fake.local"])
@patch("repoapi.utils.dlfile") @patch("repoapi.utils.dlfile")
@patch("build.tasks.trigger_build") @patch("build.tasks.trigger_build")
class JBIManageTest(TestCase): class JBIManageTest(BaseTest):
fixtures = [ fixtures = [
"test_models", "test_models",
] ]

@ -63,7 +63,6 @@ class CommonReleaseTest(SimpleTestCase):
self.assertIsNone(val) self.assertIsNone(val)
@override_settings(DEBUG=True)
class ReleaseConfigTestCase(SimpleTestCase): class ReleaseConfigTestCase(SimpleTestCase):
build_deps = [ build_deps = [
"data-hal", "data-hal",

@ -12,10 +12,10 @@
# #
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
from django.test import TestCase from django.test import SimpleTestCase
class TestHotfixConf(TestCase): class TestHotfixConf(SimpleTestCase):
def test_django_settings(self): def test_django_settings(self):
from django.conf import settings from django.conf import settings

@ -12,10 +12,10 @@
# #
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
from django.test import TestCase from django.test import SimpleTestCase
class TestPanelConf(TestCase): class TestPanelConf(SimpleTestCase):
def test_django_settings(self): def test_django_settings(self):
from django.conf import settings from django.conf import settings

@ -12,13 +12,12 @@
# #
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this prograproj. If not, see <http://www.gnu.org/licenses/>. # with this prograproj. If not, see <http://www.gnu.org/licenses/>.
from django.test import override_settings
from django.test import TestCase
from django.urls import reverse from django.urls import reverse
from repoapi.test.base import BaseTest
@override_settings(DEBUG=True)
class ReleaseTest(TestCase): class ReleaseTest(BaseTest):
fixtures = ["test_model_queries_uuid"] fixtures = ["test_model_queries_uuid"]
def test_no_release(self): def test_no_release(self):

@ -12,10 +12,10 @@
# #
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
from django.test import TestCase from django.test import SimpleTestCase
class TestReleaseDashboardConf(TestCase): class TestReleaseDashboardConf(SimpleTestCase):
def test_django_settings(self): def test_django_settings(self):
from django.conf import settings from django.conf import settings

@ -1,107 +1,114 @@
# Copyright (C) 2017 The Sipwise Team - http://sipwise.com # Copyright (C) 2017 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it # 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 # 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) # Software Foundation, either version 3 of the License, or (at your option)
# any later version. # any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT # This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details. # more details.
#
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this prograproj. If not, see <http://www.gnu.org/licenses/>. # with this prograproj. If not, see <http://www.gnu.org/licenses/>.
from django.test import TestCase
from release_dashboard.models import Project, DockerImage, DockerTag
import datetime import datetime
diobj = DockerImage.objects from release_dashboard.models import DockerImage
from release_dashboard.models import DockerTag
from release_dashboard.models import Project
from repoapi.test.base import BaseTest
class DockerImageTestCase(TestCase): class DockerImageTestCase(BaseTest):
def setUp(self): def setUp(self):
self.proj = Project.objects.create(name="fake") self.proj = Project.objects.create(name="fake")
def test_create(self): def test_create(self):
image = diobj.create( image = DockerImage.objects.create(
name='fake-jessie', project=self.proj) name="fake-jessie", project=self.proj
self.assertCountEqual(self.proj.dockerimage_set.all(), )
[image, ]) self.assertCountEqual(self.proj.dockerimage_set.all(), [image])
def test_remove_image(self): def test_remove_image(self):
image = diobj.create( image = DockerImage.objects.create(
name='fake-jessie', project=self.proj) name="fake-jessie", project=self.proj
self.assertCountEqual(self.proj.dockerimage_set.all(), )
[image, ]) self.assertCountEqual(self.proj.dockerimage_set.all(), [image])
image.delete() image.delete()
self.assertTrue(Project.objects.filter(name="fake").exists()) self.assertTrue(Project.objects.filter(name="fake").exists())
def test_remove_project(self): def test_remove_project(self):
image = diobj.create( image = DockerImage.objects.create(
name='fake-jessie', project=self.proj) name="fake-jessie", project=self.proj
self.assertCountEqual(self.proj.dockerimage_set.all(), [image, ]) )
self.assertCountEqual(self.proj.dockerimage_set.all(), [image])
self.proj.delete() self.proj.delete()
self.assertFalse(Project.objects.filter(name="fake").exists()) self.assertFalse(Project.objects.filter(name="fake").exists())
self.assertFalse(diobj.filter(name="fake").exists()) self.assertFalse(DockerImage.objects.filter(name="fake").exists())
def test_filter_images(self): def test_filter_images(self):
images = ['fake-jessie', 'other', 'ngcp-fake', 'fake-more'] images = ["fake-jessie", "other", "ngcp-fake", "fake-more"]
images_ok = ['fake-jessie', 'ngcp-fake', 'fake-more'] images_ok = ["fake-jessie", "ngcp-fake", "fake-more"]
self.assertCountEqual( self.assertCountEqual(
self.proj.filter_docker_images(images), images_ok) self.proj.filter_docker_images(images), images_ok
)
def test_image_tags(self): def test_image_tags(self):
image = diobj.create( image = DockerImage.objects.create(
name='fake-jessie', project=self.proj) name="fake-jessie", project=self.proj
)
self.assertCountEqual(image.tags, []) self.assertCountEqual(image.tags, [])
DockerTag.objects.create(name="latest", image=image, manifests="{}")
self.assertCountEqual(image.tags, ["latest"])
DockerTag.objects.create( DockerTag.objects.create(
name='latest', name="mr5.4", image=image, manifests="{}", reference="whatever"
image=image, )
manifests='{}') self.assertCountEqual(image.tags, ["latest", "mr5.4"])
self.assertCountEqual(image.tags, ['latest', ])
DockerTag.objects.create(
name='mr5.4',
image=image,
manifests='{}',
reference='whatever')
self.assertCountEqual(image.tags, ['latest', 'mr5.4'])
class DockerImageTest2Case(TestCase): class DockerImageTest2Case(BaseTest):
fixtures = ['test_model_fixtures', ] fixtures = [
"test_model_fixtures",
]
def setUp(self): def setUp(self):
self.images_with_tags = [ self.images_with_tags = [
diobj.get(name='data-hal-jessie'), DockerImage.objects.get(name="data-hal-jessie"),
diobj.get(name='documentation-jessie'), DockerImage.objects.get(name="documentation-jessie"),
diobj.get(name='ngcp-panel-selenium'), DockerImage.objects.get(name="ngcp-panel-selenium"),
diobj.get(name='ngcp-panel-tests-rest-api-jessie'), DockerImage.objects.get(name="ngcp-panel-tests-rest-api-jessie"),
diobj.get(name='ngcp-panel-tests-selenium-jessie'), DockerImage.objects.get(name="ngcp-panel-tests-selenium-jessie"),
] ]
def test_images_with_tags(self): def test_images_with_tags(self):
self.assertCountEqual( self.assertCountEqual(
diobj.images_with_tags(), DockerImage.objects.images_with_tags(), self.images_with_tags
self.images_with_tags) )
def test_project_images_with_tags(self): def test_project_images_with_tags(self):
self.assertCountEqual( self.assertCountEqual(
diobj.images_with_tags('data-hal'), DockerImage.objects.images_with_tags("data-hal"),
[diobj.get(name='data-hal-jessie'), ]) [DockerImage.objects.get(name="data-hal-jessie")],
)
self.assertCountEqual(
DockerImage.objects.images_with_tags("ngcp-panel"),
[
DockerImage.objects.get(name="ngcp-panel-selenium"),
DockerImage.objects.get(
name="ngcp-panel-tests-rest-api-jessie"
),
DockerImage.objects.get(
name="ngcp-panel-tests-selenium-jessie"
),
],
)
self.assertCountEqual( self.assertCountEqual(
diobj.images_with_tags('ngcp-panel'), DockerImage.objects.images_with_tags("libtcap"), []
[diobj.get(name='ngcp-panel-selenium'), )
diobj.get(name='ngcp-panel-tests-rest-api-jessie'),
diobj.get(name='ngcp-panel-tests-selenium-jessie'), ])
self.assertCountEqual(diobj.images_with_tags('libtcap'), [])
def test_date(self): def test_date(self):
tag = DockerTag.objects.get( tag = DockerTag.objects.get(
name='latest', name="latest", image__name="ngcp-panel-tests-selenium-jessie"
image__name='ngcp-panel-tests-selenium-jessie') )
self.assertEqual( self.assertEqual(tag.date, datetime.datetime(2017, 6, 21, 16, 3, 37))
tag.date,
datetime.datetime(2017, 6, 21, 16, 3, 37))

@ -12,13 +12,13 @@
# #
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this prograproj. If not, see <http://www.gnu.org/licenses/>. # with this prograproj. If not, see <http://www.gnu.org/licenses/>.
from django.test import TestCase from django.test import SimpleTestCase
from mock import patch from mock import patch
from release_dashboard import tasks from release_dashboard import tasks
class TasksBuildTestCase(TestCase): class TasksBuildTestCase(SimpleTestCase):
@patch("release_dashboard.tasks.gerrit_fetch_info") @patch("release_dashboard.tasks.gerrit_fetch_info")
def test_gerrit_fetch_all(self, gfi): def test_gerrit_fetch_all(self, gfi):
result = tasks.gerrit_fetch_all.delay() result = tasks.gerrit_fetch_all.delay()

@ -15,7 +15,6 @@
import uuid import uuid
from django.test import override_settings from django.test import override_settings
from django.test import TestCase
from mock import call from mock import call
from mock import patch from mock import patch
@ -23,6 +22,7 @@ from release_dashboard import tasks
from release_dashboard.models import DockerImage from release_dashboard.models import DockerImage
from release_dashboard.models import DockerTag from release_dashboard.models import DockerTag
from release_dashboard.models import Project from release_dashboard.models import Project
from repoapi.test.base import BaseTest
DOCKER_REST_CATALOG = """ DOCKER_REST_CATALOG = """
{ {
@ -63,9 +63,8 @@ def fake_manifest(url):
return ("{}", uuid.uuid4()) return ("{}", uuid.uuid4())
@override_settings(DOCKER_REGISTRY_URL="{}") @override_settings(DEBUG=False, DOCKER_REGISTRY_URL="{}")
@override_settings(DEBUG=False) class TasksDockerTestCase(BaseTest):
class TasksDockerTestCase(TestCase):
@patch( @patch(
"release_dashboard.utils.docker.get_docker_manifests_info", "release_dashboard.utils.docker.get_docker_manifests_info",
side_effect=fake_manifest, side_effect=fake_manifest,

@ -12,13 +12,12 @@
# #
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this prograproj. If not, see <http://www.gnu.org/licenses/>. # with this prograproj. If not, see <http://www.gnu.org/licenses/>.
from django.test import SimpleTestCase
from django.test import TestCase
from release_dashboard.utils import build from release_dashboard.utils import build
class UtilsBuildTestCase(TestCase): class UtilsBuildTestCase(SimpleTestCase):
def test_is_ngcp_project(self): def test_is_ngcp_project(self):
self.assertFalse(build.is_ngcp_project('fake')) self.assertFalse(build.is_ngcp_project("fake"))
self.assertTrue(build.is_ngcp_project('kamailio')) self.assertTrue(build.is_ngcp_project("kamailio"))

@ -1,22 +1,23 @@
# Copyright (C) 2017 The Sipwise Team - http://sipwise.com # Copyright (C) 2017 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it # 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 # 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) # Software Foundation, either version 3 of the License, or (at your option)
# any later version. # any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT # This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details. # more details.
#
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this prograproj. If not, see <http://www.gnu.org/licenses/>. # with this prograproj. If not, see <http://www.gnu.org/licenses/>.
from django.test import TestCase
from django.test import override_settings from django.test import override_settings
from django.test import SimpleTestCase
from mock import call
from mock import patch
from release_dashboard.utils import docker from release_dashboard.utils import docker
from mock import patch, call
DOCKER_REST_CATALOG = """ DOCKER_REST_CATALOG = """
{ {
@ -29,54 +30,51 @@ DOCKER_REST_CATALOG = """
""" """
DOCKER_REST_FAKE_TAGS = { DOCKER_REST_FAKE_TAGS = {
'fake-jessie': """{ "fake-jessie": """{
"name": "fake-jessie", "name": "fake-jessie",
"tags":[ "tags":[
"I3a899b8945688c2ef3a4be6ba6c4c1d4cbf6d548", "I3a899b8945688c2ef3a4be6ba6c4c1d4cbf6d548",
"latest"] "latest"]
}""", }""",
'other': """{"name": "other", "tags":[]}""", "other": """{"name": "other", "tags":[]}""",
} }
def fake_tag(url): def fake_tag(url):
if url == "fake-jessie/tags/list": if url == "fake-jessie/tags/list":
return DOCKER_REST_FAKE_TAGS['fake-jessie'] return DOCKER_REST_FAKE_TAGS["fake-jessie"]
elif url == "other/tags/list": elif url == "other/tags/list":
return DOCKER_REST_FAKE_TAGS['other'] return DOCKER_REST_FAKE_TAGS["other"]
@override_settings(DOCKER_REGISTRY_URL='{}')
@override_settings(DEBUG=False)
class UtilsDockerTestCase(TestCase):
@patch('release_dashboard.utils.docker.get_docker_info') @override_settings(DEBUG=False, DOCKER_REGISTRY_URL="{}")
class UtilsDockerTestCase(SimpleTestCase):
@patch("release_dashboard.utils.docker.get_docker_info")
def test_get_docker_repositories(self, gdi): def test_get_docker_repositories(self, gdi):
gdi.return_value = DOCKER_REST_CATALOG gdi.return_value = DOCKER_REST_CATALOG
self.assertCountEqual( self.assertCountEqual(
docker.get_docker_repositories(), docker.get_docker_repositories(),
['fake-jessie', ["fake-jessie", "fake-selenium-jessie", "other", "one"],
'fake-selenium-jessie',
'other',
'one']
) )
@patch('release_dashboard.utils.docker.get_docker_info', @patch(
side_effect=fake_tag) "release_dashboard.utils.docker.get_docker_info", side_effect=fake_tag
)
def test_get_docker_tags(self, gdi): def test_get_docker_tags(self, gdi):
self.assertCountEqual( self.assertCountEqual(
docker.get_docker_tags('fake-jessie'), docker.get_docker_tags("fake-jessie"),
["I3a899b8945688c2ef3a4be6ba6c4c1d4cbf6d548", ["I3a899b8945688c2ef3a4be6ba6c4c1d4cbf6d548", "latest"],
"latest"]) )
calls = [ calls = [
call("fake-jessie/tags/list"), call("fake-jessie/tags/list"),
] ]
gdi.assert_has_calls(calls) gdi.assert_has_calls(calls)
@patch('release_dashboard.utils.docker.get_docker_info', @patch(
side_effect=fake_tag) "release_dashboard.utils.docker.get_docker_info", side_effect=fake_tag
)
def test_get_docker_tags_empty(self, gdi): def test_get_docker_tags_empty(self, gdi):
self.assertCountEqual(docker.get_docker_tags('other'), []) self.assertCountEqual(docker.get_docker_tags("other"), [])
calls = [ calls = [
call("other/tags/list"), call("other/tags/list"),
] ]

@ -1,18 +1,17 @@
# Copyright (C) 2020 The Sipwise Team - http://sipwise.com # Copyright (C) 2020 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it # 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 # 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) # Software Foundation, either version 3 of the License, or (at your option)
# any later version. # any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT # This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details. # more details.
#
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this prograproj. If not, see <http://www.gnu.org/licenses/>. # with this prograproj. If not, see <http://www.gnu.org/licenses/>.
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.test import TestCase from django.test import TestCase
from django.urls import reverse from django.urls import reverse

@ -1,34 +1,37 @@
# Copyright (C) 2017 The Sipwise Team - http://sipwise.com # Copyright (C) 2017 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it # 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 # 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) # Software Foundation, either version 3 of the License, or (at your option)
# any later version. # any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT # This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details. # more details.
#
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
import os import os
import shutil import shutil
from tempfile import mkdtemp from tempfile import mkdtemp
from django.test import TestCase, override_settings from django.test import override_settings
from django.conf import settings from django.test import TestCase
JBI_BASEDIR = mkdtemp(dir=settings.RESULTS_DIR)
JBI_BASEDIR = mkdtemp(dir=os.environ.get("RESULTS"))
@override_settings(JBI_BASEDIR=JBI_BASEDIR)
class BaseTest(TestCase):
@override_settings(DEBUG=True, JBI_BASEDIR=JBI_BASEDIR)
class BaseTest(TestCase):
def setUp(self): def setUp(self):
from django.conf import settings
if not os.path.exists(settings.JBI_BASEDIR): if not os.path.exists(settings.JBI_BASEDIR):
os.makedirs(settings.JBI_BASEDIR) os.makedirs(settings.JBI_BASEDIR)
def tearDown(self): def tearDown(self):
from django.conf import settings
if os.path.exists(settings.JBI_BASEDIR): if os.path.exists(settings.JBI_BASEDIR):
shutil.rmtree(settings.JBI_BASEDIR) shutil.rmtree(settings.JBI_BASEDIR)

@ -15,14 +15,12 @@
from datetime import datetime from datetime import datetime
from datetime import timedelta from datetime import timedelta
from django.test import override_settings
from django.utils.dateparse import parse_datetime from django.utils.dateparse import parse_datetime
from repoapi.models import JenkinsBuildInfo from repoapi.models import JenkinsBuildInfo
from repoapi.test.base import BaseTest from repoapi.test.base import BaseTest
@override_settings(DEBUG=True)
class JBIQueriesTestCase(BaseTest): class JBIQueriesTestCase(BaseTest):
fixtures = ["test_model_queries.json"] fixtures = ["test_model_queries.json"]
@ -103,7 +101,6 @@ class JBIQueriesTestCase(BaseTest):
self.assertEqual(JenkinsBuildInfo.objects.count(), 4) self.assertEqual(JenkinsBuildInfo.objects.count(), 4)
@override_settings(DEBUG=True)
class JBIQueriesUUIDTest(BaseTest): class JBIQueriesUUIDTest(BaseTest):
fixtures = ["test_model_queries_uuid.json"] fixtures = ["test_model_queries_uuid.json"]
release = "release-mr8.1" release = "release-mr8.1"

@ -0,0 +1,47 @@
# 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 unittest
from django.test import override_settings
from django.test import SimpleTestCase
class SettingsTest(SimpleTestCase):
def test_debug_from_test(self):
from ..settings.test import DEBUG
self.assertTrue(DEBUG)
@unittest.expectedFailure
def test_debug(self):
from django.conf import settings
self.assertTrue(settings.DEBUG)
@override_settings(DEBUG=False)
def test_debug_override(self):
from django.conf import settings
self.assertFalse(settings.DEBUG)
def test_common_value_from_django(self):
from django.conf import settings
self.assertEqual(settings.LANGUAGE_CODE, "en-us")
def test_common_value(self):
from django.conf import settings
self.assertEqual(settings.JENKINS_TOKEN, "sipwise_jenkins_ci")
Loading…
Cancel
Save