def testCreateSynonymUsingFieldCallback(self):
        tag = Tag.objects.create(name='hello')
        Synonym.objects.create(name='aloha', tag=tag)
        self.assertEquals(['hello', 'world'], replace_synonyms(['aloha', 'world']))

        Synonym.objects.all().delete()
        self.assertEqual(0, len(Synonym.objects.all()))
        test_item = TestItemWithCallback(title='Test callbacks', tags='Test, Create Callbacks')
        test_item.save()
        second_item = TestItemWithCallback(title='Another test', tags='Test')
        second_item.save()

        synonyms = Synonym.objects.all()
        self.assertEqual(2, len(synonyms))
        self.assertEqual('create-callbacks', synonyms[0].name)
        self.assertEqual('test', synonyms[1].name)

        objs = TaggedItem.objects.get_by_model(TestItemWithCallback, ['create-callbacks'])
        self.assertEqual(1, len(objs))
        self.assertEqual('Test callbacks', objs[0].title)
示例#2
0
    def testCreateSynonymUsingFieldCallback(self):
        tag = Tag.objects.create(name='hello')
        Synonym.objects.create(name='aloha', tag=tag)
        self.assertEquals(['hello', 'world'],
                          replace_synonyms(['aloha', 'world']))

        Synonym.objects.all().delete()
        self.assertEqual(0, len(Synonym.objects.all()))
        test_item = TestItemWithCallback(title='Test callbacks',
                                         tags='Test, Create Callbacks')
        test_item.save()
        second_item = TestItemWithCallback(title='Another test', tags='Test')
        second_item.save()

        synonyms = Synonym.objects.all()
        self.assertEqual(2, len(synonyms))
        self.assertEqual('create-callbacks', synonyms[0].name)
        self.assertEqual('test', synonyms[1].name)

        objs = TaggedItem.objects.get_by_model(TestItemWithCallback,
                                               ['create-callbacks'])
        self.assertEqual(1, len(objs))
        self.assertEqual('Test callbacks', objs[0].title)
 def testReplaceSynonyms(self):
     tag = Tag.objects.create(name='hello')
     Synonym.objects.create(name='aloha', tag=tag)
     self.assertEquals(['hello', 'world'], replace_synonyms(['aloha', 'world']))
示例#4
0
 def testReplaceSynonyms(self):
     tag = Tag.objects.create(name='hello')
     Synonym.objects.create(name='aloha', tag=tag)
     self.assertEquals(['hello', 'world'],
                       replace_synonyms(['aloha', 'world']))