Python mongoengine.fields.StringField() Examples
The following are 9
code examples of mongoengine.fields.StringField().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
mongoengine.fields
, or try the search function
.
Example #1
Source File: test_backend.py From drf-mongo-filters with GNU General Public License v2.0 | 6 votes |
def test_model_mismatch(self): """ cannot apply filters for one model to queryset from another """ class FooDoc(Document): foo = fields.StringField() class BarDoc(Document): bar = fields.StringField() class FooFilter(ModelFilterset): class Meta: model = FooDoc class BarView(ListAPIView): filter_backends = (MongoFilterBackend,) filter_class = FooFilter serializer_class = mock.Mock() queryset = BarDoc.objects with self.assertRaises(TypeError): BarView.as_view()(APIRequestFactory().get("/?foo=Foo"))
Example #2
Source File: test_backend.py From drf-mongo-filters with GNU General Public License v2.0 | 6 votes |
def test_model_subclassed(self): """ can apply filters for base model to queryset of derived """ class FooDoc(Document): meta = { 'allow_inheritance': True} foo = fields.StringField() class BarDoc(FooDoc): bar = fields.StringField() class FooFilter(ModelFilterset): class Meta: model = FooDoc class BarView(ListAPIView): filter_backends = (MongoFilterBackend,) filter_class = FooFilter serializer_class = mock.Mock() queryset = BarDoc.objects BarView.as_view()(APIRequestFactory().get("/?foo=Foo"))
Example #3
Source File: test_filtersets.py From drf-mongo-filters with GNU General Public License v2.0 | 5 votes |
def test_auto_derivatives(self): class FooField(fields.StringField): pass class MockModel(Document): foo = FooField() class TestFS(ModelFilterset): class Meta: model = MockModel fs = TestFS() self.assertEqual(set(fs.filters.keys()), set(['id', 'foo'])) self.assertIsInstance(fs.filters['foo'], filters.CharFilter)
Example #4
Source File: test_filtersets.py From drf-mongo-filters with GNU General Public License v2.0 | 5 votes |
def test_selecting(self): class MockModel(Document): foo = fields.StringField() bar = fields.StringField() baz = fields.StringField() class TestFS(ModelFilterset): class Meta: model = MockModel fields = ('foo','baz') fs = TestFS() self.assertEqual(set(fs.filters.keys()), set(['id', 'foo', 'baz']))
Example #5
Source File: test_filtersets.py From drf-mongo-filters with GNU General Public License v2.0 | 5 votes |
def test_excluding(self): class MockModel(Document): foo = fields.StringField() bar = fields.StringField() baz = fields.StringField() class TestFS(ModelFilterset): class Meta: model = MockModel exclude = ('bar',) fs = TestFS() self.assertEqual(set(fs.filters.keys()), set(['id', 'foo', 'baz'])) self.assertIsInstance(fs.filters['foo'], filters.CharFilter)
Example #6
Source File: test_filtersets.py From drf-mongo-filters with GNU General Public License v2.0 | 5 votes |
def test_redeclaring(self): class MockModel(Document): foo = fields.StringField() bar = fields.StringField() baz = fields.StringField() class TestFS(ModelFilterset): class Meta: model = MockModel bar = filters.IntegerFilter() fs = TestFS() self.assertEqual(set(fs.filters.keys()), set(['id', 'foo', 'bar', 'baz'])) self.assertIsInstance(fs.filters['foo'], filters.CharFilter) self.assertIsInstance(fs.filters['bar'], filters.IntegerFilter) self.assertIsInstance(fs.filters['baz'], filters.CharFilter)
Example #7
Source File: test_filtersets.py From drf-mongo-filters with GNU General Public License v2.0 | 5 votes |
def test_kwargs(self): class MockModel(Document): foo = fields.StringField() bar = fields.StringField() baz = fields.StringField() class TestFS(ModelFilterset): class Meta: model = MockModel kwargs = { 'foo': { 'lookup': 'gte' } } fs = TestFS() self.assertEqual(fs.filters['foo'].lookup_type, 'gte')
Example #8
Source File: badges_field.py From udata with GNU Affero General Public License v3.0 | 5 votes |
def __init__(self, **kwargs): self.registered = {} super(BadgesField, self).__init__(StringField(), **kwargs)
Example #9
Source File: taglist_field.py From udata with GNU Affero General Public License v3.0 | 5 votes |
def __init__(self, **kwargs): self.tags = [] super(TagListField, self).__init__(StringField(), **kwargs)