def get_ubo_declaration(recreate=False):
     if BaseTestLive._ubo_declaration is None or recreate:
         legal_user = BaseTestLive.get_user_legal()
         params = {"user_id": legal_user.id}
         BaseTestLive._ubo_declaration = UboDeclaration(
             **UboDeclaration().create(**params))
     return BaseTestLive._ubo_declaration
    def legal_user_ubo_declaration(self):
        self.mock_declarative_user()
        self.mock_ubo_declaration()

        params = {
            "first_name": "Victor",
            "last_name": "Hugo",
            "address": Address(address_line_1='AddressLine1', address_line_2='AddressLine2',
                               city='City', region='Region',
                               postal_code='11222', country='FR'),
            "birthday": 1231432,
            "nationality": "FR",
            "country_of_residence": "FR",
            "occupation": "Writer",
            "income_range": 6,
            "proof_of_identity": None,
            "proof_of_address": None,
            "person_type": "NATURAL",
            "email": "*****@*****.**",
            "tag": "custom tag",
            "capacity": "DECLARATIVE"
        }
        user = NaturalUser(**params)
        user.save()

        params = {
            "user": user,
            "creation_date": 1554803756
        }

        ubo_declaration = UboDeclaration(**params)
        ubo_declaration.save()
        return ubo_declaration, user
    def test_create_ubo_declaration(self):
        self.mock_legal_user()
        self.mock_declarative_user()
        self.mock_ubo_declaration()

        params = {
            "first_name":
            "Victor",
            "last_name":
            "Hugo",
            "address":
            Address(address_line_1='AddressLine1',
                    address_line_2='AddressLine2',
                    city='City',
                    region='Region',
                    postal_code='11222',
                    country='FR'),
            "birthday":
            today,
            "nationality":
            "FR",
            "country_of_residence":
            "FR",
            "occupation":
            "Writer",
            "income_range":
            6,
            "proof_of_identity":
            None,
            "proof_of_address":
            None,
            "person_type":
            "NATURAL",
            "email":
            "*****@*****.**",
            "tag":
            "custom tag",
            "capacity":
            "DECLARATIVE"
        }
        user = NaturalUser(**params)
        user.save()

        params = {"user_id": "1169420", "declared_ubos": ["11694190"]}
        ubo_declaration = UboDeclaration(**params)
        ubo_declaration.save()

        self.assertTrue(isinstance(ubo_declaration, UboDeclaration))
        self.assertTrue(ubo_declaration.id == "1169420")
        self.assertTrue(len(ubo_declaration.declared_ubos) == 1)
        ubo = ubo_declaration.declared_ubos[0]
        self.assertTrue(isinstance(ubo, DeclaredUbo))
        self.assertTrue(ubo.user_id == '11694190')
        self.assertTrue(ubo.status == 'CREATED')
示例#4
0
 def test_list_ubo_declarations(self):
     legal_user = self.get_user_legal(True)
     self.get_ubo_declaration(True)
     declarations = UboDeclaration.all(**{"user_id": legal_user.id})
     self.assertIsNotNone(declarations)
     self.assertEqual(1, len(declarations))
     self.assertEqual(self.get_ubo_declaration().id, declarations[0].id)
    def test_get_ubo_declaration(self):
        self.mock_get_ubo_declaration()

        ubo_declaration, user = self.legal_user_ubo_declaration
        fetched_declaration = UboDeclaration.get(ubo_declaration.get_pk(), **{"user_id": user.get_pk()})
        self.assertIsNotNone(fetched_declaration)
        self.assertEquals(ubo_declaration.id, fetched_declaration.id)
    def legal_user_ubo_declaration(self):
        self.mock_declarative_user()
        self.mock_ubo_declaration()

        params = {
            "first_name":
            "Victor",
            "last_name":
            "Hugo",
            "address":
            Address(address_line_1='AddressLine1',
                    address_line_2='AddressLine2',
                    city='City',
                    region='Region',
                    postal_code='11222',
                    country='FR'),
            "birthday":
            1231432,
            "nationality":
            "FR",
            "country_of_residence":
            "FR",
            "occupation":
            "Writer",
            "income_range":
            6,
            "proof_of_identity":
            None,
            "proof_of_address":
            None,
            "person_type":
            "NATURAL",
            "email":
            "*****@*****.**",
            "tag":
            "Python SDK Unit Test",
            "capacity":
            "DECLARATIVE"
        }
        user = NaturalUser(**params)
        user.save()

        params = {"user": user, "creation_date": 1554803756}

        ubo_declaration = UboDeclaration(**params)
        ubo_declaration.save()
        return ubo_declaration, user
示例#7
0
 def test_get_ubo_declaration(self):
     legal_user = self.get_user_legal(True)
     self.get_ubo_declaration(True)
     fetched_declaration = UboDeclaration.get(
         self.get_ubo_declaration().get_pk(),
         **{"user_id": legal_user.get_pk()})
     self.assertIsNotNone(fetched_declaration)
     self.assertEqual(self.get_ubo_declaration().id, fetched_declaration.id)
    def test_list_ubo_declarations(self):
        self.mock_list_ubo_declarations()
        ubo_declaration, user = self.legal_user_ubo_declaration

        declarations = UboDeclaration.all(**{"user_id": "11694190"})
        self.assertIsNotNone(declarations)
        self.assertEquals(1, len(declarations))
        self.assertEquals(ubo_declaration.id, declarations[0].id)
    def test_update_ubo_declaration(self):
        self.mock_legal_user()
        self.mock_declarative_user()
        self.mock_ubo_declaration()

        params = {
            "first_name": "Victor",
            "last_name": "Hugo",
            "address": Address(address_line_1='AddressLine1', address_line_2='AddressLine2',
                               city='City', region='Region',
                               postal_code='11222', country='FR'),
            "birthday": today,
            "nationality": "FR",
            "country_of_residence": "FR",
            "occupation": "Writer",
            "income_range": 6,
            "proof_of_identity": None,
            "proof_of_address": None,
            "person_type": "NATURAL",
            "email": "*****@*****.**",
            "tag": "custom tag",
            "capacity": "DECLARATIVE"
        }
        user = NaturalUser(**params)
        user.save()

        params = {
            "user_id": "1169420",
            "declared_ubos": ["11694190"]
        }
        ubo_declaration = UboDeclaration(**params)
        ubo_declaration.save()

        updated_value = 'Updated Tag'

        self.register_mock({
            "method": responses.PUT,
            "url": settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID + '/ubodeclarations/1169420',
            "body": get_fixture('ubo_declaration') % ('"' + updated_value + '"'),
            "status": 200
        })

        ubo_declaration.tag = updated_value
        ubo_declaration.save()

        self.assertTrue(ubo_declaration.id == "1169420")
        self.assertTrue(ubo_declaration.tag == updated_value)