def test_setting_replace_user_input_params_with_optional_parameters(self):
     input_params = ReplaceUserInputParams(
         "username", True, NameInputParams("given_name", "family_name"))
     input_params.set_language(Language.SPANISH).set_locale(
         "en-gb").set_title("Manager").set_external_id(
             "external-id").set_phone_number("787281928").set_gender(
                 Gender.MALE).set_date_of_birth(
                     datetime.datetime(1990, 3, 23)).set_travel_policy(
                         "Travel Policy").set_invoice_profiles([
                             "Invoice Profile 1", "Invoice Profile 2"
                         ]).set_emergency_contact(
                             EmergencyContact(
                                 "Test contact",
                                 "679281923")).set_cost_center(
                                     "Test Cost Center").set_manager("123")
     assert {
         "userName": "******",
         "name": {
             "givenName": "given_name",
             "familyName": "family_name",
         },
         "active": True,
         "preferredLanguage": "es",
         "locale": "en-gb",
         "title": "Manager",
         "externalId": "external-id",
         "phoneNumbers": [
             {
                 "value": "787281928",
                 "type": "work",
             },
         ],
         "urn:ietf:params:scim:schemas:extension:travelperk:2.0:User": {
             "gender":
             "M",
             "dateOfBirth":
             "1990/03/23",
             "travelPolicy":
             "Travel Policy",
             "emergencyContact": {
                 "name": "Test contact",
                 "phone": "679281923",
             },
             "invoiceProfiles": [
                 {
                     "value": "Invoice Profile 1"
                 },
                 {
                     "value": "Invoice Profile 2"
                 },
             ],
         },
         "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
             "costCenter": "Test Cost Center",
             "manager": {
                 "value": "123",
             },
         },
     } == input_params.to_dict()
 def test_setting_update_user_input_params_name(self):
     input_params = UpdateUserInputParams()
     input_params.set_name(NameInputParams("given name", "family name"))
     assert {
         "name": {
             "givenName": "given name",
             "familyName": "family name",
         },
     } == input_params.to_dict()
Ejemplo n.º 3
0
 def create(self, username: str, active: bool, given_name: str,
            family_name: str) -> User:
     name = NameInputParams(given_name, family_name)
     params = CreateUserInputParams(username, active, name)
     return DataclassWrapper.wrap(
         User,
         humps.decamelize(
             self.execute("post", "/".join(["scim", "Users"]),
                          params.to_dict())),
     )
 def test_setting_replace_user_input_params(self):
     input_params = ReplaceUserInputParams(
         "username", True, NameInputParams("given_name", "family_name"))
     assert {
         "userName": "******",
         "name": {
             "givenName": "given_name",
             "familyName": "family_name",
         },
         "active": True,
     } == input_params.to_dict()
 def test_setting_all_fields(self):
     assert {
         "givenName": "Given Name",
         "familyName": "Family Name",
         "honorificPrefix": "Honorific Prefix",
         "middleName": "Middle Name",
     } == NameInputParams("Given Name", "Family Name").set_middle_name(
         "Middle Name"
     ).set_honorific_prefix(
         "Honorific Prefix"
     ).to_dict()
Ejemplo n.º 6
0
 def modify(self, id: int, username: str, active: bool, given_name: str,
            family_name: str) -> ModifyUserRequest:
     name = NameInputParams(given_name, family_name)
     return ModifyUserRequest(id, self.travelperk, username, active, name)
Ejemplo n.º 7
0
 def make(self, username: str, active: bool, given_name: str,
          family_name: str) -> CreateUserQuery:
     name = NameInputParams(given_name, family_name)
     return CreateUserQuery(self.travelperk, username, active, name)
 def test_setting_just_mandatory_fields(self):
     assert {
         "givenName": "Given Name",
         "familyName": "Family Name",
     } == NameInputParams("Given Name", "Family Name").to_dict()