def test_get_tree_queryset(self): # get default queryset qs = get_tree_queryset(Country) self.assertEqual(len(qs), 257) self.assertEqual(qs[0].name, 'root') # subtree qs = get_tree_queryset(Country, node_id=Country.objects.get(name='Europe').id) self.assertEqual(len(qs), 50) self.assertEqual(qs[0].name, u'Åland Islands') # max_level 1 qs = get_tree_queryset(Country, max_level=1) self.assertEqual(len(qs), 8) self.assertEqual(qs[0].name, 'root') # max_level True qs = get_tree_queryset(Country, max_level=True) self.assertEqual(len(qs), 8) # exclude root qs = get_tree_queryset(Country, include_root=False) self.assertEqual(len(qs), 256) self.assertEqual(qs[0].name, 'Africa')
def test_format_label(self): tree = get_tree_from_queryset(get_tree_queryset(Country), item_label_field_name="code") root = tree[0] continents = root["children"] african_countries = continents[0]["children"] self.assertEqual(african_countries[0]["name"], "DZ")
def test_format_label(self): tree = get_tree_from_queryset(get_tree_queryset(Country), item_label_field_name='code') root = tree[0] continents = root['children'] african_countries = continents[0]['children'] self.assertEqual(african_countries[0]['name'], 'DZ')
def test_get_tree_from_queryset(self): tree = get_tree_from_queryset(get_tree_queryset(Country)) root = tree[0] self.assertEqual(root['name'], 'root') continents = root['children'] self.assertEqual(len(continents), 7) self.assertEqual(continents[0]['name'], 'Africa') african_countries = continents[0]['children'] self.assertEqual(african_countries[0]['name'], 'Algeria') # format label tree = get_tree_from_queryset(get_tree_queryset(Country), item_label_field_name='code') root = tree[0] continents = root['children'] african_countries = continents[0]['children'] self.assertEqual(african_countries[0]['name'], 'DZ')
def test_default(self): tree = get_tree_from_queryset(get_tree_queryset(Country)) root = tree[0] self.assertEqual(root['name'], 'root') continents = root['children'] self.assertEqual(len(continents), 7) self.assertEqual(continents[0]['name'], 'Africa') african_countries = continents[0]['children'] self.assertEqual(african_countries[0]['name'], 'Algeria')
def test_default(self): tree = get_tree_from_queryset(get_tree_queryset(Country)) root = tree[0] self.assertEqual(root["name"], "root") continents = root["children"] self.assertEqual(len(continents), 7) self.assertEqual(continents[0]["name"], "Africa") african_countries = continents[0]["children"] self.assertEqual(african_countries[0]["name"], "Algeria")
def test_get_tree_queryset(self): # get default queryset qs = get_tree_queryset(Country) self.assertEqual(len(qs), 257) self.assertEqual(qs[0].name, 'root') # subtree qs = get_tree_queryset(Country, node_id=Country.objects.get(name='Europe').id) self.assertEqual(len(qs), 50) self.assertEqual(qs[0].name, u'Åland Islands') # max_level 1 qs = get_tree_queryset(Country, max_level=1) self.assertEqual(len(qs), 8) self.assertEqual(qs[0].name, 'root') # max_level True qs = get_tree_queryset(Country, max_level=True) self.assertEqual(len(qs), 8) # exclude root qs = get_tree_queryset(Country, include_root=False) self.assertEqual(len(qs), 256) self.assertEqual(qs[0].name, 'Africa')
def test_exclude_root(self): qs = get_tree_queryset(Country, include_root=False) self.assertEqual(len(qs), 256) self.assertEqual(qs[0].name, 'Africa')
def test_max_level_true(self): qs = get_tree_queryset(Country, max_level=True) self.assertEqual(len(qs), 8)
def test_max_level_1(self): qs = get_tree_queryset(Country, max_level=1) self.assertEqual(len(qs), 8) self.assertEqual(qs[0].name, 'root')
def test_subtree(self): qs = get_tree_queryset(Country, node_id=Country.objects.get(name='Europe').id) self.assertEqual(len(qs), 50) self.assertEqual(qs[0].name, 'Åland Islands')
def test_default(self): qs = get_tree_queryset(Country) self.assertEqual(len(qs), 257) self.assertEqual(qs[0].name, 'root')