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()
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'}
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)
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]))
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@'}
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')]))
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()
def test_getLabel(self): s = columns.StringColumn('foo') self.assertEquals(s.getLabel(), s.label)
def test_getSerializer(self): s = columns.StringColumn('foo') self.assertEquals(s.getSerializer(), s.serializer)
def test_getName(self): s = columns.StringColumn('foo') self.assertEquals(s.getName(), 'foo')