Beispiel #1
0
    def test_search_single_result(self):
        user = {}

        def user_handler(u):
            user.update(u)

        bugzilla.BugzillaUser(search_strings='[email protected]', user_handler=user_handler).wait()

        self.assertEqual(user['email'], '*****@*****.**')
        self.assertEqual(user['name'], '*****@*****.**')
        self.assertEqual(user['real_name'], 'Nobody; OK to take it and work on it')
Beispiel #2
0
    def test_get_user_array(self):
        user = {}

        def user_handler(u):
            user.update(u)

        bugzilla.BugzillaUser(user_names=['*****@*****.**'], user_handler=user_handler).wait()

        self.assertEqual(user['email'], '*****@*****.**')
        self.assertEqual(user['name'], '*****@*****.**')
        self.assertEqual(user['real_name'], 'Nobody; OK to take it and work on it')
Beispiel #3
0
    def test_get_user_include_fields(self):
        user = {}
        user_data = {}

        def user_handler(u, data):
            user.update(u)
            data.update(u)

        bugzilla.BugzillaUser(user_names='*****@*****.**', include_fields=['email', 'real_name'], user_handler=user_handler, user_data=user_data).wait()

        self.assertEqual(user['email'], '*****@*****.**')
        self.assertEqual(user['real_name'], 'Nobody; OK to take it and work on it')
        self.assertNotIn('name', user)
        self.assertNotIn('id', user)
        self.assertEqual(user, user_data)
Beispiel #4
0
    def test_get_users_ids(self):
        user = {
            'first': {},
            'second': {},
        }

        def user_handler(u):
            if u['id'] == 1:
                user['first'].update(u)
            elif u['id'] == 208267:
                user['second'].update(u)
            else:
                raise Exception('Unexpected ID')

        bugzilla.BugzillaUser(user_names=['1', 208267], user_handler=user_handler).wait()

        self.assertEqual(user['first']['email'], '*****@*****.**')
        self.assertEqual(user['first']['name'], '*****@*****.**')
        self.assertEqual(user['first']['real_name'], 'Nobody; OK to take it and work on it')
        self.assertEqual(user['second']['email'], '*****@*****.**')
        self.assertEqual(user['second']['name'], '*****@*****.**')
        self.assertEqual(user['second']['real_name'], 'bugbot on irc.mozilla.org')
Beispiel #5
0
    def test_search_multiple_queries(self):
        users = []

        def user_handler(u):
            users.append(u)

        bugzilla.BugzillaUser(search_strings=['[email protected]', '[email protected]'], user_handler=user_handler).wait()

        foundNobody1 = False
        foundNobody2 = False
        for user in users:
            if user['email'] == '*****@*****.**':
                self.assertFalse(foundNobody1)
                foundNobody1 = True
                self.assertEqual(user['name'], '*****@*****.**')
                self.assertEqual(user['real_name'], 'Nobody; OK to take it and work on it')
            elif user['email'] == '*****@*****.**':
                self.assertFalse(foundNobody2)
                foundNobody2 = True
                self.assertEqual(user['name'], '*****@*****.**')
                self.assertEqual(user['real_name'], 'Nobody; OK to take it and work on it')

        self.assertTrue(foundNobody1)
        self.assertTrue(foundNobody2)