Exemplo n.º 1
0
    def test_sortQuerySet(self):

        with Mock() as querySet:
            querySet.order_by('foo')
            querySet.order_by('bar')

        s = columns.StringColumn('foo')
        s.sortQuerySet(querySet, False)

        s = columns.StringColumn('foo', sortColumnName='bar')

        s.sortQuerySet(querySet, False)
        querySet.validate()
Exemplo n.º 2
0
    def setUp(self):
        self.w = widgets.StringWidget('foo',
                                      filterKwargs=dict(operation="contains"))
        self.c = columns.StringColumn('foo')

        self.s = storage.Storage(None, widgets=[self.w], columns=[self.c])

        self.valueDict = {'table': None, 'foo': '5', 'sort': '-foo'}
Exemplo n.º 3
0
    def test_stringColumn(self):
        s = columns.StringColumn('foo')

        with Mock() as querySet:
            querySet.order_by('foo')
            querySet.order_by('-foo')

        s.sortQuerySet(querySet, False)
        s.sortQuerySet(querySet, True)
Exemplo n.º 4
0
    def setUp(self):
        class FakeRequest:
            GET = dict(sort='first_name', start=0, count=2)

        self.fakeRequest = FakeRequest()
        self.column = columns.StringColumn('first_name', 'label')
        self.d = Table("name",
                       storage=Storage(querySet=User.objects.all(),
                                       columns=[self.column]))
Exemplo n.º 5
0
    def setUp(self):
        for a in range(5):
            User.objects.create_user('datable-test-user%i' % a, '*****@*****.**')

        self.d = Table("name",
                       storage=Storage(
                           querySet=User.objects.all(),
                           columns=[columns.StringColumn('email', 'E-mail')],
                           widgets=[
                               widgets.StringWidget('email',
                                                    label="E-mail",
                                                    initialValue='foo')
                           ]))

        self.request = FakeRequest()
        self.request.GET = {'email': 'foo@'}
Exemplo n.º 6
0
    def setUp(self):
        self.no_calls = 0

        self.req = FakeRequest()

        self.req.GET = {'start': 0, 'count': 25}
        self.req.POST = {}

        User.objects.create_user('username', 'email-username')
        User.objects.create_user('username2', 'email-username2')
        User.objects.create_user('username3', 'email')

        self.d = Table('datable',
                       storage=Storage(
                           querySet=User.objects.all(),
                           columns=[columns.StringColumn('email', 'E-mail')],
                           widgets=[widgets.StringWidget(name='exists')]))
Exemplo n.º 7
0
    def setUp(self):
        self.c = columns.StringColumn('foo')
        self.w = widgets.StringWidget('foo',
                                      filterKwargs=dict(operation="contains"))

        self.s = storage.Storage(None, widgets=[self.w], columns=[self.c])

        self.t = table.Table(name='table', storage=self.s)

        self.requestDict = {'table': None, 'foo': '5', 'sort': '-foo'}

        class FakeRequest:
            META = {'HTTP_HOST': 'localhost'}
            is_secure = lambda x=None: False
            path = '/lol'
            GET = self.requestDict

        self.fakeRequest = FakeRequest()
Exemplo n.º 8
0
 def test_getLabel(self):
     s = columns.StringColumn('foo')
     self.assertEquals(s.getLabel(), s.label)
Exemplo n.º 9
0
 def test_getSerializer(self):
     s = columns.StringColumn('foo')
     self.assertEquals(s.getSerializer(), s.serializer)
Exemplo n.º 10
0
 def test_getName(self):
     s = columns.StringColumn('foo')
     self.assertEquals(s.getName(), 'foo')