示例#1
0
def test_bcorp_get_business_directors(session, client, jwt):
    """Assert that business directors are returned."""
    # setup
    identifier = 'CP7654321'
    business = factory_business(identifier, datetime.datetime.now(), None,
                                'BC')
    director = Director(first_name='Michael',
                        last_name='Crane',
                        middle_initial='Joe',
                        title='VP',
                        appointment_date=datetime.datetime(2017, 5, 17),
                        cessation_date=None)
    director_address = Address(city='Test Delivery City',
                               address_type=Address.DELIVERY)
    director_mailing_address = Address(city='Test Mailing City',
                                       address_type=Address.MAILING)
    director.delivery_address = director_address
    director.mailing_address = director_mailing_address
    business.directors.append(director)
    business.save()

    # test
    rv = client.get(f'/api/v1/businesses/{identifier}/directors',
                    headers=create_header(jwt, [STAFF_ROLE], identifier))
    # check
    assert rv.status_code == HTTPStatus.OK
    assert 'directors' in rv.json
    assert rv.json['directors'][0]['mailingAddress'][
        'addressCity'] == 'Test Mailing City'
示例#2
0
def test_bcorp_get_business_directors(session, client, jwt):
    """Assert that business directors are returned."""
    # setup
    identifier = 'CP7654321'
    business = factory_business(identifier, datetime.datetime.now(), None,
                                Business.LegalTypes.BCOMP.value)
    director_address = Address(city='Test Delivery City',
                               address_type=Address.DELIVERY)
    director_mailing_address = Address(city='Test Mailing City',
                                       address_type=Address.MAILING)
    officer = {
        'firstName': 'Michael',
        'lastName': 'Crane',
        'middleInitial': 'Joe'
    }
    party_role = factory_party_role(director_address,
                                    director_mailing_address, officer,
                                    datetime.datetime(2017, 5, 17), None,
                                    PartyRole.RoleTypes.DIRECTOR)
    business.party_roles.append(party_role)
    business.save()

    # test
    rv = client.get(f'/api/v1/businesses/{identifier}/directors',
                    headers=create_header(jwt, [STAFF_ROLE], identifier))
    # check
    assert rv.status_code == HTTPStatus.OK
    assert 'directors' in rv.json
    assert rv.json['directors'][0]['mailingAddress'][
        'addressCity'] == 'Test Mailing City'
示例#3
0
def test_directors_coop_no_mailing_address(session, client, jwt):
    """Assert that coop directors have a mailing and delivery address."""
    # setup
    identifier = 'CP7654321'
    business = factory_business(identifier)
    delivery_address = Address(city='Test Delivery City',
                               address_type=Address.DELIVERY)
    officer = {
        'firstName': 'Michael',
        'lastName': 'Crane',
        'middleInitial': 'Joe'
    }
    party_role = factory_party_role(delivery_address, None, officer,
                                    datetime.datetime(2017, 5, 17), None,
                                    PartyRole.RoleTypes.DIRECTOR)
    business.party_roles.append(party_role)
    business.save()

    # test
    rv = client.get(f'/api/v1/businesses/{identifier}/directors',
                    headers=create_header(jwt, [STAFF_ROLE], identifier))
    # check
    assert rv.status_code == HTTPStatus.OK
    assert 'directors' in rv.json
    assert rv.json['directors'][0]['deliveryAddress'][
        'addressCity'] == 'Test Delivery City'
    assert 'mailingAddress' not in rv.json['directors'][0]
def test_get_business_addresses(session, client, jwt):
    """Assert that business addresses are returned."""
    # setup
    identifier = 'CP7654321'
    business = factory_business(identifier)
    mailing_address = Address(city='Test Mailing City', address_type=Address.MAILING)
    business.mailing_address.append(mailing_address)
    delivery_address = Address(city='Test Delivery City', address_type=Address.DELIVERY)
    business.delivery_address.append(delivery_address)
    business.save()

    # test
    rv = client.get(f'/api/v1/businesses/{identifier}/addresses',
                    headers=create_header(jwt, [STAFF_ROLE], identifier)
                    )
    # check
    assert rv.status_code == HTTPStatus.OK
    assert 'mailingAddress' in rv.json
    assert 'deliveryAddress' in rv.json
