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 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
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