File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ import pytest
2+ from tests .models import Article , Tag
3+ from easyaudit .models import CRUDEvent
4+
5+
6+ @pytest .mark .django_db
7+ def test_m2m_logging_full ():
8+
9+ article = Article .objects .create (title = "Test Article" )
10+ tag1 = Tag .objects .create (name = "django" )
11+ tag2 = Tag .objects .create (name = "pytest" )
12+
13+
14+ CRUDEvent .objects .all ().delete ()
15+
16+ # --- M2M_ADD ---
17+ article .tags .add (tag1 )
18+ assert CRUDEvent .objects .filter (event_type = CRUDEvent .M2M_ADD ).exists (),
19+
20+ # --- M2M_REMOVE ---
21+ article .tags .remove (tag1 )
22+ assert CRUDEvent .objects .filter (event_type = CRUDEvent .M2M_REMOVE ).exists (),
23+
24+ # --- M2M_CLEAR ---
25+ article .tags .add (tag1 , tag2 )
26+ article .tags .clear ()
27+ assert CRUDEvent .objects .filter (event_type = CRUDEvent .M2M_CLEAR ).exists (),
You can’t perform that action at this time.
0 commit comments