Ejemplo n.º 1
0
    def setup_class(cls):
        cls.user_id = "USER_ID"
        cls.user_name = "TEST_USER"
        cls.user_tenant_id = None
        cls.user_enabled = True
        cls.user_email = "*****@*****.**"
        cls.user_dict = {
            "id": cls.user_id,
            "name": cls.user_name,
            "tenantId": cls.user_tenant_id,
            "enabled": cls.user_enabled,
            "email": cls.user_email
        }

        cls.json_dict = {
            "name": cls.user_name,
            "tenantId": cls.user_tenant_id,
            "enabled": cls.user_enabled,
            "email": cls.user_email
        }

        cls.expected_user = User(id_=cls.user_id,
                                 name=cls.user_name,
                                 tenant_id=cls.user_tenant_id,
                                 enabled=cls.user_enabled,
                                 email=cls.user_email)
        cls.user_dict_list = [cls.user_dict]
        cls.expected_users = Users(users=[cls.expected_user])
        cls.expected_user_json = json.dumps({"user": cls.json_dict})
        cls.users_json = json.dumps({"users": cls.user_dict_list})
Ejemplo n.º 2
0
class UserTest(TestCase):
    def setUp(self):
        self.user_id = "USER_ID"
        self.user_name = "TEST_USER"
        self.user_tenant_id = None
        self.user_enabled = True
        self.user_email = "*****@*****.**"
        self.user_dict = {
            "name": self.user_name,
            "id": self.user_id,
            "tenantId": self.user_tenant_id,
            "enabled": self.user_enabled,
            "email": self.user_email}

        self.expected_user = User(id_=self.user_id,
                                  name=self.user_name,
                                  tenant_id=self.user_tenant_id,
                                  enabled=self.user_enabled,
                                  email=self.user_email)
        self.user_dict_list = [self.user_dict]
        self.expected_users = Users(users=[self.expected_user])
        self.serialized_str = json.dumps({"user": self.user_dict})
        self.expected_json = json.loads(self.serialized_str)

    def test_dict_to_obj(self):
        assert self.expected_user == User._dict_to_obj(self.user_dict)

    def test_list_to_obj(self):
        self.expected_users == Users._list_to_obj(self.user_dict_list)

    def test_json_to_obj(self):
        self.expected_user == User._json_to_obj(self.serialized_str)

    def test_obj_to_json(self):
        self.expected_json == self.expected_user._obj_to_json()
Ejemplo n.º 3
0
    def update_user(self,
                    user_id=None,
                    name=None,
                    enabled=None,
                    email=None,
                    requestslib_kwargs=None):
        """
        @summary: Updates a user given the provided parameters
         Maps to /users/{user_id}
        @param user_id: The ID of an existing tenant.
        @type user_id: String
        @param name: The name for the user
        @type name: String
        @param user_id: The id of the user
        @type user_id: String
        @param enabled: The status of the user
        @type name: Boolean
        @return: server_response
        @rtype: Response
        """

        url = '{0}/users/{1}'.format(self.base_url, user_id)
        user_request_object = User(id_=user_id,
                                   name=name,
                                   tenant_id=user_id,
                                   enabled=enabled,
                                   email=email)
        response = self.request('PUT',
                                url,
                                response_entity_type=User,
                                request_entity=user_request_object,
                                requestslib_kwargs=requestslib_kwargs)
        return response
Ejemplo n.º 4
0
    def setUp(self):
        self.user_id = "USER_ID"
        self.user_name = "TEST_USER"
        self.user_tenant_id = None
        self.user_enabled = True
        self.user_email = "*****@*****.**"
        self.user_dict = {
            "name": self.user_name,
            "id": self.user_id,
            "tenantId": self.user_tenant_id,
            "enabled": self.user_enabled,
            "email": self.user_email}

        self.expected_user = User(id_=self.user_id,
                                  name=self.user_name,
                                  tenant_id=self.user_tenant_id,
                                  enabled=self.user_enabled,
                                  email=self.user_email)
        self.user_dict_list = [self.user_dict]
        self.expected_users = Users(users=[self.expected_user])
        self.serialized_str = json.dumps({"user": self.user_dict})
        self.expected_json = json.loads(self.serialized_str)
Ejemplo n.º 5
0
    def create_user_for_a_tenant(self,
                                 id_=None,
                                 tenant_id=None,
                                 name=None,
                                 enabled=None,
                                 email=None,
                                 requestslib_kwargs=None):
        """
        @summary: Creates a user for a given tenant
        """

        url = '{0}/users'.format(self.base_url)
        user_request_object = User(id_=id_,
                                   tenant_id=tenant_id,
                                   name=name,
                                   enabled=enabled,
                                   email=email)
        response = self.request('POST',
                                url,
                                response_entity_type=User,
                                request_entity=user_request_object,
                                requestslib_kwargs=requestslib_kwargs)
        return response
Ejemplo n.º 6
0
 def test_json_to_obj(self):
     self.expected_user == User._json_to_obj(self.serialized_str)
Ejemplo n.º 7
0
 def test_dict_to_obj(self):
     assert self.expected_user == User._dict_to_obj(self.user_dict)
Ejemplo n.º 8
0
 def test_json_to_obj(self):
     assert self.expected_user == User._json_to_obj(self.expected_user_json)
     assert self.expected_users == Users._json_to_obj(self.users_json)
Ejemplo n.º 9
0
 def test_dict_to_obj(self):
     assert self.expected_user == User._dict_to_obj(self.user_dict)
Ejemplo n.º 10
0
 def test_json_to_obj(self):
     assert self.expected_user == User._json_to_obj(self.expected_user_json)
     assert self.expected_users == Users._json_to_obj(self.users_json)