Esempio n. 1
0
    def test_ping_yes(self):
        users = [
            ('yes', 'A', '*****@*****.**'),
            ('yes', 'B', '*****@*****.**'),
            ('yes', 'C', '*****@*****.**'),
            ('yes', 'D', '*****@*****.**'),
            ('no', 'E', '*****@*****.**'),
            ('no', 'F', '*****@*****.**'),
            ('no', 'G', '*****@*****.**'),
            ('no', 'H', '*****@*****.**'),
            ('maybe', 'W', '*****@*****.**'),
            ('maybe', 'X', '*****@*****.**'),
            ('maybe', 'Y', '*****@*****.**'),
            ('maybe', 'Z', '*****@*****.**'),
        ]
        for user in users:
            command = 'rsvp {response}'.format(response=user[0])
            sender_full_name = user[1]
            sender_email = user[2]
            self.issue_custom_command(
                command,
                sender_full_name=sender_full_name,
                sender_email=sender_email
            )

        users_dict = {email: name for (_, name, email) in users}

        # no actual zulip_client in tests, so we have to mock the response
        return_val = ZulipUsers('test_users_file.json')
        return_val.zulip_users = users_dict

        with patch.object(rsvp_commands.RSVPPingCommand,
                          'get_users_dict',
                          return_value=return_val):

            output = self.issue_command('rsvp ping')

        # yeses
        self.assertIn('@**A**', output[0]['body'])
        self.assertIn('@**B**', output[0]['body'])
        self.assertIn('@**C**', output[0]['body'])
        self.assertIn('@**D**', output[0]['body'])

        # maybes
        self.assertIn('@**W**', output[0]['body'])
        self.assertIn('@**X**', output[0]['body'])
        self.assertIn('@**Y**', output[0]['body'])
        self.assertIn('@**Z**', output[0]['body'])

        self.assertNotIn('@**E**', output[0]['body'])
        self.assertNotIn('@**F**', output[0]['body'])
        self.assertNotIn('@**G**', output[0]['body'])
        self.assertNotIn('@**H**', output[0]['body'])
Esempio n. 2
0
    def test_ping_yes(self):
        users = [
            ('yes', 'A', '*****@*****.**'),
            ('yes', 'B', '*****@*****.**'),
            ('yes', 'C', '*****@*****.**'),
            ('yes', 'D', '*****@*****.**'),
            ('no', 'E', '*****@*****.**'),
            ('no', 'F', '*****@*****.**'),
            ('no', 'G', '*****@*****.**'),
            ('no', 'H', '*****@*****.**'),
            ('maybe', 'W', '*****@*****.**'),
            ('maybe', 'X', '*****@*****.**'),
            ('maybe', 'Y', '*****@*****.**'),
            ('maybe', 'Z', '*****@*****.**'),
        ]
        for user in users:
            command = 'rsvp {response}'.format(response=user[0])
            sender_full_name = user[1]
            sender_email = user[2]
            self.issue_custom_command(
                command,
                sender_full_name=sender_full_name,
                sender_email=sender_email
            )

        users_dict = {email: name for (_, name, email) in users}

        # no actual zulip_client in tests, so we have to mock the response
        return_val = ZulipUsers('test_users_file.json')
        return_val.zulip_users = users_dict

        with patch.object(rsvp_commands.RSVPPingCommand,
                          'get_users_dict',
                          return_value=return_val):

            output = self.issue_command('rsvp ping')

        # yeses
        self.assertIn('@**A**', output[0]['body'])
        self.assertIn('@**B**', output[0]['body'])
        self.assertIn('@**C**', output[0]['body'])
        self.assertIn('@**D**', output[0]['body'])

        # maybes
        self.assertIn('@**W**', output[0]['body'])
        self.assertIn('@**X**', output[0]['body'])
        self.assertIn('@**Y**', output[0]['body'])
        self.assertIn('@**Z**', output[0]['body'])

        self.assertNotIn('@**E**', output[0]['body'])
        self.assertNotIn('@**F**', output[0]['body'])
        self.assertNotIn('@**G**', output[0]['body'])
        self.assertNotIn('@**H**', output[0]['body'])
Esempio n. 3
0
    def test_ping_message(self):
        self.issue_custom_command('rsvp yes', sender_full_name='A', sender_email='*****@*****.**')

        users_dict = {'*****@*****.**': 'A'}

        return_val = ZulipUsers('test_users_file.json')
        return_val.zulip_users = users_dict

        with patch.object(rsvp_commands.RSVPPingCommand,
                          'get_users_dict',
                          return_value=return_val):

            output = self.issue_command('rsvp ping message!!!')

        self.assertIn('@**A**', output[0]['body'])
        self.assertIn('message!!!', output[0]['body'])
Esempio n. 4
0
    def test_ping_message(self):
        self.issue_custom_command('rsvp yes', sender_full_name='A', sender_email='*****@*****.**')

        users_dict = {'*****@*****.**': 'A'}

        return_val = ZulipUsers('test_users_file.json')
        return_val.zulip_users = users_dict

        with patch.object(rsvp_commands.RSVPPingCommand,
                          'get_users_dict',
                          return_value=return_val):

            output = self.issue_command('rsvp ping message!!!')

        self.assertIn('@**A**', output[0]['body'])
        self.assertIn('message!!!', output[0]['body'])
Esempio n. 5
0
    def test_rsvp_ping_with_yes(self):
        self.issue_custom_command('rsvp yes', sender_full_name='B', sender_email='*****@*****.**')
        users_dict = {'*****@*****.**': 'B'}

        return_val = ZulipUsers('test_users_file.json')
        return_val.zulip_users = users_dict

        with patch.object(rsvp_commands.RSVPPingCommand,
                          'get_users_dict',
                          return_value=return_val):
            output = self.issue_command('rsvp ping we\'re all going to the yes concert')

        self.assertEqual(None, self.event['limit'])
        self.assertNotIn('@**Tester** is attending!', output[0]['body'])
        self.assertNotIn('*****@*****.**', self.event['no'])
        self.assertIn('@**B**', output[0]['body'])
        self.assertIn('we\'re all going to the yes concert', output[0]['body'])
Esempio n. 6
0
    def test_rsvp_ping_with_yes(self):
        self.issue_custom_command('rsvp yes', sender_full_name='B', sender_email='*****@*****.**')
        users_dict = {'*****@*****.**': 'B'}

        return_val = ZulipUsers('test_users_file.json')
        return_val.zulip_users = users_dict

        with patch.object(rsvp_commands.RSVPPingCommand,
                          'get_users_dict',
                          return_value=return_val):
            output = self.issue_command('rsvp ping we\'re all going to the yes concert')

        self.assertEqual(None, self.event['limit'])
        self.assertNotIn('@**Tester** is attending!', output[0]['body'])
        self.assertNotIn('*****@*****.**', self.event['no'])
        self.assertIn('@**B**', output[0]['body'])
        self.assertIn('we\'re all going to the yes concert', output[0]['body'])
Esempio n. 7
0
 def get_users_dict(self):
   return ZulipUsers()