示例#5
0
def test_business_filing_ia_parties(session, client, jwt):
    """Assert that the ia parties can be received in a valid JSONSchema format."""
    identifier = 'BC7654321'
    b = factory_business(identifier)
    filings = factory_completed_filing(b, INCORPORATION_FILING_TEMPLATE)
    director_address = Address(city='Test Mailing City',
                               address_type=Address.DELIVERY,
                               postal_code='H0H0H0')
    officer = {
        'firstName': 'Michael',
        'lastName': 'Crane',
        'middleInitial': 'Joe',
        'partyType': 'person',
        'organizationName': ''
    }
    party_role = factory_party_role(director_address, None, officer,
                                    datetime(2017, 5, 17), None,
                                    PartyRole.RoleTypes.DIRECTOR)
    b.party_roles.append(party_role)

    officer = {
        'firstName': '',
        'lastName': '',
        'middleInitial': '',
        'partyType': 'organization',
        'organizationName': 'Test Inc.'
    }
    party_role = factory_party_role(director_address, None, officer,
                                    datetime(2017, 5, 17), None,
                                    PartyRole.RoleTypes.DIRECTOR)
    b.party_roles.append(party_role)

    rv = client.get(f'/api/v1/businesses/{identifier}/filings/{filings.id}',
                    headers=create_header(jwt, [STAFF_ROLE], identifier))

    assert rv.status_code == HTTPStatus.OK
    party_1 = rv.json['filing']['incorporationApplication']['parties'][0][
        'officer']
    assert party_1
    assert party_1['partyType'] == 'person'
    assert party_1['firstName'] == 'Michael'
    assert party_1['lastName'] == 'Crane'
    assert party_1['middleName'] == 'Joe'
    assert 'organizationName' not in party_1

    party_2 = rv.json['filing']['incorporationApplication']['parties'][1][
        'officer']
    assert party_2
    assert party_2['partyType'] == 'organization'
    assert 'firstName' not in party_2
    assert 'lastName' not in party_2
    assert 'middleName' not in party_2
    assert party_2['organizationName'] == 'Test Inc.'
def test_get_business_addresses(session, client, jwt):
    """Assert that business addresses are returned."""
    # setup
    identifier = 'CP7654321'
    business = factory_business(identifier)
    mailing_address = Address(city='Test Mailing City',
                              address_type=Address.MAILING)
    delivery_address = Address(city='Test Delivery City',
                               address_type=Address.DELIVERY)
    office = Office(office_type='registeredOffice')
    office.addresses.append(mailing_address)
    office.addresses.append(delivery_address)
    business.offices.append(office)
    business.save()

    # test
    rv = client.get(f'/api/v2/businesses/{identifier}/addresses',
                    headers=create_header(jwt, [STAFF_ROLE], identifier,
                                          **{'Accept-Version': 'v1'}))
    # check
    assert rv.status_code == HTTPStatus.OK
    assert 'registeredOffice' in rv.json
    assert 'mailingAddress' in rv.json['registeredOffice']
    assert 'deliveryAddress' in rv.json['registeredOffice']
def test_get_business_mailing_addresses_by_type(session, client, jwt):
    """Assert that business address type is returned."""
    # setup
    identifier = 'CP7654321'
    business = factory_business(identifier)
    mailing_address = Address(city='Test Mailing City', address_type=Address.MAILING)
    business.mailing_address.append(mailing_address)
    business.save()

    # test
    rv = client.get(f'/api/v1/businesses/{identifier}/addresses?addressType={Address.JSON_MAILING}',
                    headers=create_header(jwt, [STAFF_ROLE], identifier)
                    )
    # check
    assert rv.status_code == HTTPStatus.OK
    assert Address.JSON_MAILING in rv.json
def test_get_business_delivery_addresses_by_type_missing_address(session, client, jwt):
    """Assert that business addresses are not returned."""
    # setup
    identifier = 'CP7654321'
    business = factory_business(identifier)
    delivery_address = Address(city='Test Delivery City', address_type=Address.DELIVERY)
    business.delivery_address.append(delivery_address)
    business.save()

    # test
    rv = client.get(f'/api/v1/businesses/{identifier}/addresses?addressType={Address.JSON_MAILING}',
                    headers=create_header(jwt, [STAFF_ROLE], identifier)
                    )
    # check
    assert rv.status_code == HTTPStatus.NOT_FOUND
    assert rv.json == {'message': f'{identifier} address not found'}
示例#9
0
def test_get_business_addresses_by_id(session, client, jwt):
    """Assert that business address is returned."""
    # setup
    identifier = 'CP7654321'
    business = factory_business(identifier)
    mailing_address = Address(city='Test Mailing City',
                              address_type=Address.MAILING,
                              business_id=business.id)
    office = Office(office_type='registeredOffice')
    office.addresses.append(mailing_address)
    business.offices.append(office)
    business.save()

    # test
    rv = client.get(
        f'/api/v1/businesses/{identifier}/addresses/{mailing_address.id}',
        headers=create_header(jwt, [STAFF_ROLE], identifier))
    # check
    assert rv.status_code == HTTPStatus.OK
    assert 'mailingAddress' in rv.json
示例#10
0
def test_get_business_delivery_addresses_by_type(session, client, jwt):
    """Assert that business address type is returned."""
    # setup
    identifier = 'CP7654321'
    business = factory_business(identifier)
    delivery_address = Address(city='Test Delivery City',
                               address_type=Address.DELIVERY,
                               business_id=business.id)
    office = Office(office_type='registeredOffice')
    office.addresses.append(delivery_address)
    business.offices.append(office)
    business.save()

    # test
    rv = client.get(
        f'/api/v1/businesses/{identifier}/addresses?addressType={Address.JSON_DELIVERY}',
        headers=create_header(jwt, [STAFF_ROLE], identifier))
    # check
    assert rv.status_code == HTTPStatus.OK
    assert Address.JSON_DELIVERY in rv.json