Exemplo n.º 1
0
    def test_application_message_title(self):
        author = UserFactory()
        group = GroupFactory(members=[author])
        applicant = UserFactory()
        application = ApplicationFactory(group=group, user=applicant)
        conversation = Conversation.objects.get_or_create_for_target(application)
        message = conversation.messages.create(author=author, content='bla')

        title = get_message_title(message, 'en')
        self.assertEqual(title, '❓ {} / {}'.format(applicant.display_name, author.display_name))

        application.accept(author)
        message.refresh_from_db()
        title = get_message_title(message, 'en')
        self.assertEqual(title, '✅ {} / {}'.format(applicant.display_name, author.display_name))

        application.decline(author)
        message.refresh_from_db()
        title = get_message_title(message, 'en')
        self.assertEqual(title, '❌ {} / {}'.format(applicant.display_name, author.display_name))

        application.withdraw()
        message.refresh_from_db()
        title = get_message_title(message, 'en')
        self.assertEqual(title, '🗑️ {} / {}'.format(applicant.display_name, author.display_name))

        message = conversation.messages.create(author=applicant, content='bla')
        message.refresh_from_db()
        title = get_message_title(message, 'en')
        self.assertEqual(title, '🗑️ {}'.format(applicant.display_name))
Exemplo n.º 2
0
    def test_issue_message_title(self):
        issue = IssueFactory()
        author = issue.group.members.first()
        conversation = issue.conversation
        message = conversation.messages.create(author=author, content='bla')

        title = get_message_title(message, 'en')
        self.assertIn('☹️', title)
Exemplo n.º 3
0
    def test_place_message_title(self):
        author = UserFactory()
        place = PlaceFactory()
        conversation = Conversation.objects.get_or_create_for_target(place)
        message = conversation.messages.create(author=author, content='bla')

        title = get_message_title(message, 'en')
        self.assertEqual(title, '{} / {}'.format(place.name, author.display_name))
Exemplo n.º 4
0
    def test_group_message_title(self):
        author = UserFactory()
        group = GroupFactory(members=[author])
        conversation = Conversation.objects.get_or_create_for_target(group)
        message = conversation.messages.create(author=author, content='bla')

        title = get_message_title(message, 'en')
        self.assertEqual(title, '{} / {}'.format(group.name, author.display_name))
Exemplo n.º 5
0
    def test_private_message_title(self):
        author = UserFactory()
        user = UserFactory()
        conversation = Conversation.objects.get_or_create_for_two_users(author, user)
        message = conversation.messages.create(author=author, content='bla')

        title = get_message_title(message, 'en')
        self.assertEqual(title, author.display_name)
Exemplo n.º 6
0
    def test_pickup_message_title(self):
        author = UserFactory()
        group = GroupFactory(members=[author], timezone='Europe/Berlin')
        place = PlaceFactory(group=group)
        pickup = PickupDateFactory(place=place, collectors=[author], date=to_range(parse('2018-11-11T20:00:00Z')))
        conversation = Conversation.objects.get_or_create_for_target(pickup)
        message = conversation.messages.create(author=author, content='bla')

        title = get_message_title(message, 'en')
        self.assertEqual(title, 'Pickup Sunday 9:00 PM / {}'.format(author.display_name))
Exemplo n.º 7
0
    def test_reply_message_title(self):
        author = UserFactory()
        group = GroupFactory(members=[author])
        conversation = Conversation.objects.get_or_create_for_target(group)
        message = conversation.messages.create(author=author, content='bla' * 10)
        reply = ConversationMessage.objects.create(
            author=author, conversation=conversation, thread=message, content='reply'
        )

        title = get_message_title(reply, 'en')
        self.assertEqual(title, 'blablablablabl… / {}'.format(author.display_name))
Exemplo n.º 8
0
    def test_activity_message_title(self):
        author = UserFactory()
        group = GroupFactory(members=[author], timezone='Europe/Berlin')
        place = PlaceFactory(group=group)
        activity = ActivityFactory(place=place, participants=[author], date=to_range(parse('2018-11-11T20:00:00Z')))
        conversation = Conversation.objects.get_or_create_for_target(activity)
        message = conversation.messages.create(author=author, content='bla')

        title = get_message_title(message, 'en')
        self.assertEqual(
            title, '{} Sunday 9:00 PM / {}'.format(activity.activity_type.get_translated_name(), author.display_name)
        )