Example #1
0
def test_is_probably_company_officer_match(mock_list_officers, caplog):
    mock_list_officers.return_value = create_response(json_body={
        'items': [
            {
                'name': 'EXAMPLE, Jim',
                'date_of_birth': {
                    'month': 1,
                    'year': 1990
                 },
            }
        ]
    })

    actual = helpers.is_probably_company_officer(
        first_name='Jim',
        surname='Example',
        birth_date=datetime.date(1990, 1, 1),
        company_number=12345678
    )

    assert actual is True

    log = caplog.records[-1]
    assert log.levelname == 'INFO'
    assert log.msg == 'Jim Example match found for 12345678. Scores: 100 100'
Example #2
0
def test_is_probably_company_officer_date_match(mock_list_officers, caplog):
    mock_list_officers.return_value = create_response(json_body={
        'items': [
            {
                'name': 'FOOD, Fred',
                'date_of_birth': {
                    'month': 1,
                    'year': 1990
                 },
            }
        ]
    })

    actual = helpers.is_probably_company_officer(
        first_name='Jim',
        surname='Example',
        birth_date=datetime.date(1990, 1, 1),
        company_number=12345678
    )

    assert actual is False

    log = caplog.records[-1]
    assert log.levelname == 'WARNING'
    assert log.msg == 'No matches for Jim Example in 12345678'
 def form_valid(self, form):
     user_attributes = form.get_user_attributes()
     is_success = helpers.is_probably_company_officer(
         first_name=user_attributes['first_name'],
         surname=user_attributes['surname'],
         birth_date=user_attributes['birth_date'],
         company_number=self.company_details['number'],
     )
     return TemplateResponse(
         request=self.request,
         template=self.get_template_name(is_success=is_success),
         context=self.get_context_data(
             company_details=self.company_details))
Example #4
0
def test_is_probably_company_officer_no_company(
    mock_list_officers, status_code
):
    mock_list_officers.return_value = create_response(status_code=status_code)

    actual = helpers.is_probably_company_officer(
        first_name='Jim',
        surname='Example',
        birth_date=datetime.date(1990, 1, 1),
        company_number=12345678
    )

    assert actual is False
Example #5
0
def test_force_match(settings, company_number, expected, caplog):
    settings.FEATURE_FORCE_MATCH_ENABLED = True
    settings.FORCE_MATCH_COMPANY_NUMBER = '1234567'

    actual = helpers.is_probably_company_officer(
        first_name='Jim',
        surname='Example',
        birth_date=datetime.date(1990, 1, 1),
        company_number=company_number
    )

    assert actual is expected

    log = caplog.records[-1]
    assert log.levelname == 'WARNING'
    assert log.msg == 'Force match enabled'