def setUp(self): self.product1 = PrepaidProduct( issuer_name='Bank of CFPB', prepaid_type='Tax' ) self.product1.save() self.product2 = PrepaidProduct( issuer_name='CFPB Bank', prepaid_type='Tax', other_relevant_parties='Party' ) self.product2.save() effective_date = date(month=2, day=3, year=2019) created_date = make_aware(datetime(month=4, day=1, year=2020)) self.agreement_old = PrepaidAgreement( effective_date=effective_date, created_time=created_date - timedelta(hours=1), product=self.product1, ) self.agreement_old.save() self.agreement_older = PrepaidAgreement( effective_date=effective_date, created_time=created_date - timedelta(hours=2), product=self.product2, ) self.agreement_older.save() self.agreement_new = PrepaidAgreement( effective_date=effective_date, created_time=created_date, product=self.product1, ) self.agreement_new.save()
def test_search_products_issuer_name(self): product1 = PrepaidProduct(issuer_name='Bank of CFPB') product1.save() product2 = PrepaidProduct(issuer_name='Bank of Foo Bar') product2.save() results = search_products(search_term='cfpb', search_field=['issuer_name'], products=PrepaidProduct.objects.all()) self.assertIn(product1, results) self.assertEqual(results.count(), 1)
def test_search_products_all_fields(self): product1 = PrepaidProduct(issuer_name='XYZ Bank') product1.save() product2 = PrepaidProduct(program_manager='xyz manager') product2.save() product3 = PrepaidProduct(name='Foo Bar Product') product3.save() results = search_products(search_term='Xyz', search_field=[], products=PrepaidProduct.objects.all()) self.assertIn(product1, results) self.assertIn(product2, results) self.assertEqual(results.count(), 2)
def test_get_available_filters(self): product1 = PrepaidProduct(issuer_name='Bank of CFPB', prepaid_type='Tax') product1.save() product2 = PrepaidProduct(prepaid_type='Travel') product2.save() products = PrepaidProduct.objects.all() self.assertEqual( get_available_filters(products), { 'prepaid_type': ['Tax', 'Travel'], 'status': [], 'issuer_name': ['Bank of CFPB'] })
def setUp(self): self.product1 = PrepaidProduct( issuer_name='Bank of CFPB', prepaid_type='Tax', status='Active', ) self.product1.save() self.product2 = PrepaidProduct(program_manager='CFPB manager', prepaid_type='Travel', status='Withdrawn') self.product2.save() self.product3 = PrepaidProduct( name='ABC Product', issuer_name='ABC Bank', prepaid_type='Payroll', status='Active', ) self.product3.save()
def test_filter_products(self): product1 = PrepaidProduct(status='Active', prepaid_type='Student') product1.save() product2 = PrepaidProduct(status='Withdrawn', prepaid_type='Travel', issuer_name='XYZ Bank') product2.save() product3 = PrepaidProduct(status='Active', prepaid_type='Payroll', issuer_name='ABC Bank') product3.save() results = filter_products(filters={ 'status': ['Active'], 'prepaid_type': ['Travel', 'Payroll', 'Student'], 'issuer_name': ['ABC Bank', 'XYZ Bank'] }, products=PrepaidProduct.objects.all()) self.assertIn(product3, results) self.assertEqual(results.count(), 1)
def setUp(self): self.product = PrepaidProduct() self.product.save() effective_date = date(month=2, day=3, year=2019) self.agreement_old = PrepaidAgreement( effective_date=effective_date, created_time=timezone.now() - timedelta(hours=1), product=self.product, ) self.agreement_old.save() self.agreement_older = PrepaidAgreement( effective_date=effective_date, created_time=timezone.now() - timedelta(hours=2), product=self.product, ) self.agreement_older.save() self.agreement_new = PrepaidAgreement( effective_date=effective_date, created_time=timezone.now(), product=self.product, ) self.agreement_new.save()
def setUp(self): self.issuer_name1 = 'Bank of CFPB' self.issuer_name2 = 'CFPB Bank' self.issuer_name3 = 'Bank_of CFPB' self.product_name1 = self.issuer_name2 self.product_name2 = self.issuer_name1 self.product_name3 = self.issuer_name2.replace(' ', '_') self.product1 = PrepaidProduct(name=self.product_name1, issuer_name=self.issuer_name1, prepaid_type='Tax') self.product1.save() self.product2 = PrepaidProduct(name=self.product_name2, issuer_name=self.issuer_name2, prepaid_type='Tax', other_relevant_parties='Party') self.product2.save() self.product3 = PrepaidProduct(name=self.product_name3, issuer_name=self.issuer_name3, prepaid_type='Tax', other_relevant_parties='Party') self.product3.save() effective_date = date(month=2, day=3, year=2019) created_date = make_aware(datetime(month=4, day=1, year=2020)) filename1 = self.product_name1.replace(' ', '_') + '_01_04_2020.zip' filename2 = self.product_name2.replace(' ', '_') + '_02_04_2020.zip' filename3 = self.product_name3.replace(' ', '_') + '_03_04_2020.zip' self.path1 = \ self.issuer_name1 + '/' + self.product_name1 + '/20200401' self.path2 = \ self.issuer_name2 + '/' + self.product_name2 + '/20200402' self.path3 = \ self.issuer_name3 + '/' + self.product_name3 + '/20200403' self.direct_download1 = S3_PATH + filename1 self.direct_download2 = S3_PATH + filename2 self.direct_download3 = S3_PATH + filename3 self.agreement_old = PrepaidAgreement( compressed_files_url=self.direct_download1, bulk_download_path=self.path1, filename=filename1, effective_date=effective_date, created_time=created_date - timedelta(hours=1), product=self.product1, ) self.agreement_old.save() self.agreement_older = PrepaidAgreement( compressed_files_url=self.direct_download2, bulk_download_path=self.path2, filename=filename2, effective_date=effective_date, created_time=created_date - timedelta(hours=2), product=self.product2, ) self.agreement_older.save() self.agreement_new = PrepaidAgreement( compressed_files_url=self.direct_download1, bulk_download_path=self.path1, filename=filename1, effective_date=effective_date, created_time=created_date, product=self.product1, ) self.agreement_new.save() self.agreement_newer = PrepaidAgreement( compressed_files_url=self.direct_download3, bulk_download_path=self.path3, filename=filename3, effective_date=effective_date, created_time=created_date + timedelta(hours=1), product=self.product3, ) self.agreement_newer.save()