diff --git a/build/test/test_conf.py b/build/test/test_conf.py
index 5ed3649..4e13cdb 100644
--- a/build/test/test_conf.py
+++ b/build/test/test_conf.py
@@ -12,10 +12,10 @@
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
-from django.test import TestCase
+from django.test import SimpleTestCase
-class TestBuildConf(TestCase):
+class TestBuildConf(SimpleTestCase):
def test_django_settings(self):
from django.conf import settings
diff --git a/build/test/test_models.py b/build/test/test_models.py
index 8f5a274..8de5cdc 100644
--- a/build/test/test_models.py
+++ b/build/test/test_models.py
@@ -16,14 +16,13 @@ from unittest.mock import MagicMock
from unittest.mock import patch
from django.test import override_settings
-from django.test import TestCase
from build.models import BuildRelease
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")
class BuildReleaseManagerTestCase(BaseTest):
fixtures = ["test_models", "test_models_jbi"]
@@ -61,8 +60,7 @@ class BuildReleaseManagerTestCase(BaseTest):
)
-@override_settings(DEBUG=True)
-class BuildReleaseTestCase(TestCase):
+class BuildReleaseTestCase(BaseTest):
fixtures = [
"test_models",
]
@@ -136,8 +134,7 @@ class BuildReleaseTestCase(TestCase):
self.assertListEqual(build.build_deps, build_deps)
-@override_settings(DEBUG=True)
-class BuildReleaseStepsTest(TestCase):
+class BuildReleaseStepsTest(BaseTest):
fixtures = [
"test_models",
]
@@ -300,10 +297,10 @@ class BuildReleaseStepsTest(TestCase):
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("build.models.build_resume")
-class JBIManageTest(TestCase):
+class JBIManageTest(BaseTest):
fixtures = [
"test_models",
]
@@ -375,8 +372,7 @@ class JBIManageTest(TestCase):
self.assertEqual(br.triggered_projects, "kamailio")
-@override_settings(DEBUG=True)
-class BRManageTest(TestCase):
+class BRManageTest(BaseTest):
@patch("build.tasks.trigger_copy_deps")
@patch("build.models.build_resume")
def test_br_manage(self, build_resume, trigger_copy_deps):
@@ -387,8 +383,7 @@ class BRManageTest(TestCase):
)
-@override_settings(DEBUG=True)
-class BuildReleaseRetriggerTest(TestCase):
+class BuildReleaseRetriggerTest(BaseTest):
fixtures = [
"test_models",
]
diff --git a/build/test/test_release.py b/build/test/test_release.py
index b689d80..d949e6d 100644
--- a/build/test/test_release.py
+++ b/build/test/test_release.py
@@ -15,14 +15,11 @@
from copy import deepcopy
from unittest.mock import MagicMock
-from django.test import override_settings
-from django.test import TestCase
-
from build.models import BuildRelease
+from repoapi.test.base import BaseTest
-@override_settings(DEBUG=True)
-class BuildReleaseStepsTest(TestCase):
+class BuildReleaseStepsTest(BaseTest):
fixtures = [
"test_change_build_deps",
]
diff --git a/build/test/test_rest.py b/build/test/test_rest.py
index 57186ce..a68c90a 100644
--- a/build/test/test_rest.py
+++ b/build/test/test_rest.py
@@ -35,7 +35,7 @@ class APIAuthenticatedTestCase(BaseTest, APITestCase):
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):
def setUp(self):
super(TestRest, self).setUp()
@@ -103,7 +103,7 @@ class TestRest(APIAuthenticatedTestCase):
self.assertEqual(len(projects), 75)
-@override_settings(DEBUG=True, JBI_ALLOWED_HOSTS=["fake.local"])
+@override_settings(JBI_ALLOWED_HOSTS=["fake.local"])
class TestBuildRest(APIAuthenticatedTestCase):
fixtures = [
"test_models",
@@ -120,7 +120,7 @@ class TestBuildRest(APIAuthenticatedTestCase):
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):
fixtures = [
"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):
fixtures = [
"test_models",
diff --git a/build/test/test_tasks.py b/build/test/test_tasks.py
index 4c93c62..f1d8174 100644
--- a/build/test/test_tasks.py
+++ b/build/test/test_tasks.py
@@ -16,16 +16,16 @@ from unittest.mock import call
from unittest.mock import patch
from django.test import override_settings
-from django.test import TestCase
from build.models import BuildRelease
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("build.tasks.trigger_build")
-class JBIManageTest(TestCase):
+class JBIManageTest(BaseTest):
fixtures = [
"test_models",
]
diff --git a/build/test/test_utils.py b/build/test/test_utils.py
index 853e9f9..b7afac5 100644
--- a/build/test/test_utils.py
+++ b/build/test/test_utils.py
@@ -63,7 +63,6 @@ class CommonReleaseTest(SimpleTestCase):
self.assertIsNone(val)
-@override_settings(DEBUG=True)
class ReleaseConfigTestCase(SimpleTestCase):
build_deps = [
"data-hal",
diff --git a/hotfix/test/test_conf.py b/hotfix/test/test_conf.py
index 1e01ff7..4fd808b 100644
--- a/hotfix/test/test_conf.py
+++ b/hotfix/test/test_conf.py
@@ -12,10 +12,10 @@
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
-from django.test import TestCase
+from django.test import SimpleTestCase
-class TestHotfixConf(TestCase):
+class TestHotfixConf(SimpleTestCase):
def test_django_settings(self):
from django.conf import settings
diff --git a/panel/test/test_conf.py b/panel/test/test_conf.py
index ca7f828..91383d2 100644
--- a/panel/test/test_conf.py
+++ b/panel/test/test_conf.py
@@ -12,10 +12,10 @@
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
-from django.test import TestCase
+from django.test import SimpleTestCase
-class TestPanelConf(TestCase):
+class TestPanelConf(SimpleTestCase):
def test_django_settings(self):
from django.conf import settings
diff --git a/panel/test/test_views.py b/panel/test/test_views.py
index 02e35d4..a904881 100644
--- a/panel/test/test_views.py
+++ b/panel/test/test_views.py
@@ -12,13 +12,12 @@
#
# You should have received a copy of the GNU General Public License along
# with this prograproj. If not, see .
-from django.test import override_settings
-from django.test import TestCase
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"]
def test_no_release(self):
diff --git a/release_dashboard/test/test_conf.py b/release_dashboard/test/test_conf.py
index f926ac3..3a0b3cd 100644
--- a/release_dashboard/test/test_conf.py
+++ b/release_dashboard/test/test_conf.py
@@ -12,10 +12,10 @@
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
-from django.test import TestCase
+from django.test import SimpleTestCase
-class TestReleaseDashboardConf(TestCase):
+class TestReleaseDashboardConf(SimpleTestCase):
def test_django_settings(self):
from django.conf import settings
diff --git a/release_dashboard/test/test_models_docker.py b/release_dashboard/test/test_models_docker.py
index d6dcf49..6295e0e 100644
--- a/release_dashboard/test/test_models_docker.py
+++ b/release_dashboard/test/test_models_docker.py
@@ -1,107 +1,114 @@
# Copyright (C) 2017 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 prograproj. If not, see .
-
-from django.test import TestCase
-from release_dashboard.models import Project, DockerImage, DockerTag
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):
self.proj = Project.objects.create(name="fake")
def test_create(self):
- image = diobj.create(
- name='fake-jessie', project=self.proj)
- self.assertCountEqual(self.proj.dockerimage_set.all(),
- [image, ])
+ image = DockerImage.objects.create(
+ name="fake-jessie", project=self.proj
+ )
+ self.assertCountEqual(self.proj.dockerimage_set.all(), [image])
def test_remove_image(self):
- image = diobj.create(
- name='fake-jessie', project=self.proj)
- self.assertCountEqual(self.proj.dockerimage_set.all(),
- [image, ])
+ image = DockerImage.objects.create(
+ name="fake-jessie", project=self.proj
+ )
+ self.assertCountEqual(self.proj.dockerimage_set.all(), [image])
image.delete()
self.assertTrue(Project.objects.filter(name="fake").exists())
def test_remove_project(self):
- image = diobj.create(
- name='fake-jessie', project=self.proj)
- self.assertCountEqual(self.proj.dockerimage_set.all(), [image, ])
+ image = DockerImage.objects.create(
+ name="fake-jessie", project=self.proj
+ )
+ self.assertCountEqual(self.proj.dockerimage_set.all(), [image])
self.proj.delete()
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):
- images = ['fake-jessie', 'other', 'ngcp-fake', 'fake-more']
- images_ok = ['fake-jessie', 'ngcp-fake', 'fake-more']
+ images = ["fake-jessie", "other", "ngcp-fake", "fake-more"]
+ images_ok = ["fake-jessie", "ngcp-fake", "fake-more"]
self.assertCountEqual(
- self.proj.filter_docker_images(images), images_ok)
+ self.proj.filter_docker_images(images), images_ok
+ )
def test_image_tags(self):
- image = diobj.create(
- name='fake-jessie', project=self.proj)
+ image = DockerImage.objects.create(
+ name="fake-jessie", project=self.proj
+ )
self.assertCountEqual(image.tags, [])
+ DockerTag.objects.create(name="latest", image=image, manifests="{}")
+ self.assertCountEqual(image.tags, ["latest"])
DockerTag.objects.create(
- name='latest',
- image=image,
- manifests='{}')
- self.assertCountEqual(image.tags, ['latest', ])
- DockerTag.objects.create(
- name='mr5.4',
- image=image,
- manifests='{}',
- reference='whatever')
- self.assertCountEqual(image.tags, ['latest', 'mr5.4'])
+ name="mr5.4", image=image, manifests="{}", reference="whatever"
+ )
+ self.assertCountEqual(image.tags, ["latest", "mr5.4"])
-class DockerImageTest2Case(TestCase):
- fixtures = ['test_model_fixtures', ]
+class DockerImageTest2Case(BaseTest):
+ fixtures = [
+ "test_model_fixtures",
+ ]
def setUp(self):
self.images_with_tags = [
- diobj.get(name='data-hal-jessie'),
- diobj.get(name='documentation-jessie'),
- diobj.get(name='ngcp-panel-selenium'),
- diobj.get(name='ngcp-panel-tests-rest-api-jessie'),
- diobj.get(name='ngcp-panel-tests-selenium-jessie'),
+ DockerImage.objects.get(name="data-hal-jessie"),
+ DockerImage.objects.get(name="documentation-jessie"),
+ 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"),
]
def test_images_with_tags(self):
self.assertCountEqual(
- diobj.images_with_tags(),
- self.images_with_tags)
+ DockerImage.objects.images_with_tags(), self.images_with_tags
+ )
def test_project_images_with_tags(self):
self.assertCountEqual(
- diobj.images_with_tags('data-hal'),
- [diobj.get(name='data-hal-jessie'), ])
+ DockerImage.objects.images_with_tags("data-hal"),
+ [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(
- diobj.images_with_tags('ngcp-panel'),
- [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'), [])
+ DockerImage.objects.images_with_tags("libtcap"), []
+ )
def test_date(self):
tag = DockerTag.objects.get(
- name='latest',
- image__name='ngcp-panel-tests-selenium-jessie')
- self.assertEqual(
- tag.date,
- datetime.datetime(2017, 6, 21, 16, 3, 37))
+ name="latest", image__name="ngcp-panel-tests-selenium-jessie"
+ )
+ self.assertEqual(tag.date, datetime.datetime(2017, 6, 21, 16, 3, 37))
diff --git a/release_dashboard/test/test_tasks_build.py b/release_dashboard/test/test_tasks_build.py
index 5ca063c..5923042 100644
--- a/release_dashboard/test/test_tasks_build.py
+++ b/release_dashboard/test/test_tasks_build.py
@@ -12,13 +12,13 @@
#
# You should have received a copy of the GNU General Public License along
# with this prograproj. If not, see .
-from django.test import TestCase
+from django.test import SimpleTestCase
from mock import patch
from release_dashboard import tasks
-class TasksBuildTestCase(TestCase):
+class TasksBuildTestCase(SimpleTestCase):
@patch("release_dashboard.tasks.gerrit_fetch_info")
def test_gerrit_fetch_all(self, gfi):
result = tasks.gerrit_fetch_all.delay()
diff --git a/release_dashboard/test/test_tasks_docker.py b/release_dashboard/test/test_tasks_docker.py
index e3cf7d8..824fc49 100644
--- a/release_dashboard/test/test_tasks_docker.py
+++ b/release_dashboard/test/test_tasks_docker.py
@@ -15,7 +15,6 @@
import uuid
from django.test import override_settings
-from django.test import TestCase
from mock import call
from mock import patch
@@ -23,6 +22,7 @@ from release_dashboard import tasks
from release_dashboard.models import DockerImage
from release_dashboard.models import DockerTag
from release_dashboard.models import Project
+from repoapi.test.base import BaseTest
DOCKER_REST_CATALOG = """
{
@@ -63,9 +63,8 @@ def fake_manifest(url):
return ("{}", uuid.uuid4())
-@override_settings(DOCKER_REGISTRY_URL="{}")
-@override_settings(DEBUG=False)
-class TasksDockerTestCase(TestCase):
+@override_settings(DEBUG=False, DOCKER_REGISTRY_URL="{}")
+class TasksDockerTestCase(BaseTest):
@patch(
"release_dashboard.utils.docker.get_docker_manifests_info",
side_effect=fake_manifest,
diff --git a/release_dashboard/test/test_utils_build.py b/release_dashboard/test/test_utils_build.py
index 6532942..a2c9ea0 100644
--- a/release_dashboard/test/test_utils_build.py
+++ b/release_dashboard/test/test_utils_build.py
@@ -12,13 +12,12 @@
#
# You should have received a copy of the GNU General Public License along
# with this prograproj. If not, see .
+from django.test import SimpleTestCase
-from django.test import TestCase
from release_dashboard.utils import build
-class UtilsBuildTestCase(TestCase):
-
+class UtilsBuildTestCase(SimpleTestCase):
def test_is_ngcp_project(self):
- self.assertFalse(build.is_ngcp_project('fake'))
- self.assertTrue(build.is_ngcp_project('kamailio'))
+ self.assertFalse(build.is_ngcp_project("fake"))
+ self.assertTrue(build.is_ngcp_project("kamailio"))
diff --git a/release_dashboard/test/test_utils_docker.py b/release_dashboard/test/test_utils_docker.py
index 072a1f1..1caaf84 100644
--- a/release_dashboard/test/test_utils_docker.py
+++ b/release_dashboard/test/test_utils_docker.py
@@ -1,22 +1,23 @@
# Copyright (C) 2017 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 prograproj. If not, see .
-
-from django.test import TestCase
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 mock import patch, call
DOCKER_REST_CATALOG = """
{
@@ -29,54 +30,51 @@ DOCKER_REST_CATALOG = """
"""
DOCKER_REST_FAKE_TAGS = {
- 'fake-jessie': """{
+ "fake-jessie": """{
"name": "fake-jessie",
"tags":[
"I3a899b8945688c2ef3a4be6ba6c4c1d4cbf6d548",
"latest"]
}""",
- 'other': """{"name": "other", "tags":[]}""",
+ "other": """{"name": "other", "tags":[]}""",
}
def fake_tag(url):
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":
- 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):
gdi.return_value = DOCKER_REST_CATALOG
self.assertCountEqual(
docker.get_docker_repositories(),
- ['fake-jessie',
- 'fake-selenium-jessie',
- 'other',
- 'one']
+ ["fake-jessie", "fake-selenium-jessie", "other", "one"],
)
- @patch('release_dashboard.utils.docker.get_docker_info',
- side_effect=fake_tag)
+ @patch(
+ "release_dashboard.utils.docker.get_docker_info", side_effect=fake_tag
+ )
def test_get_docker_tags(self, gdi):
self.assertCountEqual(
- docker.get_docker_tags('fake-jessie'),
- ["I3a899b8945688c2ef3a4be6ba6c4c1d4cbf6d548",
- "latest"])
+ docker.get_docker_tags("fake-jessie"),
+ ["I3a899b8945688c2ef3a4be6ba6c4c1d4cbf6d548", "latest"],
+ )
calls = [
call("fake-jessie/tags/list"),
]
gdi.assert_has_calls(calls)
- @patch('release_dashboard.utils.docker.get_docker_info',
- side_effect=fake_tag)
+ @patch(
+ "release_dashboard.utils.docker.get_docker_info", side_effect=fake_tag
+ )
def test_get_docker_tags_empty(self, gdi):
- self.assertCountEqual(docker.get_docker_tags('other'), [])
+ self.assertCountEqual(docker.get_docker_tags("other"), [])
calls = [
call("other/tags/list"),
]
diff --git a/release_dashboard/test/test_views.py b/release_dashboard/test/test_views.py
index ca70b42..75cef18 100644
--- a/release_dashboard/test/test_views.py
+++ b/release_dashboard/test/test_views.py
@@ -1,18 +1,17 @@
# 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 prograproj. If not, see .
-
from django.contrib.auth.models import User
from django.test import TestCase
from django.urls import reverse
diff --git a/repoapi/test/base.py b/repoapi/test/base.py
index c4b4dac..8a9686c 100644
--- a/repoapi/test/base.py
+++ b/repoapi/test/base.py
@@ -1,34 +1,37 @@
# Copyright (C) 2017 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 .
-
import os
import shutil
from tempfile import mkdtemp
-from django.test import TestCase, override_settings
-from django.conf import settings
-JBI_BASEDIR = mkdtemp(dir=settings.RESULTS_DIR)
+from django.test import override_settings
+from django.test import TestCase
+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):
+ from django.conf import settings
+
if not os.path.exists(settings.JBI_BASEDIR):
os.makedirs(settings.JBI_BASEDIR)
def tearDown(self):
+ from django.conf import settings
+
if os.path.exists(settings.JBI_BASEDIR):
shutil.rmtree(settings.JBI_BASEDIR)
diff --git a/repoapi/test/test_model_queries.py b/repoapi/test/test_model_queries.py
index 70779f9..ff32e44 100644
--- a/repoapi/test/test_model_queries.py
+++ b/repoapi/test/test_model_queries.py
@@ -15,14 +15,12 @@
from datetime import datetime
from datetime import timedelta
-from django.test import override_settings
from django.utils.dateparse import parse_datetime
from repoapi.models import JenkinsBuildInfo
from repoapi.test.base import BaseTest
-@override_settings(DEBUG=True)
class JBIQueriesTestCase(BaseTest):
fixtures = ["test_model_queries.json"]
@@ -103,7 +101,6 @@ class JBIQueriesTestCase(BaseTest):
self.assertEqual(JenkinsBuildInfo.objects.count(), 4)
-@override_settings(DEBUG=True)
class JBIQueriesUUIDTest(BaseTest):
fixtures = ["test_model_queries_uuid.json"]
release = "release-mr8.1"
diff --git a/repoapi/test/test_settings.py b/repoapi/test/test_settings.py
new file mode 100644
index 0000000..7d977ff
--- /dev/null
+++ b/repoapi/test/test_settings.py
@@ -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 .
+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")