def test_retrieving_claims_by_company_id(self):
        claimant_data_1 = {'foo': 'bar'}
        employee_record_1 = {'employer_id': 1}

        add_claim(claimant_data_1, employee_record_1)
        claim = claims_against_company(1)

        assert_that(claim[0][0], has_entry("foo", "bar"))
    def test_creating_multiple_claims(self):
        claimant_1_data = {'foo': 'bar'}
        claimant_2_data = {'foo': 'zap'}
        claimant_3_data = {'foo': 'pow'}
        employee_record_1 = {'x': '1'}
        employee_record_2 = {'x': '2'}
        employee_record_3 = {'x': '3'}
        add_claim(claimant_1_data, employee_record_1)
        add_claim(claimant_2_data, employee_record_2)

        claim_3_id = add_claim(claimant_3_data, employee_record_3)

        claim = get_claim(claim_3_id)
        assert_that(claim[0]['foo'], is_('pow'))
        assert_that(claim[1]['x'], is_('3'))
    def test_creating_a_claim(self):
        claimant_information = {'foo': 'bar'}

        employee_record = {'foo': 'zap'}

        claim_id = add_claim(claimant_information, employee_record)
        claim = get_claim(claim_id)
        assert_that(claim[0]['foo'], is_('bar'))
        assert_that(claim[1]['foo'], is_('zap'))
    def test_submitting_claim(self, mock_time):
        mock_time.return_value = datetime(1990, 1, 1, 1)
        claimant_data = {'foo': 'bar'}
        employee_record = {'x': '1'}

        claim_id = add_claim(claimant_data, employee_record)

        mark_claim_as_submitted(claim_id)

        claim = get_claim(claim_id)
        assert_that(claim[2], is_(datetime(1990, 1, 1, 1)))
def create_claim_2(claimant_information):
    nino = claimant_information['nino']
    employee_record = cabinet_api.employee_via_nino(nino)
    if employee_record:
        claim_id = cabinet_api.add_claim(
            claimant_information,
            employee_record
        )
        return claim_id
    else:
        raise NoEmployeeException(
            "Can't create a claim without first creating an employee")
    def test_getting_submitted_claims_since_a_given_time(self, mock_time):
        mock_time.return_value = datetime(1990, 1, 1, 1)
        claimant_1_data = {'foo': 'bar'}
        employee_record_1 = {'x': '1'}
        claim_id = add_claim(claimant_1_data, employee_record_1)
        mark_claim_as_submitted(claim_id)

        claims = get_claims_submitted_between(start=datetime(1990, 1, 1),
                                              end=datetime(1990, 1, 2))

        assert_that(claims, has_length(1))
        assert_that(claims[0][2], is_(datetime(1990, 1, 1, 1)))
    def test_sumarise_claims_with_discrepancies(self):
        claimant_data_1 = {'nino': 'XX223344X', 'gross_rate_of_pay': 100}
        employee_record_1 = {
            'employer_id': 1,
            'employee_basic_weekly_pay': 200
        }

        claim_id = add_claim(claimant_data_1, employee_record_1)

        claims_summary = api.summarise_claims()

        assert_that(claims_summary, has_length(1))
        assert_that(claims_summary[0], has_entry('discrepancy', is_(True)))
def step(context):
    #No discrepancies
    claimant_data_1 = {
        'nino': 'XX223344X',
        'forenames': 'Ted Rocket Man',
        'surname': 'Jones',
        'date_of_birth': ['23', '05', '1982'],
        'gross_rate_of_pay': 100
    }
    employee_record_1 = {
        'employer_id': 1,
        'employee_forenames': 'Ted Rocket Man',
        'employee_surname': 'Jones',
        'employee_national_insurance_number': 'XX223344X',
        'employee_basic_weekly_pay': 100
    }

    claim_id = cabinet_api.add_claim(claimant_data_1, employee_record_1)
    cabinet_api.mark_claim_as_submitted(claim_id)

    #With discrepancies
    claimant_data_2 = {
        'nino': 'XX223355A',
        'forenames': 'John',
        'surname': 'Henry',
        'date_of_birth': ['24', '05', '1981'],
        'gross_rate_of_pay': 200
    }
    employee_record_2 = {
        'employer_id': 1,
        'employee_forenames': 'John',
        'employee_surname': 'Henry',
        'nino': 'XX223355A',
        'employee_basic_weekly_pay': 250
    }

    claim_id = cabinet_api.add_claim(claimant_data_2, employee_record_2)
    cabinet_api.mark_claim_as_submitted(claim_id)
    def test_summarise_claims(self):
        claimant_data_1 = {'foo': 'bar', 'nino': 'XX223344X'}
        employee_record_1 = {'employer_id': 1}

        claim_id = add_claim(claimant_data_1, employee_record_1)
        api.submit(claim_id)

        claims_summary = api.summarise_claims()

        assert_that(claims_summary, has_length(1))
        assert_that(claims_summary[0], has_entry('nino', 'XX223344X'))
        assert_that(claims_summary[0], has_entry('date_submitted',
                                                 is_not(None)))
        assert_that(claims_summary[0], has_entry('discrepancy', is_(False)))
    def test_retrieving_claims(self):
        claimant_1_data = {'foo': 'bar'}
        claimant_2_data = {'foo': 'zap'}
        claimant_3_data = {'foo': 'pow'}
        employee_record_1 = {'x': '1'}
        employee_record_2 = {'x': '2'}
        employee_record_3 = {'x': '3'}
        add_claim(claimant_1_data, employee_record_1)
        add_claim(claimant_2_data, employee_record_2)
        add_claim(claimant_3_data, employee_record_3)

        claims = get_claims()
        assert_that(claims, has_length(3))
        assert_that(claims[0][0], has_entry('foo', is_('bar')))
    def test_updating_a_claim(self):
        claimant_data = {'foo': 'bar', 'unchanged': 'grep'}
        employee_record = {'foo': 'baz'}

        updated_claimant_data = {'foo': 'mongoose', 'zap': 'pow'}

        claim_id = add_claim(claimant_data, employee_record)

        claim = get_claim(claim_id)

        assert_that(claim[0]['foo'], is_('bar'))
        assert_that(claim[0]['unchanged'], is_('grep'))
        assert_that(claim[1]['foo'], is_('baz'))

        update_claim(claim_id, claimant_information=updated_claimant_data)

        updated_claim = get_claim(claim_id)
        assert_that(updated_claim[0]['zap'], is_('pow'))
        assert_that(updated_claim[0]['foo'], is_('mongoose'))
        assert_that(updated_claim[0]['unchanged'], is_('grep'))
        assert_that(updated_claim[1]['foo'], is_('baz'))
    def test_should_return_none_if_no_unprocessed_claims(self):
        add_claim({}, {})
        get_next_claim_not_processed_by_chomp()
        claim = get_next_claim_not_processed_by_chomp()

        assert_that(claim, is_(None))
    def test_should_return_next_unprocessed_claim(self):
        add_claim({}, {})
        claim = get_next_claim_not_processed_by_chomp()

        assert_that(claim, is_(not_none()))