Skip to content

Commit

Permalink
Merge 85b8e15 into a1f35f6
Browse files Browse the repository at this point in the history
  • Loading branch information
emil-balashov committed Jan 15, 2020
2 parents a1f35f6 + 85b8e15 commit 98d593b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions django_logic/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def __getattr__(self, item):
# This exceptions should be handled otherwise it will be very annoying
elif transitions:
raise ManyTransitions("There are several transitions available")
else:
raise TransitionNotAllowed('Transition not allowed')
raise AttributeError(f"Process class {self.__class__} has no transition with action name {item}")

def is_valid(self, user=None) -> bool:
"""
Expand Down
9 changes: 9 additions & 0 deletions tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,15 @@ class MyProcess(Process):
invoice.refresh_from_db()
self.assertEqual(invoice.status, 'draft')

def test_get_non_existing_transition(self):
class MyProcess(Process):
transitions = [Transition('validate', sources=['draft'], target='valid')]

invoice = Invoice.objects.create(status='draft')
process = MyProcess(instance=invoice, field_name='status')
with self.assertRaises(AttributeError):
process.test()


def disable_invoice(invoice: Invoice):
invoice.is_available = False
Expand Down

0 comments on commit 98d593b

Please sign in to comment.