def create(self): mango_call = LegalUser(LegalPersonType=self.legal_type, Name=self.legal_name, LegalRepresentativeBirthday=_make_timestamp(self.birthday), # see if this self. is right? LegalRepresentativeCountryOfResidence=self.country_of_residence, LegalRepresentativeNationality=self.nationality, LegalRepresentativeFirstName=self.user.first_name, LegalRepresentativeLastName=self.user.last_name, Email=self.user.email, CompanyNumber=self.company_number) mango_call.save() self.mid = mango_call.Id self.save()
def get_user(self): return LegalUser( id=self.mangopay_id, email=self.business_email, name=self.business_name, legal_person_type=self.legal_person_type, headquarters_address=Address( address_line_1=self.headquarters_address), legal_representative_first_name=self.first_name, legal_representative_last_name=self.last_name, legal_representative_address=Address(address_line_1=self.address), legal_representative_email=self.email, legal_representative_birthday=self._birthday_fmt(), legal_representative_nationality=self.nationality.code, legal_representative_country_of_residence=self. country_of_residence.code, )
def test_retrieve_specific_legal_user(self): self.mock_legal_user() self.register_mock({ 'method': responses.GET, 'url': re.compile(r'' + settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID + '/users/\d+'), 'body': { "Name": "MangoPay", "LegalPersonType": "BUSINESS", "HeadquartersAddress": { "AddressLine1": "AddressLine1", "AddressLine2": "AddressLine2", "City": "City", "Region": "Region", "PostalCode": "11222", "Country": "FR" }, "LegalRepresentativeFirstName": "Mango", "LegalRepresentativeLastName": "Pay", "LegalRepresentativeEmail": "*****@*****.**", "LegalRepresentativeBirthday": today_timestamp, "LegalRepresentativeNationality": "FR", "LegalRepresentativeCountryOfResidence": "FR", "ProofOfRegistration": None, "ShareholderDeclaration": None, "LegalRepresentativeAddress": None, "Statute": None, "PersonType": "LEGAL", "Email": "*****@*****.**", "Id": "1169420", "Tag": "custom tag", "CreationDate": 1383322502, "KYCLevel": "LIGHT", "UserCategory": "OWNER" }, 'status': 200 }) params = { "name": "MangoPay", "legal_person_type": "BUSINESS", "headquarters_address": Address(address_line_1='AddressLine1', address_line_2='AddressLine2', city='City', region='Region', postal_code='11222', country='FR'), "legal_representative_first_name": "Mango", "legal_representative_last_name": "Pay", "legal_representative_email": "*****@*****.**", "legal_representative_birthday": today, "legal_representative_nationality": "FR", "legal_representative_country_of_residence": "FR", "proof_of_registration": None, "shareholder_declaration": None, "legal_representative_address": None, "statute": None, "person_type": "LEGAL", "email": "*****@*****.**", "tag": "custom tag", "user_category": "OWNER" # "creation_date": datetime.now() } user = LegalUser(**params) self.assertIsNone(user.get_pk()) user.save() self.assertIsInstance(user, LegalUser) for key, value in params.items(): self.assertEqual(getattr(user, key), value) retrieved_user = User.get(user.id) for key, value in params.items(): self.assertEqual(getattr(retrieved_user, key), value) self.assertIsInstance(retrieved_user, User)
def test_create_legal_user(self): self.mock_legal_user() self.register_mock({ 'method': responses.PUT, 'url': re.compile( r'' + settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID + '/users/legal/\d+'), 'body': { "Name": "MangoPay edited", "LegalPersonType": "BUSINESS", "HeadquartersAddress": { "AddressLine1": "AddressLine1", "AddressLine2": "AddressLine2", "City": "City", "Region": "Region", "PostalCode": "11222", "Country": "FR" }, "LegalRepresentativeFirstName": "Mango", "LegalRepresentativeLastName": "Pay", "LegalRepresentativeEmail": "*****@*****.**", "LegalRepresentativeBirthday": today_timestamp, "LegalRepresentativeNationality": "FR", "LegalRepresentativeCountryOfResidence": "FR", "PersonType": "LEGAL", "Email": "*****@*****.**", "Id": "1169420", "Tag": "custom tag", "CreationDate": 1383322502, "KYCLevel": "LIGHT" }, 'status': 200 }) params = { "name": "MangoPay", "legal_person_type": "BUSINESS", "headquarters_address": Address(address_line_1='AddressLine1', address_line_2='AddressLine2', city='City', region='Region', postal_code='11222', country='FR'), "legal_representative_first_name": "Mango", "legal_representative_last_name": "Pay", "legal_representative_email": "*****@*****.**", "legal_representative_birthday": today, "legal_representative_nationality": "FR", "legal_representative_country_of_residence": "FR", "proof_of_registration": None, "shareholder_declaration": None, "legal_representative_address": None, "statute": None, "person_type": "LEGAL", "email": "*****@*****.**", "tag": "custom tag", # "creation_date": datetime.now() } user = LegalUser(**params) self.assertIsNone(user.get_pk()) user.save() self.assertIsInstance(user, LegalUser) for key, value in params.items(): self.assertEqual(getattr(user, key), value) self.assertIsNotNone(user.get_pk()) previous_pk = user.get_pk() user.last_name = 'Claver' user.save() self.assertEqual(previous_pk, user.get_pk()) self.assertEqual(user.last_name, 'Claver')