1-
21import pytest
2+ from tests .views .message .utils import post_and_get_response
3+
34from django_unicorn .components import UnicornView
45from example .coffee .models import Flavor
5- from tests . views . message . utils import post_and_get_response
6+
67
78class TestIssue732View (UnicornView ):
89 template_name = "templates/test_component.html"
9- flavor : Flavor = None
10+ flavor : Flavor | None = None
1011
1112 def mount (self ):
1213 pass
@@ -17,6 +18,7 @@ def load_flavor(self, flavor_id):
1718 def save (self ):
1819 self .flavor .save ()
1920
21+
2022@pytest .mark .django_db
2123def test_fk_loading (client ):
2224 # Setup
@@ -35,22 +37,22 @@ def test_fk_loading(client):
3537 url = "/message/tests.views.test_fk_loading.TestIssue732View" ,
3638 action_queue = action_queue ,
3739 )
38-
40+
3941 assert not response .get ("error" )
4042 data = response ["data" ]
41-
43+
4244 # Verify flavor is in data
4345 assert "flavor" in data
4446 assert data ["flavor" ]["pk" ] == child_flavor .pk
45-
47+
4648 # 2. Execute 'save' with the returned data
4749 action_queue = [
4850 {
4951 "payload" : {"name" : "save" , "args" : []},
5052 "type" : "callMethod" ,
5153 }
5254 ]
53-
55+
5456 # This is where it should fail without the fix
5557 response = post_and_get_response (
5658 client ,
@@ -59,7 +61,4 @@ def test_fk_loading(client):
5961 action_queue = action_queue ,
6062 )
6163
62- if "error" in response :
63- print (f"Error: { response ['error' ]} " )
64-
6564 assert not response .get ("error" )
0 commit comments