예제 #1
0
파일: test_views.py 프로젝트: mjhea0/ramses
    def test_only_provided_attrs_are_available(self, run_init, mock_eng):
        view_cls = views.generate_rest_view(
            model_cls='foo', attrs=['show', 'foobar'],
            es_based=True, attr_view=False, singular=False)
        assert issubclass(view_cls, views.ESCollectionView)
        request = Mock(**ViewTestBase.request_kwargs)
        view = view_cls(request=request, **ViewTestBase.view_kwargs)
        assert not hasattr(view_cls, 'foobar')

        try:
            view.show()
        except JHTTPMethodNotAllowed:
            raise Exception('Unexpected error')
        except Exception:
            pass
        with pytest.raises(JHTTPMethodNotAllowed):
            view.delete_many()
        with pytest.raises(JHTTPMethodNotAllowed):
            view.create()
        with pytest.raises(JHTTPMethodNotAllowed):
            view.delete()
        with pytest.raises(JHTTPMethodNotAllowed):
            view.update_many()
        with pytest.raises(JHTTPMethodNotAllowed):
            view.index()
예제 #2
0
파일: test_views.py 프로젝트: mjhea0/ramses
 def test_default_values(self, mock_eng):
     view_cls = views.generate_rest_view(
         model_cls='foo', attrs=['show'])
     assert issubclass(view_cls, views.ESCollectionView)
     assert issubclass(view_cls, views.CollectionView)
     assert view_cls._model_class == 'foo'
     assert view_cls._json_encoder == mock_eng.JSONEncoder
예제 #3
0
파일: test_views.py 프로젝트: oleduc/ramses
    def test_only_provided_attrs_are_available(self, run_init):
        config = config_mock()
        view_cls = views.generate_rest_view(config,
                                            model_cls='foo',
                                            attrs=['show', 'foobar'],
                                            es_based=True,
                                            attr_view=False,
                                            singular=False)
        view_cls._json_encoder = 'foo'
        assert issubclass(view_cls, views.ESCollectionView)
        request = Mock(**ViewTestBase.request_kwargs)
        view = view_cls(request=request, **ViewTestBase.view_kwargs)
        assert not hasattr(view_cls, 'foobar')

        try:
            view.show()
        except JHTTPMethodNotAllowed:
            raise Exception('Unexpected error')
        except Exception:
            pass
        with pytest.raises(JHTTPMethodNotAllowed):
            view.delete_many()
        with pytest.raises(JHTTPMethodNotAllowed):
            view.create()
        with pytest.raises(JHTTPMethodNotAllowed):
            view.delete()
        with pytest.raises(JHTTPMethodNotAllowed):
            view.update_many()
        with pytest.raises(JHTTPMethodNotAllowed):
            view.index()
예제 #4
0
 def test_attribute_view(self):
     config = config_mock()
     view_cls = views.generate_rest_view(
         config, model_cls='foo', attrs=['show'],
         es_based=True, attr_view=True, singular=False)
     view_cls._json_encoder = 'foo'
     assert issubclass(view_cls, views.ItemAttributeView)
예제 #5
0
 def test_default_values(self):
     config = config_mock()
     view_cls = views.generate_rest_view(
         config, model_cls='foo', attrs=['show'])
     view_cls._json_encoder = 'foo'
     assert issubclass(view_cls, views.ESCollectionView)
     assert issubclass(view_cls, views.CollectionView)
     assert view_cls.Model == 'foo'
예제 #6
0
 def test_dbcollection_view(self):
     config = config_mock()
     view_cls = views.generate_rest_view(
         config, model_cls='foo', attrs=['show'],
         es_based=False, attr_view=False, singular=False)
     view_cls._json_encoder = 'foo'
     assert not issubclass(view_cls, views.ESCollectionView)
     assert issubclass(view_cls, views.CollectionView)
예제 #7
0
    def test_database_acls_option(self):
        from nefertari_guards.view import ACLFilterViewMixin
        config = config_mock()

        config.registry.database_acls = False
        view_cls = views.generate_rest_view(
            config, model_cls='foo', attrs=['show'],
            es_based=False, attr_view=False, singular=False)
        assert not issubclass(
            view_cls, ACLFilterViewMixin)
        assert not issubclass(
            view_cls, views.SetObjectACLMixin)

        config.registry.database_acls = True
        view_cls = views.generate_rest_view(
            config, model_cls='foo', attrs=['show'],
            es_based=False, attr_view=False, singular=False)
        assert issubclass(view_cls, views.SetObjectACLMixin)
        assert issubclass(view_cls, ACLFilterViewMixin)
예제 #8
0
파일: test_views.py 프로젝트: mjhea0/ramses
 def test_dbcollection_view(self, mock_eng):
     view_cls = views.generate_rest_view(
         model_cls='foo', attrs=['show'],
         es_based=False, attr_view=False, singular=False)
     assert not issubclass(view_cls, views.ESCollectionView)
     assert issubclass(view_cls, views.CollectionView)
예제 #9
0
파일: test_views.py 프로젝트: mjhea0/ramses
 def test_attribute_view(self, mock_eng):
     view_cls = views.generate_rest_view(
         model_cls='foo', attrs=['show'],
         es_based=True, attr_view=True, singular=False)
     assert issubclass(view_cls, views.ItemAttributeView)