def test_no_cluster_same_category_on_original_category(self): article = ArticleController().read(category_id__ne=None).first() art_cat_id = article.category_id cat_ctrl = CategoryController(article.user_id) cluster = article.cluster feed = FeedController(cluster.user_id).create(title='new feed', category_id=art_cat_id) update_on_all_objs(articles=cluster.articles, feeds=[feed], cluster_same_category=None, cluster_enabled=True) cat_ctrl.update({'id': art_cat_id}, {'cluster_same_category': False}) article = self.create_article_from(cluster, feed) self.assertNotInCluster(article, cluster) cat_ctrl.update({'id': art_cat_id}, {'cluster_same_category': True}) article = self.create_article_from(cluster, feed) self.assertInCluster(article, cluster)
def put(category_id): """Update an existing category.""" cctrl = CategoryController(current_identity.id) attrs = parse_meaningful_params(parser_edit) if attrs: changed = cctrl.update({'id': category_id}, attrs) if not changed: cctrl.assert_right_ok(category_id) return None, 204
def test_cluster_disabled_on_original_category(self): article = ArticleController().read(category_id__ne=None).first() art_cat_id = article.category_id cat_ctrl = CategoryController(article.user_id) cluster = article.cluster fctrl = FeedController(cluster.user_id) feed = fctrl.create(title='new feed', category_id=art_cat_id) fno_cat = fctrl.create(title='category-less') update_on_all_objs(users=[cluster.user], cluster_enabled=None) cat_ctrl.update({}, {'cluster_enabled': False}) article = self.create_article_from(cluster, feed) self.assertEqual(1, len(article.cluster.articles)) self.assertNotInCluster(article, cluster) article = self.create_article_from(cluster, fno_cat) self.assertEqual(1, len(article.cluster.articles)) self.assertNotInCluster(article, cluster) cat_ctrl.update({'id': art_cat_id}, {'cluster_enabled': True}) article = self.create_article_from(cluster, fno_cat) self.assertEqual(2, len(article.cluster.articles)) self.assertInCluster(article, cluster) article = self.create_article_from(cluster, feed) self.assertEqual(3, len(article.cluster.articles)) self.assertInCluster(article, cluster)