-
-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathtest_mixins.py
More file actions
23 lines (15 loc) · 727 Bytes
/
test_mixins.py
File metadata and controls
23 lines (15 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pytest
from statemachine.mixins import MachineMixin
from tests.models import MyModel
class MyMixedModel(MyModel, MachineMixin):
state_machine_name = "tests.conftest.CampaignMachine"
def test_mixin_should_instantiate_a_machine(campaign_machine):
model = MyMixedModel(state="draft")
assert isinstance(model.statemachine, campaign_machine)
assert model.state == "draft"
assert model.statemachine.current_state == model.statemachine.draft
def test_mixin_should_raise_exception_if_machine_class_does_not_exist():
class MyModelWithoutMachineName(MachineMixin):
pass
with pytest.raises(ValueError, match="None is not a valid state machine name"):
MyModelWithoutMachineName()