def test_sort_by_lambda_column(self):
        column = Endpoint.get_widget("author-table", ()).columns.index(('Age', get_age))
        client_params = _client_params_ordering(column, "desc")
        records = Endpoint.get_widget("author-table", ()).get_data(client_params)['aaData']
        self.assertLess(_get_date(records[0]['1']), _get_date(records[1]['1']))

        client_params = _client_params_ordering(column, "asc")
        records = Endpoint.get_widget("author-table", ()).get_data(client_params)['aaData']
        self.assertGreater(_get_date(records[0]['1']), _get_date(records[1]['1']))
 def test_second_page(self):
     PAGE_SIZE = 10
     for _ in range(PAGE_SIZE):
         Book.objects.create(title="Book", author=self.fakeauthor)
     client_params = json.dumps({
         'datatables_params': {"iDisplayStart": PAGE_SIZE,
                               "iDisplayLength": PAGE_SIZE,
                               "sEcho": 1}})
     records = Endpoint.get_widget("book-table", ()).get_data(client_params)['aaData']
     self.assertEqual(len(records), 3)
 def test_get_all_data(self):
     city_map = Endpoint.get_widget("city-map", ())
     client_params = {}
     data = city_map.get_data(client_params)
     self.assertEqual(data, [
         {'description': "City City_1 with latitude 30 " +
                         "and longitude 20",
          'latitude': 30.0, 'longitude': 20.0},
         {'description': "City City_2 with latitude 33 " +
                         "and longitude 21",
          'latitude': 33.0, 'longitude': 21.0},
         {'description': "City City_3 with latitude 35 " +
                         "and longitude 22",
          'latitude': 35.0, 'longitude': 22.0}])
 def test_str(self):
     text = smart_text(Endpoint.get_widget("book-table", ()))
     self.assertIn("Title", text)
 def test_single_text_filter(self):
     client_params = '{"filter_query":"pages__gt=19"}'
     records = Endpoint.get_widget("book-table", ()).get_data(client_params)['aaData']
     self.assertEqual(len(records), 1)
 def test_no_filters(self):
     records = Endpoint.get_widget("book-table", ()).get_data("{}")['aaData']
     self.assertEqual(len(records), 3)
 def test_get_no_data(self):
     city_map = Endpoint.get_widget("city-map", ())
     client_params = 'citizens_number__gt=30&latitude__lt=20.0'
     data = city_map.get_data(client_params)
     self.assertEqual(data, [])
 def test_get_some_data(self):
     city_map = Endpoint.get_widget("city-map", ())
     client_params = 'citizens_number__gt=30&latitude__lt=34.0'
     data = city_map.get_data(client_params)
     self.assertEqual(data[0]['latitude'], 33.0)
示例#9
0
 def get_context_data(self, **kwargs):
     return {
         'book_table': Endpoint.get_widget("book-table", ()),
         'author_table': Endpoint.get_widget("author-table", ()),
         "filterform": Endpoint.get_widget("book-table", ()).filterform
     }
示例#10
0
 def get_context_data(self, **kwargs):
     return {
         'city_filterform': Endpoint.get_widget("city-map", ()).filterform,
         'city_map': Endpoint.get_widget("city-map", ()),
     }
示例#11
0
 def get_context_data(self, **kwargs):
     return {
         "map": Endpoint.get_widget("city-map-nf", ())
     }
示例#12
0
 def get_context_data(self, **kwargs):
     return {
         'book_table': Endpoint.get_widget("book-table", ()),
         'author_table': Endpoint.get_widget("author-table", ()),
         "filterform": Endpoint.get_widget("book-table", ()).filterform
     }
示例#13
0
 def get_context_data(self, **kwargs):
     return {
         'city_filterform': Endpoint.get_widget("city-map", ()).filterform,
         'city_map': Endpoint.get_widget("city-map", ()),
     }
示例#14
0
 def get_context_data(self, **kwargs):
     return {"map": Endpoint.get_widget("city-map-nf", ())}