Exemplo n.º 1
0
    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')
Exemplo n.º 2
0
 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")
Exemplo n.º 3
0
 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')
Exemplo n.º 4
0
    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')
Exemplo n.º 5
0
    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')
Exemplo n.º 6
0
    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")
Exemplo n.º 7
0
    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')
Exemplo n.º 8
0
 def test_exclude_root(self):
     qs = get_tree_queryset(Country, include_root=False)
     self.assertEqual(len(qs), 256)
     self.assertEqual(qs[0].name, 'Africa')
Exemplo n.º 9
0
 def test_max_level_true(self):
     qs = get_tree_queryset(Country, max_level=True)
     self.assertEqual(len(qs), 8)
Exemplo n.º 10
0
 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')
Exemplo n.º 11
0
 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')
Exemplo n.º 12
0
 def test_default(self):
     qs = get_tree_queryset(Country)
     self.assertEqual(len(qs), 257)
     self.assertEqual(qs[0].name, 'root')