Ejemplo n.º 1
0
 def test_calls_child_block_is_submitted(self, mock_getstreamfields, mock_hasattr):
     child = mock.Mock()
     streamfields = {'name': [child]}
     mock_getstreamfields.return_value = streamfields
     mock_hasattr.return_value = True
     form_module_handlers(self.page, self.request, self.context)
     child.block.is_submitted.assert_called_with(self.request, 'name', 0)
Ejemplo n.º 2
0
 def test_checks_child_block_if_set_form_context_exists(
         self, mock_getstreamfields, mock_hasattr):
     child = mock.Mock()
     streamfields = {'name': [child]}
     mock_getstreamfields.return_value = streamfields
     form_module_handlers(self.page, self.request, self.context)
     mock_hasattr.assert_called_with(child.block, 'get_result')
Ejemplo n.º 3
0
 def test_sets_context_fieldname_if_not_set(self, mock_getstreamfields, mock_hasattr):
     child = mock.Mock()
     streamfields = {'name': [child]}
     mock_getstreamfields.return_value = streamfields
     mock_hasattr.return_value = True
     form_module_handlers(self.page, self.request, self.context)
     assert 'name' in self.context['form_modules']
     self.assertIsInstance(self.context['form_modules']['name'], dict)
 def test_checks_child_block_if_set_form_context_exists(self, mock_getstreamfields, mock_hasattr):
     child = mock.Mock()
     streamfields = {'name': [child]}
     mock_getstreamfields.return_value = streamfields
     form_module_handlers(self.page, self.request, self.context)
     mock_hasattr.assert_called_with(child.block, 'get_result')
Ejemplo n.º 5
0
 def test_calls_get_streamfields(self, mock_getstreamfields):
     form_module_handlers(self.page, self.request, self.context)
     mock_getstreamfields.assert_called_with(self.page)
Ejemplo n.º 6
0
 def test_does_not_set_context(self, mock_getstreamfields):
     mock_getstreamfields().items.return_value = []
     form_module_handlers(self.page, self.request, self.context)
     assert 'form_modules' not in self.context
Ejemplo n.º 7
0
 def test_sets_context(self, mock_getstreamfields, mock_hasattr):
     mock_hasattr.return_value = True
     child = mock.Mock()
     mock_getstreamfields().items.return_value = [('name', [child])]
     form_module_handlers(self.page, self.request, self.context)
     assert 'form_modules' in self.context