示例#1
0
 def get_dependencies(self, instance):
     '''
     Filter the dependencies because contenttype and permission are automagically created by django
     '''
     deps = get_dependencies(instance)
     if self.exclude_content_type:
         deps = [d for d in deps if not isinstance(
             d, (ContentType, Permission))]
     return deps
示例#2
0
 def get_objects_with_deps(self):
     from dev_db.dependencies import get_dependencies
     objects = self.get_objects()
     deps = []
     for object_ in objects:
         deps += get_dependencies(object_)
     objects += deps
     objects = self.cleanup(objects)
     return objects
示例#3
0
 def get_objects_with_deps(self):
     from dev_db.dependencies import get_dependencies
     objects = self.get_objects()
     deps = []
     for object_ in objects:
         deps += get_dependencies(object_)
     objects += deps
     objects = self.cleanup(objects)
     return objects
示例#4
0
 def get_dependencies(self, instance):
     '''
     Filter the dependencies because contenttype and permission are automagically created by django
     '''
     deps = get_dependencies(instance)
     if self.exclude_content_type:
         deps = [
             d for d in deps if not isinstance(d, (ContentType, Permission))
         ]
     return deps
示例#5
0
    def test_dependency_lookup_site(self):
        '''
        Expected output is a sorted list like

        Site Category, Site, User, Entity, Love

        '''
        from core.models import Site, SiteCategory
        site = Site.objects.all()[:1][0]
        # check the recursive approach
        dependencies = get_dependencies(site)
        correct_deps = [site.category, site]
        self.assertEqual(correct_deps, dependencies)
示例#6
0
    def test_dependency_lookup_site(self):
        '''
        Expected output is a sorted list like

        Site Category, Site, User, Entity, Love

        '''
        from core.models import Site, SiteCategory
        site = Site.objects.all()[:1][0]
        # check the recursive approach
        dependencies = get_dependencies(site)
        correct_deps = [site.category, site]
        self.assertEqual(correct_deps, dependencies)
示例#7
0
    def test_dependency_lookup_item(self):
        '''
        Expected output is a sorted list like

        Site Category, Site, User, Entity, Love

        '''
        from core.models import Item
        instance = Item.objects.all()[:1][0]
        # check the recursive approach
        dependencies = get_dependencies(instance)
        correct_deps = list(instance.tags.all())[::-1] + [instance.user,
                                                          instance.site.category, instance.site, instance]
        self.assertEqual(dependencies, correct_deps)
示例#8
0
    def test_dependency_lookup_item(self):
        '''
        Expected output is a sorted list like

        Site Category, Site, User, Entity, Love

        '''
        from core.models import Item
        instance = Item.objects.all()[:1][0]
        # check the recursive approach
        dependencies = get_dependencies(instance)
        correct_deps = list(instance.tags.all())[::-1] + [
            instance.user, instance.site.category, instance.site, instance
        ]
        self.assertEqual(dependencies, correct_deps)
示例#9
0
 def test_recursion(self):
     from core.models import Post
     post = Post.objects.get(pk=1)
     deps = get_dependencies(post)
     correct_deps = [post, post.blogger, post]
     self.assertEqual(correct_deps, deps)
示例#10
0
 def test_recursion(self):
     from core.models import Post
     post = Post.objects.get(pk=1)
     deps = get_dependencies(post)
     correct_deps = [post, post.blogger, post]
     self.assertEqual(correct_deps, deps)