Exemple #1
0
    def test_BaseView_form_attribute_must_be_instance_of_FlaskForm():
        mocked_form = Mock(FlaskForm)
        BaseView.Meta.form = mocked_form

        # init new instance BaseView with form specified
        BaseView()
        # in init method BaseView must init form class and save form instance
        mocked_form.assert_called()
Exemple #2
0
    def test_BaseView_template_property_must_return_attribute_from_Meta(self):
        """
        template specified
        """
        expected_template = 'some_template.html'
        BaseView.Meta.template = expected_template
        # view with template
        new_view = BaseView()

        self.assertEqual(new_view.template, expected_template)
Exemple #3
0
    def test_BaseView_default_page_property_must_return_url_for_home_if_Meta_default_page_not_specified(mocked_url):
        """
        When default page is not specified property must return '/'
        """
        BaseView.Meta.default_page = None

        expected_route = '/'

        new_view = BaseView()
        new_view.default_page
        mocked_url.assert_called_with(expected_route)
Exemple #4
0
 def test_BaseView_render_own_template_method_must_call_render_template_function_with_param_at_default(mock_render):
     """
     Default param is:
         -   template
         -   title
         -   form
     """
     BaseView.Meta.form = Mock(return_value='form')
     BaseView.Meta.title = 'title'
     BaseView.Meta.template = 'template'
     expected_kwargs = {
         '__title__': 'title',
         'form': 'form'
     }
     new_view = BaseView()
     new_view._render_own_template()
     mock_render.assert_called_once_with('template', **expected_kwargs)
Exemple #5
0
 def setUp(self):
     self.view = BaseView()