Ejemplo n.º 1
0
    def test_uri_convert(self):
        with self.assertRaises(ValidationError):
            fields.Uri().convert('foo bad')

        self.assertEqual(
            'http://www.ietf.org/rfc/rfc2396.txt',
            fields.Uri().convert('http://www.ietf.org/rfc/rfc2396.txt'))
Ejemplo n.º 2
0
 def test_inherited_filters(self):
     self.assertEqual(
         {
             'string': {
                 'eq': filters.EqualFilter
             },
             'email': {
                 None: filters.EqualFilter,
                 'eq': filters.EqualFilter,
                 'ne': filters.NotEqualFilter,
                 'in': filters.InFilter,
                 'contains': filters.StringContainsFilter,
                 'icontains': filters.StringIContainsFilter,
                 'endswith': filters.EndsWithFilter,
                 'iendswith': filters.IEndsWithFilter,
                 'startswith': filters.StartsWithFilter,
                 'istartswith': filters.IStartsWithFilter,
             },
             'uri': {
                 'eq': filters.EqualFilter,
                 'ne': filters.NotEqualFilter,
                 'endswith': filters.EndsWithFilter,
             },
             'date_string': {
                 None: filters.EqualFilter,
                 'eq': filters.EqualFilter,
                 'ne': filters.NotEqualFilter,
                 'in': filters.InFilter,
                 'lt': filters.LessThanFilter,
                 'lte': filters.LessThanEqualFilter,
                 'gt': filters.GreaterThanFilter,
                 'gte': filters.GreaterThanEqualFilter,
                 'between': filters.DateBetweenFilter,
             },
         },
         filters_for_fields(
             {
                 'string': fields.String(),
                 # inherit from String
                 'email': fields.Email(),
                 'uri': fields.Uri(),
                 # no filter defined for Raw
                 'raw': fields.Raw({}),
                 # inherits from String, but there is a filter for DateString
                 'date_string': fields.DateString(),
             },
             filter_names=FILTER_NAMES,
             filters_by_type=FILTERS_BY_TYPE,
             filters_expression={
                 'string': ['eq'],
                 'email': True,
                 'uri': ['eq', 'ne', 'endswith'],
                 '*': True,
             },
         ),
     )
Ejemplo n.º 3
0
    'imageUrl':
    fields.String(
        nullable=True,
        description=
        'Base64 URL encoded string for the image to embed in the mail',
        attribute='image_url',
    ),
    'recipients':
    fields.List(
        fields.Email(nullable=False),
        nullable=False,
        description='A list of emails to share an analysis with',
    ),
    'attachments':
    fields.List(
        fields.Object({
            'filename':
            fields.String(description='Name of the attachment file'),
            'content':
            fields.String(
                description=
                'Content inform of CSV or JSON strings for the attachment file'
            ),
        })),
    'queryUrl':
    fields.Uri(description='Url for the current query', attribute='query_url'),
    'isPreview':
    fields.Boolean(description='Flag for sending preview email',
                   attribute='is_preview'),
}