Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: SpikeeLabs/django-admin-action-tools
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.2
Choose a base ref
...
head repository: SpikeeLabs/django-admin-action-tools
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.1.3-alpha.1
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Nov 3, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    Copy the full SHA
    665b986 View commit details
Showing with 38 additions and 2 deletions.
  1. +33 −1 admin_action_tools/tests/unit/test_toolchain.py
  2. +5 −1 admin_action_tools/toolchain.py
34 changes: 33 additions & 1 deletion admin_action_tools/tests/unit/test_toolchain.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


class TestToolchain(AdminConfirmTestCase):
def test_form_action(self):
def test_toolchain_expired(self):
request = self.factory.request()
name = f"toolchain{request.path}"
request.session[name] = {
@@ -20,3 +20,35 @@ def test_form_action(self):

# test data is save
self.assertEqual(request.session[name]["history"], [])

def test_toolchain_wrong_date(self):
request = self.factory.request()
name = f"toolchain{request.path}"
request.session[name] = {
"expire_at": "ggg",
"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"], [])

def test_toolchain_wrong_date_type(self):
request = self.factory.request()
name = f"toolchain{request.path}"
request.session[name] = {
"expire_at": 3,
"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"], [])
6 changes: 5 additions & 1 deletion admin_action_tools/toolchain.py
Original file line number Diff line number Diff line change
@@ -55,7 +55,11 @@ def _get_data(self):
expire_at = old_data.get("expire_at")

if expire_at:
expire_at = datetime.fromisoformat(expire_at)
try:
expire_at = datetime.fromisoformat(expire_at)
except Exception: # pylint: disable=broad-except
expire_at = None
old_data = None

if not old_data:
self.data = {"expire_at": self._get_expiration()}