def test_term_parent_child(self):
        parent = WordPressTerm()
        parent.taxonomy = 'category'
        parent.name = 'Test Parent Term'

        parent_id = self.client.call(taxonomies.NewTerm(parent))
        self.assertTrue(parent_id)
        parent.id = parent_id

        child = WordPressTerm()
        child.taxonomy = parent.taxonomy
        child.name = 'Test Child Term'
        child.parent = parent.id

        child_id = self.client.call(taxonomies.NewTerm(child))
        self.assertTrue(child_id)
        child.id = child_id

        try:
            # re-fetch to verify
            child2 = self.client.call(taxonomies.GetTerm(child.taxonomy, child.id))
            self.assertEqual(child.parent, child2.parent)
        finally:
            # cleanup
            self.client.call(taxonomies.DeleteTerm(child.taxonomy, child.id))
            self.client.call(taxonomies.DeleteTerm(parent.taxonomy, parent.id))
    def test_term_search(self):
        tag1 = WordPressTerm()
        tag1.taxonomy = 'post_tag'
        tag1.name = 'Test FoobarA'

        tag1_id = self.client.call(taxonomies.NewTerm(tag1))
        self.assertTrue(tag1_id)
        tag1.id = tag1_id

        tag2 = WordPressTerm()
        tag2.taxonomy = 'post_tag'
        tag2.name = 'Test FoobarB'

        tag2_id = self.client.call(taxonomies.NewTerm(tag2))
        self.assertTrue(tag2_id)
        tag2.id = tag2_id

        try:
            results = self.client.call(taxonomies.GetTerms('post_tag', {'search': 'foobarb'}))
            found_tag1 = False
            found_tag2 = False
            for tag in results:
                if tag.id == tag1_id:
                    found_tag1 = True
                elif tag.id == tag2_id:
                    found_tag2 = True
            self.assertFalse(found_tag1)
            self.assertTrue(found_tag2)
        finally:
            # cleanup
            self.client.call(taxonomies.DeleteTerm(tag1.taxonomy, tag1.id))
            self.client.call(taxonomies.DeleteTerm(tag2.taxonomy, tag2.id))
Exemplo n.º 3
0
    def test_term_search(self):
        tag1 = WordPressTerm()
        tag1.taxonomy = 'post_tag'
        tag1.name = 'Test FoobarA'

        tag1_id = self.client.call(taxonomies.NewTerm(tag1))
        self.assertTrue(tag1_id)
        tag1.id = tag1_id

        tag2 = WordPressTerm()
        tag2.taxonomy = 'post_tag'
        tag2.name = 'Test FoobarB'

        tag2_id = self.client.call(taxonomies.NewTerm(tag2))
        self.assertTrue(tag2_id)
        tag2.id = tag2_id

        try:
            results = self.client.call(taxonomies.GetTerms('post_tag', {'search': 'foobarb'}))
            found_tag1 = False
            found_tag2 = False
            for tag in results:
                if tag.id == tag1_id:
                    found_tag1 = True
                elif tag.id == tag2_id:
                    found_tag2 = True
            self.assertFalse(found_tag1)
            self.assertTrue(found_tag2)
        finally:
            # cleanup
            self.client.call(taxonomies.DeleteTerm(tag1.taxonomy, tag1.id))
            self.client.call(taxonomies.DeleteTerm(tag2.taxonomy, tag2.id))
