def setUp(self):
        self.user_id = unique_id()
        self.group1_name = unique_id()
        self.group2_name = unique_id()

        group1_data = {'name': self.group1_name}
        group2_data = {'name': self.group2_name}

        self.new_user_id = unique_id()
        self.old_user_data = {
            'first_name': 'first',
            'last_name': 'user',
            'userid': self.user_id,
            'groups': [self.group1_name]
        }
        self.new_user_data = {
            'first_name': 'second',
            'last_name': 'user',
            'userid': self.new_user_id,
            'groups': [self.group2_name]
        }
        create_group(group1_data)
        create_group(group2_data)

        create_user(self.old_user_data)
 def test_create_group_missing_name(self):
     group_name = unique_id()
     self.created_group_names.append(group_name)
     group_data = {
     }
     response = post(TEST_HOST, TEST_PORT, GROUPS_URL, group_data)
     self.assertEqual(response.status, 400)
 def setUp(self):
     self.group_name = unique_id()
     group_data = {
         'name': self.group_name
     }
     create_group(group_data)
     self.created_group_names = [self.group_name]
     self.created_user_ids = []
 def test_create_simple_group(self):
     group_name = unique_id()
     self.created_group_names.append(group_name)
     group_data = {
         'name': group_name
     }
     response = post(TEST_HOST, TEST_PORT, GROUPS_URL, group_data)
     self.assertEqual(response.status, 200)
 def test_create_group_existing_group(self):
     group_name = unique_id()
     self.created_group_names.append(group_name)
     group_data = {'name': group_name}
     response = post(TEST_HOST, TEST_PORT, GROUPS_URL, group_data)
     self.assertEqual(response.status, 200)
     response = post(TEST_HOST, TEST_PORT, GROUPS_URL, group_data)
     self.assertEqual(response.status, 400)
 def test_create_user_missing_groups(self):
     user_id = unique_id()
     self.created_user_ids.append(user_id)
     user_data = {
         'first_name': 'user',
         'last_name': 'lname',
         'userid': user_id
     }
     response = post(TEST_HOST, TEST_PORT, USERS_URL, user_data)
     self.assertEqual(response.status, 400)
 def test_create_user_missing_groups(self):
     user_id = unique_id()
     self.created_user_ids.append(user_id)
     user_data = {
         'first_name': 'user',
         'last_name': 'lname',
         'userid': user_id
     }
     response = post(TEST_HOST, TEST_PORT, USERS_URL, user_data)
     self.assertEqual(response.status, 400)
 def test_create_user_nonexisting_group(self):
     user_id = unique_id()
     self.created_user_ids.append(user_id)
     user_data = {
         'first_name': 'simple',
         'last_name': 'user',
         'userid': user_id,
         'groups': ['group32432']
     }
     response = post(TEST_HOST, TEST_PORT, USERS_URL, user_data)
     self.assertEqual(response.status, 500)
 def test_create_simple_user(self):
     user_id = unique_id()
     self.created_user_ids.append(user_id)
     user_data = {
         'first_name': 'simple',
         'last_name': 'user',
         'userid': user_id,
         'groups': ['group1', 'group2']
     }
     response = post(TEST_HOST, TEST_PORT, USERS_URL, user_data)
     self.assertEqual(response.status, 200)
 def setUp(self):
     self.group_name = unique_id()
     group_data = {'name': self.group_name}
     self.user_1_name = unique_id()
     self.user_2_name = unique_id()
     user_1_data = {
         'first_name': 'first',
         'last_name': 'user',
         'userid': self.user_1_name,
         'groups': [self.group_name]
     }
     user_2_data = {
         'first_name': 'second',
         'last_name': 'user',
         'userid': self.user_2_name,
         'groups': []
     }
     create_group(group_data)
     create_user(user_1_data)
     create_user(user_2_data)
 def setUp(self):
     self.group_name = unique_id()
     group_data = {'name': self.group_name}
     self.user_1_name = unique_id()
     self.user_2_name = unique_id()
     user_1_data = {
         'first_name': 'first',
         'last_name': 'user',
         'userid': self.user_1_name,
         'groups': [self.group_name]
     }
     user_2_data = {
         'first_name': 'second',
         'last_name': 'user',
         'userid': self.user_2_name,
         'groups': []
     }
     create_group(group_data)
     create_user(user_1_data)
     create_user(user_2_data)
 def test_create_user_existing_user(self):
     user_id = unique_id()
     self.created_user_ids.append(user_id)
     user_data = {
         'first_name': 'existing',
         'last_name': 'user',
         'userid': user_id,
         'groups': ['group1', 'group2']
     }
     response = post(TEST_HOST, TEST_PORT, USERS_URL, user_data)
     self.assertEqual(response.status, 200)
     response = post(TEST_HOST, TEST_PORT, USERS_URL, user_data)
     self.assertEqual(response.status, 400)
 def setUp(self):
     self.first_name = 'first_name'
     self.last_name = 'last_name'
     self.user_id = unique_id()
     self.groups = ['group1', 'group2']
     user_data = {
         'first_name': self.first_name,
         'last_name': self.last_name,
         'userid': self.user_id,
         'groups': self.groups
     }
     create_group({'name': 'group1'})
     create_group({'name': 'group2'})
     create_user(user_data)
     self.created_user_ids = [self.user_id]
 def setUp(self):
     self.first_name = 'first_name'
     self.last_name = 'last_name'
     self.user_id = unique_id()
     self.groups = ['group1', 'group2']
     user_data = {
         'first_name': self.first_name,
         'last_name': self.last_name,
         'userid': self.user_id,
         'groups': self.groups
     }
     create_group({'name': 'group1'})
     create_group({'name': 'group2'})
     create_user(user_data)
     self.created_user_ids = [self.user_id]
    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_create_user_bad_json(self):
     user_id = unique_id()
     self.created_user_ids.append(user_id)
     user_data = ''
     response = post(TEST_HOST, TEST_PORT, USERS_URL, user_data)
     self.assertEqual(response.status, 400)
Ejemplo n.º 17
0
 def setUp(self):
     self.group_name = unique_id()
     create_group({'name': self.group_name})
     self.created_group_names = [self.group_name]
 def test_create_user_bad_json(self):
     user_id = unique_id()
     self.created_user_ids.append(user_id)
     user_data = ''
     response = post(TEST_HOST, TEST_PORT, USERS_URL, user_data)
     self.assertEqual(response.status, 400)