コード例 #1
0
ファイル: test_models.py プロジェクト: HZ-labs/Rynda
class TestMessageCategories(unittest.TestCase):
    def setUp(self):
        self.message = MessageFactory(user=None)
        self.category = CategoryFactory()

    def tearDown(self):
        self.message.delete()
        self.category.delete()

    def test_add_category(self):
        before = len(self.message.category.all())
        self.message.category.add(self.category)
        self.assertEqual(len(self.message.category.all()), before + 1)

    def test_added_category_stored(self):
        self.message.category.add(self.category)
        m = Message.objects.get(id=self.message.pk)
        self.assertIn(self.category, m.category.all())

    def test_added_category_twice(self):
        before = len(self.message.category.all())
        self.message.category.add(self.category)
        self.message.category.add(self.category)
        self.assertEqual(len(self.message.category.all()), before + 1)

    def test_remove_category(self):
        self.message.category.add(self.category)
        before = self.message.category.count()
        self.message.category.remove(self.category)
        self.assertNotIn(self.category, self.message.category.all())
        self.assertEqual(self.message.category.count(), before - 1)
コード例 #2
0
ファイル: test_models.py プロジェクト: HZ-labs/Rynda
 def test_unlink_category(self):
     cat = CategoryFactory(group=self.group)
     cat.unlink()
     self.assertIsNone(cat.group)
     cat.delete()
コード例 #3
0
ファイル: test_models.py プロジェクト: HZ-labs/Rynda
 def test_category_unicoade(self):
     cat = CategoryFactory(group=self.group)
     self.assertEqual(cat.name, "%s" % cat)
     cat.delete()
コード例 #4
0
ファイル: test_models.py プロジェクト: HZ-labs/Rynda
 def test_unlinked_category(self):
     cat = CategoryFactory(group=None, subdomain=None)
     self.assertIsNotNone(cat)
     self.assertIsNone(cat.group)
     cat.delete()
コード例 #5
0
ファイル: test_models.py プロジェクト: HZ-labs/Rynda
 def test_category(self):
     cat = CategoryFactory(group=self.group)
     self.assertIsNotNone(cat)
     self.assertEqual(cat.group, self.group)
     cat.delete()
コード例 #6
0
ファイル: test_models.py プロジェクト: HZ-labs/Rynda
 def test_appeng_category(self):
     cat = CategoryFactory(group=None)
     self.group.add_category(cat)
     self.assertEqual(cat.group, self.group)
     cat.delete()