Exemplo n.º 4
0
    def test_term_parent_child(self):
        parent = WordPressTerm()
        parent.taxonomy = 'category'
        parent.name = 'Test Parent Term'

        parent_id = self.client.call(taxonomies.NewTerm(parent))
        self.assertTrue(parent_id)
        parent.id = parent_id

        child = WordPressTerm()
        child.taxonomy = parent.taxonomy
        child.name = 'Test Child Term'
        child.parent = parent.id

        child_id = self.client.call(taxonomies.NewTerm(child))
        self.assertTrue(child_id)
        child.id = child_id

        try:
            # re-fetch to verify
            child2 = self.client.call(taxonomies.GetTerm(child.taxonomy, child.id))
            self.assertEqual(child.parent, child2.parent)
        finally:
            # cleanup
            self.client.call(taxonomies.DeleteTerm(child.taxonomy, child.id))
            self.client.call(taxonomies.DeleteTerm(parent.taxonomy, parent.id))
    def test_category_post(self):
        # create a test post
        post = WordPressPost()
        post.title = 'Test Post'
        post.slug = 'test-post'
        post.user = self.userid
        post.id = self.client.call(posts.NewPost(post))

        # create a test category
        cat = WordPressTerm()
        cat.name = 'Test Category'
        cat.taxonomy = 'category'
        cat.id = self.client.call(taxonomies.NewTerm(cat))

        # set category on post
        try:
            post.terms = [cat]
            response = self.client.call(posts.EditPost(post.id, post))
            self.assertTrue(response)

            # fetch categories for the post to verify
            post2 = self.client.call(posts.GetPost(post.id, ['terms']))
            post_cats = post2.terms
            self.assert_list_of_classes(post_cats, WordPressTerm)
            self.assertEqual(post_cats[0].id, cat.id)
        finally:
            # cleanup
            self.client.call(taxonomies.DeleteTerm(cat.taxonomy, cat.id))
            self.client.call(posts.DeletePost(post.id))
    def test_category_lifecycle(self):
        # Create category object
        cat = WordPressTerm()
        cat.name = 'Test Category'
        cat.taxonomy = 'category'

        # Create the category in WordPress
        cat_id = self.client.call(taxonomies.NewTerm(cat))
        self.assertTrue(cat_id)
        cat.id = cat_id

        try:
            # Check that the new category shows in category suggestions
            suggestions = self.client.call(taxonomies.GetTerms('category', {'search': 'test'}))
            self.assertTrue(isinstance(suggestions, list))
            found = False
            for suggestion in suggestions:
                if suggestion.id == cat_id:
                    found = True
                    break
            self.assertTrue(found)
        finally:
            # Delete the category
            response = self.client.call(taxonomies.DeleteTerm(cat.taxonomy, cat.id))
            self.assertTrue(response)
    def test_term_lifecycle(self):
        term = WordPressTerm()
        term.name = 'Test Term'
        term.taxonomy = 'category'

        # create the term
        term_id = self.client.call(taxonomies.NewTerm(term))
        self.assertTrue(term_id)
        term.id = term_id

        # re-fetch to verify
        term2 = self.client.call(taxonomies.GetTerm(term.taxonomy, term.id))
        self.assertEqual(term.name, term2.name)

        # set a description and save
        term.description = "My test term"
        response = self.client.call(taxonomies.EditTerm(term.id, term))
        self.assertTrue(response)

        # re-fetch to verify
        term3 = self.client.call(taxonomies.GetTerm(term.taxonomy, term.id))
        self.assertEqual(term.description, term3.description)

        # delete the term
        response = self.client.call(taxonomies.DeleteTerm(term.taxonomy, term.id))
        self.assertTrue(response)
Exemplo n.º 8
0
    def test_term_lifecycle(self):
        term = WordPressTerm()
        term.name = 'Test Term'
        term.taxonomy = 'category'

        # create the term
        term_id = self.client.call(taxonomies.NewTerm(term))
        self.assertTrue(term_id)
        term.id = term_id

        # re-fetch to verify
        term2 = self.client.call(taxonomies.GetTerm(term.taxonomy, term.id))
        self.assertEqual(term.name, term2.name)

        # set a description and save
        term.description = "My test term"
        response = self.client.call(taxonomies.EditTerm(term.id, term))
        self.assertTrue(response)

        # re-fetch to verify
        term3 = self.client.call(taxonomies.GetTerm(term.taxonomy, term.id))
        self.assertEqual(term.description, term3.description)

        # delete the term
        response = self.client.call(taxonomies.DeleteTerm(term.taxonomy, term.id))
        self.assertTrue(response)
