def test_get_created_group(self): response = get_or_delete('GET', TEST_HOST, TEST_PORT, GROUPS_URL, self.group_name) response_string = response.read().decode() response_json = json.loads(response_string) self.assertEqual(response.status, 200) self.assertTrue('userids' in response_json) self.assertEqual(response_json['userids'], [])
def test_delete_user(self): response = get_user(self.user_id) self.assertEqual(response.status, 200) response = get_or_delete('DELETE', TEST_HOST, TEST_PORT, USERS_URL, self.user_id) self.assertEqual(response.status, 200) response = get_user(self.user_id) self.assertEqual(response.status, 404)
def test_delete_group(self): response = get_group(self.group_name) self.assertEqual(response.status, 200) response = get_or_delete('DELETE', TEST_HOST, TEST_PORT, GROUPS_URL, self.group_name) self.assertEqual(response.status, 200) response = get_group(self.group_name) self.assertEqual(response.status, 404)
def test_get_created_user(self): response = get_or_delete('GET', TEST_HOST, TEST_PORT, USERS_URL, self.user_id) response_string = response.read().decode() response_json = json.loads(response_string) self.assertEqual(response.status, 200) self.assertTrue('first_name' in response_json) self.assertTrue('last_name' in response_json) self.assertTrue('userid' in response_json) self.assertTrue('groups' in response_json) self.assertEqual(self.first_name, response_json['first_name']) self.assertEqual(self.last_name, response_json['last_name']) self.assertEqual(self.user_id, response_json['userid']) self.assertEqual(self.groups, response_json['groups'])
def test_get_created_user(self): response = get_or_delete('GET', TEST_HOST, TEST_PORT, USERS_URL, self.user_id) response_string = response.read().decode() response_json = json.loads(response_string) self.assertEqual(response.status, 200) self.assertTrue('first_name' in response_json) self.assertTrue('last_name' in response_json) self.assertTrue('userid' in response_json) self.assertTrue('groups' in response_json) self.assertEqual(self.first_name, response_json['first_name']) self.assertEqual(self.last_name, response_json['last_name']) self.assertEqual(self.user_id, response_json['userid']) self.assertEqual(self.groups, response_json['groups'])
def test_get_group_with_users(self): user_id = unique_id() self.created_user_ids.append(user_id) user_data = { 'first_name': 'simple', 'last_name': 'user', 'userid': user_id, 'groups': [self.group_name] } create_user(user_data) response = get_or_delete('GET', TEST_HOST, TEST_PORT, GROUPS_URL, self.group_name) response_string = response.read().decode() response_json = json.loads(response_string) self.assertEqual(response.status, 200) self.assertTrue('userids' in response_json) self.assertEqual(response_json['userids'], [user_id])
def test_delete_user_no_userid(self): response = get_or_delete('DELETE', TEST_HOST, TEST_PORT, USERS_URL, '') self.assertEqual(response.status, 405)
def test_delete_missing_user(self): response = get_or_delete('DELETE', TEST_HOST, TEST_PORT, USERS_URL, 'foobar') self.assertEqual(response.status, 404)
def test_get_group_no_name(self): response = get_or_delete('GET', TEST_HOST, TEST_PORT, GROUPS_URL, '') self.assertEqual(response.status, 405)
def test_get_nonexistent_group(self): response = get_or_delete('GET', TEST_HOST, TEST_PORT, GROUPS_URL, 'foobar') response_string = response.read().decode() self.assertEqual(response.status, 404)
def test_delete_missing_group(self): response = get_or_delete('DELETE', TEST_HOST, TEST_PORT, GROUPS_URL, 'foobar') self.assertEqual(response.status, 404)
def test_get_user_no_userid(self): response = get_or_delete('GET', TEST_HOST, TEST_PORT, USERS_URL, '') self.assertEqual(response.status, 405)