def test_custom_case(self): """FORCE_LOWERCASE setting is off """ askbot_settings.update('FORCE_LOWERCASE_TAGS', False) models.Tag(name='TAG1', created_by=self.user).save() models.Tag(name='Tag2', created_by=self.user).save() cleaned_tags = self.clean('tag1 taG2 TAG1 tag3 tag3') self.assert_tags_equal(cleaned_tags, ['TAG1', 'Tag2', 'tag3'])
def test_tag_based_subscription_on_new_question_works2(self): """someone subscribes for an pre-existing tag then another user asks a question with that tag and the subcriber receives an alert """ models.Tag( name = 'something', created_by = self.user1 ).save() self.user1.email_tag_filter_strategy = const.INCLUDE_SUBSCRIBED self.user1.save() self.user1.mark_tags( tagnames = ('something',), reason = 'subscribed', action = 'add' ) self.user2.post_question( title = 'some title', body_text = 'some text for the question', tags = 'something' ) outbox = django.core.mail.outbox self.assertEqual(len(outbox), 1) self.assertEqual(len(outbox[0].recipients()), 1) self.assertTrue( self.user1.email in outbox[0].recipients() )
def test_user_does_not_care_about_question_no_wildcards(self): askbot_settings.update('USE_WILDCARD_TAGS', False) tag = models.Tag(name='five', created_by=self.user) tag.save() mt = models.MarkedTag(user=self.user, tag=tag, reason='good') mt.save() self.assertFalse( self.user.has_affinity_to_question(question=self.question, affinity_type='like'))
def create_tag(self, tag_name, user=None): """creates a user, b/c it is necessary""" if user is None: try: user = models.User.objects.get(username='******') except models.User.DoesNotExist: user = self.create_user('tag_creator') tag = models.Tag(created_by=user, name=tag_name, language_code='en') tag.save() return tag