def test_generatereviews(self): PROFILES_TO_CREATE = 20 ProfileFactory.create_batch(PROFILES_TO_CREATE) call_command('generatereviews', reviews_count=self.REVIEWS_TO_CREATE) review_count = Review.objects.count() self.assertEqual(review_count, self.REVIEWS_TO_CREATE)
def handle(self, *args, **options): try: ProfileFactory.create_batch(options['profile_count']) except IntegrityError as ie: raise CommandError( 'Unable to generate dummy profiles, truncate your database and try again.', ie) except Exception as ex: raise CommandError('Unable to generate dummy profiles.', ex)
def test_generatetransactions(self): PROFILES_TO_CREATE = 10 ProfileFactory.create_batch(size=PROFILES_TO_CREATE) call_command('generatetransactions', transactions_count=self.TRANSACTIONS_TO_CREATE) transaction_count = Transaction.objects.count() self.assertEqual(transaction_count, self.TRANSACTIONS_TO_CREATE)
def test_generate_profiles_working(self): GENERATED_MODELS_COUNT = 25 existing_profiles_count = Profile.objects.count() ProfileFactory.create_batch(GENERATED_MODELS_COUNT) new_profiles_count = Profile.objects.count() self.assertEqual(new_profiles_count, existing_profiles_count + GENERATED_MODELS_COUNT)
def test_view_with_search(self, staff_client, program_data): """ Tests that ReviewFinancialAidView returns the expected results with search """ fin_aid_status = FinancialAidStatus.AUTO_APPROVED profiles = ProfileFactory.create_batch( 4, first_name=factory.Iterator(['match_name', 'x', 'y', 'z']), last_name=factory.Iterator(['x', 'y', 'z', 'match_name']), ) FinancialAidFactory.create_batch( 4, tier_program=program_data.tier_programs["0k"], status=fin_aid_status, user=factory.Iterator([p.user for p in profiles]) ) name_query = 'match_name' url = self.review_url(program_data.program.id, status=fin_aid_status, search_param=name_query) resp = staff_client.get(url) assert resp.status_code == status.HTTP_200_OK financial_aid_objects = resp.context_data["financial_aid_objects"] # Two users should match the search term - one for first_name, one for last_name assert len(financial_aid_objects) == 2 assert all( name_query in (fin_aid.user.profile.first_name, fin_aid.user.profile.last_name) for fin_aid in financial_aid_objects )
def test_view_with_search(self, staff_client, program_data): """ Tests that ReviewFinancialAidView returns the expected results with search """ fin_aid_status = FinancialAidStatus.AUTO_APPROVED profiles = ProfileFactory.create_batch( 4, first_name=factory.Iterator(['match_name', 'x', 'y', 'z']), last_name=factory.Iterator(['x', 'y', 'z', 'match_name']), ) FinancialAidFactory.create_batch( 4, tier_program=program_data.tier_programs["0k"], status=fin_aid_status, user=factory.Iterator([p.user for p in profiles]) ) name_query = 'match_name' url = self.review_url(program_data.program.id, status=fin_aid_status, search_param=name_query) resp = staff_client.get(url) assert resp.status_code == status.HTTP_200_OK financial_aid_objects = resp.context_data["financial_aid_objects"] # Two users should match the search term - one for first_name, one for last_name assert len(financial_aid_objects) == 2 assert all( fin_aid.user.profile.first_name == name_query or fin_aid.user.profile.last_name == name_query for fin_aid in financial_aid_objects )
def setUpTestData(cls): cls.created_by, cls.sent_to = ProfileFactory.create_batch(size=2) cls.TRANSACTION_URL = f'/transaction/{cls.sent_to.handle}' cls.data_payload = { 'date': timezone.now().strftime('%m/%d/%Y'), 'amount': 1234, 'currency': 'USD', 'is_requester_principal': True, 'proof_receipt': TransactionFactory.create_proof_receipt() }