def test_user_roles(self):
    user_PHID = 'PHID-USER-abcdef'

    def assert_user_search_called():
        return self.phab.user.search.assert_called_with(constraints={'phids': [user_PHID]})
    user_roles = self.phab.get_user_roles(user_PHID)
    assert_user_search_called()
    self.assertEqual(user_roles, [])
    self.phab.user.search.return_value = test.mocks.phabricator.Result([{'id': 1, 'type': 'USER', 'phid': user_PHID, 'fields': {'username': 'foobar', 'realName': 'Foo Bar', 'roles': ['admin', 'verified', 'approved', 'activated'], 'dateCreated': 0, 'dateModified': 0, 'custom.abc:slack-username': 'Foobar'}}])
    user_roles = self.phab.get_user_roles(user_PHID)
    assert_user_search_called()
    self.assertEqual(user_roles, ['admin', 'verified', 'approved', 'activated'])
    self.phab.user.search.return_value = test.mocks.phabricator.Result([{'id': 1, 'type': 'USER', 'phid': user_PHID, 'fields': {'roles': ['verified']}}, {'id': 2, 'type': 'USER', 'phid': user_PHID, 'fields': {'roles': ['admin']}}])
    user_roles = self.phab.get_user_roles(user_PHID)
    assert_user_search_called()
    self.assertEqual(user_roles, [])
def test_user_roles(self):
    user_PHID = 'PHID-USER-abcdef'

    def assert_user_search_called():
        return self.phab.user.search.assert_called_with(constraints={'phids': [user_PHID]})
    user_roles = self.phab.get_user_roles(user_PHID)
    assert_user_search_called()
    self.assertEqual(user_roles, [])
    self.phab.user.search.return_value = test.mocks.phabricator.Result([{'id': 1, 'type': 'USER', 'phid': user_PHID, 'fields': {'username': 'foobar', 'realName': 'Foo Bar', 'roles': ['admin', 'verified', 'approved', 'activated'], 'dateCreated': 0, 'dateModified': 0, 'custom.abc:slack-username': 'Foobar'}}])
    user_roles = self.phab.get_user_roles(user_PHID)
    assert_user_search_called()
    self.assertEqual(user_roles, ['admin', 'verified', 'approved', 'activated'])
    self.phab.user.search.return_value = test.mocks.phabricator.Result([{'id': 1, 'type': 'USER', 'phid': user_PHID, 'fields': {'roles': ['verified']}}, {'id': 2, 'type': 'USER', 'phid': user_PHID, 'fields': {'roles': ['admin']}}])
    user_roles = self.phab.get_user_roles(user_PHID)
    assert_user_search_called()
    self.assertEqual(user_roles, [])