コード例 #1
0
ファイル: merge.py プロジェクト: ppp0/openbroadcast
    def testMergeTagsCreatesSynonyms(self):
        first = TestItem(title = 'first', tags = 'one, two')
        first.save()
        second = TestItem(title = 'second', tags = 'second')
        second.save()

        self.assertEqual([], [s.name for s in get_tag('two').synonyms.all()])

        ctype = model_to_ctype(TestItem)
        merge('two', 'second', ctype)

        self.assertEqual(['second'], [s.name for s in get_tag('two').synonyms.all()])
コード例 #2
0
ファイル: merge.py プロジェクト: ppp0/openbroadcast
    def testMergeTagsWhenSynonymAlreadyExists(self):
        first = TestItem(title = 'first', tags = 'one, two, blah')
        first.save()
        second = TestItem(title = 'second', tags = 'second')
        second.save()
        blah = get_tag('blah')
        blah.synonyms.create(name='second')

        self.assertEqual([], [s.name for s in get_tag('two').synonyms.all()])

        ctype = model_to_ctype(TestItem)
        merge('two', 'second', ctype)

        self.assertEqual([], [s.name for s in get_tag('two').synonyms.all()])
        self.assertEqual(['second'], [s.name for s in get_tag('blah').synonyms.all()])
コード例 #3
0
ファイル: merge.py プロジェクト: ppp0/openbroadcast
    def testMergeTagsDeletesSecondTagIfNoMoreTaggedItems(self):
        self.assertEqual(0, Tag.objects.count())
        self.assertEqual(0, TaggedItem.objects.count())
        self.assertEqual(0, Synonym.objects.count())

        first = TestItem(title = 'first', tags = 'one, two')
        first.save()
        second = TestItem(title = 'second', tags = 'second')
        second.save()

        self.assertEqual(1, len(with_tag('one')))
        self.assertEqual(1, len(with_tag('two')))
        self.assertEqual(1, len(with_tag('second')))

        ctype = model_to_ctype(TestItem)
        merge('two', 'second', ctype)

        self.assertEqual(1, len(with_tag('one')))
        self.assertEqual(2, len(with_tag('two')))
        self.assertRaises(Tag.DoesNotExist, Tag.objects.get, name = 'second')
コード例 #4
0
ファイル: merge.py プロジェクト: ppp0/openbroadcast
    def testMergeTagsNotDeletesSecondTag(self):
        self.assertEqual(0, Tag.objects.count())
        self.assertEqual(0, TaggedItem.objects.count())
        self.assertEqual(0, Synonym.objects.count())

        first = TestItem(title = 'first', tags = 'one, two')
        first.save()
        second = TestItem(title = 'second', tags = 'second')
        second.save()
        third = TestItemWithCallback(title = 'third', tags = 'second')
        third.save()

        self.assertEqual(1, len(with_tag('second')))
        self.assertEqual(1, len(with_tag('second', TestItemWithCallback)))

        ctype = model_to_ctype(TestItem)
        merge('two', 'second', ctype)

        self.assertEqual(0, len(with_tag('second')))
        self.assertEqual(1, len(with_tag('second', TestItemWithCallback)))
        self.assert_(Tag.objects.get(name = 'second'))