Beispiel #1
0
    def test_same_day(self):
        data1 = sample_reimbursement_data.copy()
        data1['document_id'] = 42 * 2
        data1['issue_date'] = '1970-12-31'
        Reimbursement.objects.create(**data1)

        data2 = sample_reimbursement_data.copy()
        data2['document_id'] = 42 * 3
        data2['issue_date'] = '1970-12-31'
        Reimbursement.objects.create(**data2)

        data3 = sample_reimbursement_data.copy()
        data3['document_id'] = 42 * 4
        data3['issue_date'] = '1970-12-31'
        Reimbursement.objects.create(**data3)

        unique_id = dict(
            year=1970,
            applicant_id=13,
            document_id=84
        )
        qs = Reimbursement.objects.same_day(**unique_id)
        self.assertEqual(2, qs.count())
    def setUp(self):

        data = [
            sample_reimbursement_data.copy(),
            sample_reimbursement_data.copy(),
            sample_reimbursement_data.copy(),
            sample_reimbursement_data.copy()
        ]

        data[1]['cnpj_cpf'] = '22222222222'
        data[1]['document_id'] = 42 * 2
        data[1]['issue_date'] = date(1969, 12, 31)
        data[1]['probability'] = None
        data[1]['subquota_id'] = 22

        data[2]['applicant_id'] = 13 * 3
        data[2]['cnpj_cpf'] = '22222222222'
        data[2]['document_id'] = 42 * 3
        data[2]['probability'] = 0.1
        data[2]['subquota_id'] = 22

        data[3]['applicant_id'] = 13 * 4
        data[3]['cnpj_cpf'] = '22222222222'
        data[3]['document_id'] = 42 * 4
        data[3]['probability'] = 0.9
        data[3]['subquota_id'] = 22
        data[3]['year'] = 1983
        data[3]['issue_date'] = '1970-02-01'

        for d in data:
            Reimbursement.objects.create(**d)

        url_name = 'api:reimbursement-list'
        self.all = resolve_url(url_name)
        self.by_year = resolve_url(url_name, year=1970)
        self.by_applicant = resolve_url(url_name, year=1970, applicant_id=13)