Esempio n. 1
0
 def testCategory(self):
     '''Test the Category object.'''
     SOCIAL_CATEGORY_TITLE = 'Social eCommerce'
     
     self.deleteTestHierarchy()
     self.assertEquals(Hierarchy.objects.all().count(), 0)
     self.assertEquals(Category.objects.all().count(), 0)
          
     blog_space = Space.objects.filter(name=self.TEST_HIERARCHY_TITLE)[0]
     
     test_hierarchy_filter = Hierarchy.objects.filter(name=self.TEST_HIERARCHY_TITLE)
     if test_hierarchy_filter.count() == 0:
         test_hierarchy = Hierarchy(name=self.TEST_HIERARCHY_TITLE, slug=self.TEST_HIERARCHY_SLUG, space=blog_space)
         test_hierarchy.save()
     else:
         test_hierarchy = test_hierarchy_filter[0]
                 
     ecommerce_space = Space.objects.filter(name='eCommerce')[0]
     social_space = Space.objects.filter(name='Social eCommerce')[0]
     plugins_space = Space.objects.filter(name='eCommerce Plugins')[0]
     
     hierarchy = Hierarchy.objects.filter(name=self.TEST_HIERARCHY_TITLE)[0]
             
     ecommerce_category = Category(hierarchy=hierarchy, name='eCommerce', slug='ecommerce', space=ecommerce_space)
     ecommerce_category.save()
     
     plugins_category = Category(hierarchy=hierarchy, parent=ecommerce_category, name='eCommerce Plugins', slug='ecommerce-plugins', space=plugins_space)
     plugins_category.save()
     
     social_category = Category(hierarchy=hierarchy, parent=ecommerce_category, name=SOCIAL_CATEGORY_TITLE, slug='social-ecommerce', space=social_space)
     social_category.save()
     
     # get_all_children
     self.assertEquals(len(ecommerce_category.get_all_children()), 2L)
     self.assertEquals(len(social_category.get_all_children()), 0)
     
     # get_top_content
     # TODO
     
     # get_templates
     self.assertEquals(plugins_category.get_templates()[0], 'categories/blog/ecommerce/ecommerce-plugins/detail.html')
     
     # breadcrumbs
     self.assertEquals(plugins_category.breadcrumbs()[0]['url'], '/blog/')
     self.assertEquals(plugins_category.breadcrumbs()[0]['name'], 'Blog')
     self.assertEquals(plugins_category.breadcrumbs()[1]['url'], '/blog/ecommerce/')
     self.assertEquals(plugins_category.breadcrumbs()[1]['name'], 'eCommerce')
                                                         
     # absolute URL, template used
     response = self.client.get(social_category.get_absolute_url())
     self.assertContains(response, SOCIAL_CATEGORY_TITLE)
     self.assertTemplateUsed(response, 'categories/detail.html')
Esempio n. 2
0
    def testHierarchy(self):
        '''Test the Hierarchy object.'''
        self.deleteTestHierarchy()
        self.assertEquals(Hierarchy.objects.all().count(), 0)

        blog_space = Space.objects.filter(name='Blog')[0]

        test_hierarchy = Hierarchy(name=self.TEST_HIERARCHY_TITLE,
                                   slug=self.TEST_HIERARCHY_SLUG,
                                   space=blog_space)
        test_hierarchy.save()

        self.assertEquals(
            test_hierarchy.get_templates()[0],
            'hierarchies/%s/detail.html' % self.TEST_HIERARCHY_SLUG)
        self.assertEquals(test_hierarchy.get_templates()[1],
                          'hierarchies/detail.html')
        self.assertEquals(test_hierarchy.get_absolute_url(),
                          '/%s/' % self.TEST_HIERARCHY_SLUG)

        response = self.client.get(test_hierarchy.get_absolute_url())
        self.assertContains(response, self.TEST_HIERARCHY_TITLE)
        self.assertTemplateUsed(response, 'hierarchies/detail.html')

        self.deleteTestHierarchy()
