def testlistTrialUsers(self, m): """testadmintoken check that we have an admin token""" response = { "role_assignments": [ {"user": {"id": "0f4de1ea94d342e696f3f61320c15253"}, "links": {"assignment": "http://aurl.com/abc"} }, {"user": {"id": "24396976a1b84eafa5347c3f9818a66a"}, "links": {"assignment": "http://a.com"} }, {"user": {"id": "24cebaa9b665426cbeab579f1a3ac733"}, "links": {"assignment": "http://b.com"} }, {"user": {"id": "zippitelli"}, "links": {"assignment": "http://c.com"} } ], "links": {"self": "http://d.com"} } m.get(requests_mock.ANY, json=response) expiredusers = ExpiredUsers('any tenant id', 'any username', 'any password') expiredusers.token = 'a token' expiredusers.get_list_trial_users() result = expiredusers.gerlisttrialusers() expectedresult = ['0f4de1ea94d342e696f3f61320c15253', '24396976a1b84eafa5347c3f9818a66a', '24cebaa9b665426cbeab579f1a3ac733', 'zippitelli'] self.assertEqual(expectedresult, result)
def testlistTrialUsersWithNoAdminToken(self, m): """testlistTrialUsersWithNoAdminToken check that we have an admin token""" expiredusers = ExpiredUsers('any tenant id', 'any username', 'any password') # There was no users in the list expiredusers.token = "" expectedmessage = "Error, you need to have an admin token. Execute the get_admin_token() method previously." try: expiredusers.get_list_trial_users() except ValueError as e: self.assertEqual(e.message, expectedmessage)