예제 #1
0
    def test_post(self):
        data = dict(username='******',
                    first_name='',
                    last_name='',
                    middle_initials='',
                    password='******',
                    email='*****@*****.**',
                    active=True,
                    rolename='User',
                    package='Standard package')

        # add
        response = self.admin_open(method='POST', json=data)
        self.assert200(response)
        user = User.get(data['username']).to_dict(full=True)
        user['join_date'] = user['join_date'].replace(
            tzinfo=pytz.utc).isoformat()
        self.assertEqual(dict(user, actions=mock.ANY), response.json['data'])

        # check conversion of extended boolean fields
        data['username'] += '1'
        data['email'] = '1' + data['email']
        data['active'] = 'TrUe'
        response = self.admin_open(method='POST', json=data)
        self.assert200(response)  # active is valid
        self.assertEqual(response.json['data']['active'], True)

        data['username'] += '1'
        data['email'] = '1' + data['email']
        data['suspended'] = '1'
        response = self.admin_open(method='POST', json=data)
        self.assert200(response)  # suspended is valid
        self.assertEqual(response.json['data']['suspended'], True)
예제 #2
0
 def _validate_kube_type_in_user_package(self, exists, field, value):
     if exists and self.user:
         if self.user == KUBERDOCK_INTERNAL_USER and \
                 value == Kube.get_internal_service_kube_type():
             return
         package = User.get(self.user).package
         if value not in [k.kube_id for k in package.kubes]:
             self._error(field,
                         "Pod can't be created, because your package "
                         "\"{0}\" does not include kube type with id "
                         "\"{1}\"".format(package.name, value))