Esempio n. 3
0
    def testHierarchy(self):
        '''Test the Hierarchy object.'''
        self.deleteTestHierarchy()
        self.assertEquals(Hierarchy.objects.all().count(), 0)
                
        blog_space = Space.objects.filter(name='Blog')[0]

        test_hierarchy = Hierarchy(name=self.TEST_HIERARCHY_TITLE, slug=self.TEST_HIERARCHY_SLUG, space=blog_space)
        test_hierarchy.save()
                
        self.assertEquals(test_hierarchy.get_templates()[0], 'hierarchies/%s/detail.html' % self.TEST_HIERARCHY_SLUG)
        self.assertEquals(test_hierarchy.get_templates()[1], 'hierarchies/detail.html')
        self.assertEquals(test_hierarchy.get_absolute_url(), '/%s/' % self.TEST_HIERARCHY_SLUG)
        
        response = self.client.get(test_hierarchy.get_absolute_url())
        self.assertContains(response, self.TEST_HIERARCHY_TITLE)
        self.assertTemplateUsed(response, 'hierarchies/detail.html')
        
        self.deleteTestHierarchy()    
Esempio n. 4
0
    def testCategory(self):
        '''Test the Category object.'''
        SOCIAL_CATEGORY_TITLE = 'Social eCommerce'

        self.deleteTestHierarchy()
        self.assertEquals(Hierarchy.objects.all().count(), 0)
        self.assertEquals(Category.objects.all().count(), 0)

        blog_space = Space.objects.filter(name=self.TEST_HIERARCHY_TITLE)[0]

        test_hierarchy_filter = Hierarchy.objects.filter(
            name=self.TEST_HIERARCHY_TITLE)
        if test_hierarchy_filter.count() == 0:
            test_hierarchy = Hierarchy(name=self.TEST_HIERARCHY_TITLE,
                                       slug=self.TEST_HIERARCHY_SLUG,
                                       space=blog_space)
            test_hierarchy.save()
        else:
            test_hierarchy = test_hierarchy_filter[0]

        ecommerce_space = Space.objects.filter(name='eCommerce')[0]
        social_space = Space.objects.filter(name='Social eCommerce')[0]
        plugins_space = Space.objects.filter(name='eCommerce Plugins')[0]

        hierarchy = Hierarchy.objects.filter(name=self.TEST_HIERARCHY_TITLE)[0]

        ecommerce_category = Category(hierarchy=hierarchy,
                                      name='eCommerce',
                                      slug='ecommerce',
                                      space=ecommerce_space)
        ecommerce_category.save()

        plugins_category = Category(hierarchy=hierarchy,
                                    parent=ecommerce_category,
                                    name='eCommerce Plugins',
                                    slug='ecommerce-plugins',
                                    space=plugins_space)
        plugins_category.save()

        social_category = Category(hierarchy=hierarchy,
                                   parent=ecommerce_category,
                                   name=SOCIAL_CATEGORY_TITLE,
                                   slug='social-ecommerce',
                                   space=social_space)
        social_category.save()

        # get_all_children
        self.assertEquals(len(ecommerce_category.get_all_children()), 2L)
        self.assertEquals(len(social_category.get_all_children()), 0)

        # get_top_content
        # TODO

        # get_templates
        self.assertEquals(
            plugins_category.get_templates()[0],
            'categories/blog/ecommerce/ecommerce-plugins/detail.html')

        # breadcrumbs
        self.assertEquals(plugins_category.breadcrumbs()[0]['url'], '/blog/')
        self.assertEquals(plugins_category.breadcrumbs()[0]['name'], 'Blog')
        self.assertEquals(plugins_category.breadcrumbs()[1]['url'],
                          '/blog/ecommerce/')
        self.assertEquals(plugins_category.breadcrumbs()[1]['name'],
                          'eCommerce')

        # absolute URL, template used
        response = self.client.get(social_category.get_absolute_url())
        self.assertContains(response, SOCIAL_CATEGORY_TITLE)
        self.assertTemplateUsed(response, 'categories/detail.html')