Exemplo n.º 9
0
    def test_category_post(self):
        # create a test post
        post = WordPressPost()
        post.title = 'Test Post'
        post.slug = 'test-post'
        post.user = self.userid
        post.id = self.client.call(posts.NewPost(post))

        # create a test category
        cat = WordPressTerm()
        cat.name = 'Test Category'
        cat.taxonomy = 'category'
        cat.id = self.client.call(taxonomies.NewTerm(cat))

        # set category on post
        try:
            post.terms = [cat]
            response = self.client.call(posts.EditPost(post.id, post))
            self.assertTrue(response)

            # fetch categories for the post to verify
            post2 = self.client.call(posts.GetPost(post.id, ['terms']))
            post_cats = post2.terms
            self.assert_list_of_classes(post_cats, WordPressTerm)
            self.assertEqual(post_cats[0].id, cat.id)
        finally:
            # cleanup
            self.client.call(taxonomies.DeleteTerm(cat.taxonomy, cat.id))
            self.client.call(posts.DeletePost(post.id))
Exemplo n.º 10
0
    def test_category_lifecycle(self):
        # Create category object
        cat = WordPressTerm()
        cat.name = 'Test Category'
        cat.taxonomy = 'category'

        # Create the category in WordPress
        cat_id = self.client.call(taxonomies.NewTerm(cat))
        self.assertTrue(cat_id)
        cat.id = cat_id

        try:
            # Check that the new category shows in category suggestions
            suggestions = self.client.call(
                taxonomies.GetTerms('category', {'search': 'test'}))
            self.assertTrue(isinstance(suggestions, list))
            found = False
            for suggestion in suggestions:
                if suggestion.id == cat_id:
                    found = True
                    break
            self.assertTrue(found)
        finally:
            # Delete the category
            response = self.client.call(
                taxonomies.DeleteTerm(cat.taxonomy, cat.id))
            self.assertTrue(response)
Exemplo n.º 11
0
 def create_taxonomy(self, parent_cat_id, name, taxonomy='category'):
     child_cat = WordPressTerm()
     child_cat.taxonomy = taxonomy
     if parent_cat_id:
         child_cat.parent = parent_cat_id
     child_cat.name = name
     child_cat.id = self.client.call(taxonomies.NewTerm(child_cat))
     return child_cat
Exemplo n.º 12
0
 def create_taxonomy(self, parent_cat_id, name, taxonomy='category'):
     child_cat = WordPressTerm()
     child_cat.taxonomy = taxonomy
     if parent_cat_id:
         child_cat.parent = parent_cat_id
     child_cat.name = name
     child_cat.id = self.client.call(taxonomies.NewTerm(child_cat))
     return child_cat
Exemplo n.º 13
0
 def checkCategorys(self):
     self.categorys = self.rpcClient.call(taxonomies.GetTerms('category'))      
     if len(self.categorys)<2:    
         for category in all_categorys:
             cat = WordPressTerm()
             cat.name = category
             cat.taxonomy = 'category'
             cat.id = self.rpcClient.call(taxonomies.NewTerm(cat))
         self.categorys = self.rpcClient.call(taxonomies.GetTerms('category'))
Exemplo n.º 14
0
 def checkCategorys(self):
     self.categorys = self.rpcClient.call(taxonomies.GetTerms('category'))
     if len(self.categorys) < 2:
         for category in all_categorys:
             cat = WordPressTerm()
             cat.name = category
             cat.taxonomy = 'category'
             cat.id = self.rpcClient.call(taxonomies.NewTerm(cat))
         self.categorys = self.rpcClient.call(
             taxonomies.GetTerms('category'))
Exemplo n.º 15
0
 def wrap_to_wp_category(self, taxonomy_tree):
     cat = WordPressTerm()
     cat.taxonomy = 'category'
     cat.parent = taxonomy_tree.parent.wp_id if taxonomy_tree.parent else None
     cat.id = taxonomy_tree.wp_id
     return cat
Exemplo n.º 16
0
 def wrap_to_wp_category(self, taxonomy_tree):        
     cat = WordPressTerm()
     cat.taxonomy = 'category'
     cat.parent = taxonomy_tree.parent.wp_id if taxonomy_tree.parent else None
     cat.id = taxonomy_tree.wp_id
     return cat