@@ -9,9 +9,29 @@ def portal(portal_class):
99 yield portal_class
1010
1111
12+ @pytest .fixture (scope = "class" )
13+ def contents (portal ):
14+ with api .env .adopt_roles (["Manager" ]):
15+ doc = api .content .create (portal , type = "Document" , id = "lorem-ipsum" )
16+ doc .blocks = {
17+ "1" : {"@type" : "title" },
18+ "2" : {"@type" : "teaser" },
19+ "3" : {
20+ "@type" : "gridBlock" ,
21+ "blocks" : {
22+ "1" : {"@type" : "teaser" },
23+ "2" : {"@type" : "teaser" },
24+ "3" : {"@type" : "teaser" },
25+ },
26+ },
27+ }
28+ doc .reindexObject (idxs = ["block_types" ])
29+ transaction .commit ()
30+
31+
1232class TestBlockTypesGet :
1333 @pytest .fixture (autouse = True )
14- def _setup (self , portal , api_manager_request ):
34+ def _setup (self , contents , portal , api_manager_request ):
1535 self .portal = portal
1636 self .api_session = api_manager_request
1737
@@ -26,28 +46,11 @@ def test_response_type_with_id(self):
2646 assert isinstance (data , list )
2747
2848 def test_filtered (self ):
29- with api .env .adopt_roles (["Manager" ]):
30- doc = api .content .create (self .portal , type = "Document" , id = "lorem-ipsum" )
31- doc .blocks = {
32- "1" : {"@type" : "title" },
33- "2" : {"@type" : "teaser" },
34- "3" : {
35- "@type" : "gridBlock" ,
36- "blocks" : {
37- "1" : {"@type" : "teaser" },
38- "2" : {"@type" : "teaser" },
39- "3" : {"@type" : "teaser" },
40- },
41- },
42- }
43- doc .reindexObject (idxs = ["block_types" ])
44- transaction .commit ()
45-
4649 response = self .api_session .get ("/@blocktypes?path=/plone/lorem-ipsum" )
4750 data = response .json ()
4851 assert len (data ) == 3
4952
5053 def test_filtered_with_id (self ):
5154 response = self .api_session .get ("/@blocktypes/teaser?path=/plone/lorem-ipsum" )
5255 data = response .json ()
53- assert len (data ) == 4
56+ assert len (data ) == 1
0 commit comments