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) qs = Reimbursement.objects.same_day_as(84) self.assertEqual(2, qs.count())
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) qs = Reimbursement.objects.same_day_as(84) self.assertEqual(2, qs.count())
def test_content_non_duplicate_name(self): expected = [dict(congressperson_name='Roger That', applicant_id=13)] secondary_data = sample_reimbursement_data.copy() secondary_data['document_id'] = 13 secondary_data['year'] = 1971 Reimbursement.objects.create(**secondary_data) resp = self.client.get(self.url) content = loads(resp.content.decode('utf-8')) self.assertEqual(1, content['count']) self.assertEqual(expected, content['results'])
def test_content_non_duplicate_name(self): expected = [ dict(subquota_description='Subquota description', subquota_id=4) ] secondary_data = sample_reimbursement_data.copy() secondary_data['document_id'] = 13 secondary_data['year'] = 1971 Reimbursement.objects.create(**secondary_data) resp = self.client.get(self.url) content = loads(resp.content.decode('utf-8')) self.assertEqual(1, content['count']) self.assertEqual(expected, content['results'])
def test_contents_with_filter(self): expected = [dict(congressperson_name='John Doe', applicant_id=42)] secondary_data = sample_reimbursement_data.copy() secondary_data['applicant_id'] = 42 secondary_data['congressperson_name'] = 'John Doe' secondary_data['document_id'] = 13 Reimbursement.objects.create(**secondary_data) resp = self.client.get(self.url + '?q=doe') content = loads(resp.content.decode('utf-8')) self.assertEqual(1, content['count']) self.assertEqual(expected, content['results'])
def test_content_non_duplicate_name(self): expected = [ dict(subquota_description='Subquota description', subquota_number=4) ] secondary_data = sample_reimbursement_data.copy() secondary_data['document_id'] = 13 secondary_data['year'] = 1971 Reimbursement.objects.create(**secondary_data) resp = self.client.get(self.url) content = loads(resp.content.decode('utf-8')) self.assertEqual(1, content['count']) self.assertEqual(expected, content['results'])
def test_content_non_duplicate_name(self): expected = [ dict(congressperson_name='Roger That', applicant_id=13) ] secondary_data = sample_reimbursement_data.copy() secondary_data['document_id'] = 13 secondary_data['year'] = 1971 Reimbursement.objects.create(**secondary_data) resp = self.client.get(self.url) content = loads(resp.content.decode('utf-8')) self.assertEqual(1, content['count']) self.assertEqual(expected, content['results'])
def setUp(self): self.maxDiff = 2**10 cnpj = '12345678901234' company1 = sample_company_data.copy() company1['cnpj'] = format_cnpj(cnpj) company1['city'] = 'Atlantis' company1['state'] = 'WE' Company.objects.create(**company1) company2 = sample_company_data.copy() company2['cnpj'] = format_cnpj(cnpj[::-1]) Company.objects.create(**company2) data1 = sample_reimbursement_data.copy() data1['document_id'] = 42 * 2 data1['cnpj_cpf'] = cnpj Reimbursement.objects.create(**data1) data2 = sample_reimbursement_data.copy() data2['document_id'] = 42 * 3 data2['cnpj_cpf'] = cnpj Reimbursement.objects.create(**data2) data3 = sample_reimbursement_data.copy() data3['document_id'] = 42 * 4 data3['cnpj_cpf'] = cnpj[::-1] Reimbursement.objects.create(**data3) data4 = sample_reimbursement_data.copy() data4['document_id'] = 42 * 5 data4['cnpj_cpf'] = '11111111111111' Reimbursement.objects.create(**data4) url = resolve_url('chamber_of_deputies:reimbursement-same-day', document_id=84) self.resp = self.client.get(url)
def setUp(self): self.maxDiff = 2 ** 10 cnpj = '12345678901234' company1 = sample_company_data.copy() company1['cnpj'] = format_cnpj(cnpj) company1['city'] = 'Atlantis' company1['state'] = 'WE' Company.objects.create(**company1) company2 = sample_company_data.copy() company2['cnpj'] = format_cnpj(cnpj[::-1]) Company.objects.create(**company2) data1 = sample_reimbursement_data.copy() data1['document_id'] = 42 * 2 data1['cnpj_cpf'] = cnpj Reimbursement.objects.create(**data1) data2 = sample_reimbursement_data.copy() data2['document_id'] = 42 * 3 data2['cnpj_cpf'] = cnpj Reimbursement.objects.create(**data2) data3 = sample_reimbursement_data.copy() data3['document_id'] = 42 * 4 data3['cnpj_cpf'] = cnpj[::-1] Reimbursement.objects.create(**data3) data4 = sample_reimbursement_data.copy() data4['document_id'] = 42 * 5 data4['cnpj_cpf'] = '11111111111111' Reimbursement.objects.create(**data4) url = resolve_url('chamber_of_deputies:reimbursement-same-day', document_id=84) self.resp = self.client.get(url)
def test_contents_with_filter(self): expected = [ dict(congressperson_name='John Doe', applicant_id=42) ] secondary_data = sample_reimbursement_data.copy() secondary_data['applicant_id'] = 42 secondary_data['congressperson_name'] = 'John Doe' secondary_data['document_id'] = 13 Reimbursement.objects.create(**secondary_data) resp = self.client.get(self.url + '?q=doe') content = loads(resp.content.decode('utf-8')) self.assertEqual(1, content['count']) self.assertEqual(expected, content['results'])
def test_contents_with_filter(self): expected = [ dict(subquota_description='Another subquota', subquota_id=42) ] secondary_data = sample_reimbursement_data.copy() secondary_data['document_id'] = 13 secondary_data['year'] = 1971 secondary_data['subquota_id'] = 42 secondary_data['subquota_description'] = 'Another subquota' Reimbursement.objects.create(**secondary_data) resp = self.client.get(self.url + '?q=another') content = loads(resp.content.decode('utf-8')) self.assertEqual(1, content['count']) self.assertEqual(expected, content['results'])
def test_contents_with_filter(self): expected = [ dict(subquota_description='Another subquota', subquota_number=42) ] secondary_data = sample_reimbursement_data.copy() secondary_data['document_id'] = 13 secondary_data['year'] = 1971 secondary_data['subquota_number'] = 42 secondary_data['subquota_description'] = 'Another subquota' Reimbursement.objects.create(**secondary_data) resp = self.client.get(self.url + '?q=another') content = loads(resp.content.decode('utf-8')) self.assertEqual(1, content['count']) self.assertEqual(expected, content['results'])
def test_contents(self): expected = [ dict(congressperson_name='John Doe', applicant_id=42), dict(congressperson_name='Roger That', applicant_id=13) ] cache.clear() secondary_data = sample_reimbursement_data.copy() secondary_data['applicant_id'] = 42 secondary_data['congressperson_name'] = 'John Doe' secondary_data['document_id'] = 13 Reimbursement.objects.create(**secondary_data) resp = self.client.get(self.url) content = loads(resp.content.decode('utf-8')) self.assertEqual(2, content['count']) self.assertEqual(expected, content['results'])
def test_contents(self): expected = [ dict(congressperson_name='John Doe', applicant_id=42), dict(congressperson_name='Roger That', applicant_id=13) ] cache.clear() secondary_data = sample_reimbursement_data.copy() secondary_data['applicant_id'] = 42 secondary_data['congressperson_name'] = 'John Doe' secondary_data['document_id'] = 13 Reimbursement.objects.create(**secondary_data) resp = self.client.get(self.url) content = loads(resp.content.decode('utf-8')) self.assertEqual(2, content['count']) self.assertEqual(expected, content['results'])
def test_contents(self): expected = [ dict(subquota_description='Another subquota', subquota_number=42), dict(subquota_description='Subquota description', subquota_number=4) ] cache.clear() secondary_data = sample_reimbursement_data.copy() secondary_data['document_id'] = 13 secondary_data['year'] = 1971 secondary_data['subquota_number'] = 42 secondary_data['subquota_description'] = 'Another subquota' Reimbursement.objects.create(**secondary_data) resp = self.client.get(self.url) content = loads(resp.content.decode('utf-8')) self.assertEqual(2, content['count']) self.assertEqual(expected, content['results'])