forked from TrangPham/django-admin-confirm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(toolchain): fix toolchain session
- Loading branch information
Showing
5 changed files
with
77 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,27 +3,22 @@ | |
from django.contrib.admin.options import IS_POPUP_VAR | ||
from django.contrib.admin.sites import AdminSite | ||
from django.contrib.auth.models import Permission, User | ||
from django.test import TestCase | ||
from django.urls import reverse | ||
|
||
from admin_action_tools.constants import CONFIRM_ACTION | ||
from admin_action_tools.tests.helpers import RequestSessionFactory | ||
from admin_action_tools.tests.helpers import AdminConfirmTestCase | ||
from tests.market.admin import ShopAdmin | ||
from tests.market.admin.inventory_admin import InventoryAdmin | ||
from tests.market.models import Inventory, Shop | ||
|
||
|
||
class TestConfirmActions(TestCase): | ||
class TestConfirmActions(AdminConfirmTestCase): | ||
@classmethod | ||
def setUpTestData(cls): | ||
cls.superuser = User.objects.create_superuser( # nosec | ||
username="super", email="[email protected]", password="pass" | ||
) | ||
|
||
def setUp(self): | ||
self.client.force_login(self.superuser) | ||
self.factory = RequestSessionFactory() | ||
|
||
def test_get_changelist_should_not_be_affected(self): | ||
response = self.client.get(reverse("admin:market_shop_changelist")) | ||
self.assertIsNotNone(response) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
from django.contrib.auth.models import User | ||
from django.test import TestCase | ||
from django.urls import reverse | ||
|
||
from admin_action_tools.constants import CONFIRM_FORM | ||
from admin_action_tools.tests.helpers import RequestSessionFactory | ||
from admin_action_tools.tests.helpers import AdminConfirmTestCase | ||
from tests.factories import InventoryFactory, ShopFactory | ||
from tests.market.form import NoteActionForm | ||
|
||
CONFIRM_FORM_UNIQUE = f"{CONFIRM_FORM}_{NoteActionForm.__name__}" | ||
|
||
|
||
class TestFormAction(TestCase): | ||
class TestFormAction(AdminConfirmTestCase): | ||
@classmethod | ||
def setUpTestData(cls): | ||
cls.superuser = User.objects.create_superuser( # nosec | ||
username="super", email="[email protected]", password="pass" | ||
) | ||
|
||
def setUp(self): | ||
self.client.force_login(self.superuser) | ||
self.factory = RequestSessionFactory() | ||
super().setUp() | ||
self.shop = ShopFactory() | ||
self.inv = InventoryFactory(shop=self.shop, quantity=10) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from admin_action_tools.constants import CONFIRM_FORM | ||
from admin_action_tools.tests.helpers import AdminConfirmTestCase | ||
from admin_action_tools.toolchain import ToolChain | ||
from tests.market.form import NoteActionForm | ||
|
||
|
||
class TestToolchain(AdminConfirmTestCase): | ||
def test_form_action(self): | ||
request = self.factory.request() | ||
name = f"toolchain{request.path}" | ||
request.session[name] = { | ||
"expire_at": "2012-11-02T15:14:31.000", | ||
"history": ["tool1"], | ||
"tool1": {"data": {"field1": True}, "metadata": {}}, | ||
} | ||
toolchain = ToolChain(request) | ||
|
||
# test toolchain reset | ||
self.assertEqual(toolchain.get_history(), []) | ||
|
||
# test data is save | ||
self.assertEqual(request.session[name]["history"], []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters