✨(plugins) move fixture plugins_urls to conftest
This fixture will be reused in various tests.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""Fixtures for the la suite tests."""
|
||||
|
||||
from importlib import import_module, reload
|
||||
|
||||
from django.urls import clear_url_caches, set_urlconf
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(name="plugin_urls")
|
||||
def reload_urlconf(settings):
|
||||
"""Reload the urlconf before"""
|
||||
settings.INSTALLED_PLUGINS = ["plugins.la_suite"]
|
||||
reload(import_module("core.plugins.urls"))
|
||||
reload(import_module(settings.ROOT_URLCONF))
|
||||
|
||||
clear_url_caches()
|
||||
set_urlconf(None)
|
||||
|
||||
yield
|
||||
|
||||
settings.INSTALLED_PLUGINS = []
|
||||
reload(import_module("core.plugins.urls"))
|
||||
reload(import_module(settings.ROOT_URLCONF))
|
||||
|
||||
clear_url_caches()
|
||||
set_urlconf(None)
|
||||
@@ -1,9 +1,6 @@
|
||||
"""Test for the La Suite plugin API active organizations siret"""
|
||||
|
||||
from importlib import import_module, reload
|
||||
|
||||
from django.test import override_settings
|
||||
from django.urls import clear_url_caches, set_urlconf
|
||||
|
||||
import pytest
|
||||
from rest_framework import status
|
||||
@@ -16,26 +13,6 @@ pytestmark = pytest.mark.django_db
|
||||
API_URL = "/la-suite/v1.0/siret/"
|
||||
|
||||
|
||||
@pytest.fixture(name="plugin_urls")
|
||||
def reload_urlconf(settings):
|
||||
"""Reload the urlconf before"""
|
||||
settings.INSTALLED_PLUGINS = ["plugins.la_suite"]
|
||||
reload(import_module("core.plugins.urls"))
|
||||
reload(import_module(settings.ROOT_URLCONF))
|
||||
|
||||
clear_url_caches()
|
||||
set_urlconf(None)
|
||||
|
||||
yield
|
||||
|
||||
settings.INSTALLED_PLUGINS = []
|
||||
reload(import_module("core.plugins.urls"))
|
||||
reload(import_module(settings.ROOT_URLCONF))
|
||||
|
||||
clear_url_caches()
|
||||
set_urlconf(None)
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def test_active_organizations_siret_unauthorized(plugin_urls):
|
||||
"""Test the active organizations siret API unauthorized"""
|
||||
|
||||
Reference in New Issue
Block a user