def setUp(self): # Disconnect signals so there's no problem to use UserProfileFactory signals.post_save.disconnect( dispatch_uid='eff._models.user_profile.create_profile_for_user', sender=User) # Create a external source self.ext_src = ExternalSourceFactory(name='DotprojectMachinalis') # Create 2 client user and 2 companies. self.company = ClientFactory(name='Fake Client 1', external_source=self.ext_src) user = UserFactory(username='******') self.client1 = ClientProfileFactory(user=user, company=self.company) user = UserFactory(username='******') self.company2 = ClientFactory(name='Fake Client 2', external_source=self.ext_src) self.client2 = ClientProfileFactory(user=user, company=self.company2) # Create some commercial documents for company1 self.billing = BillingFactory(client=self.company, amount=Decimal('1000'), date=date(2012, 5, 3), concept="Billing1 " + self.company.name, expire_date=date(2012, 5, 30), payment_date=date(2012, 5, 25)) self.credit_note = CreditNoteFactory(client=self.company, amount=Decimal('100'), date=date(2012, 5, 4), concept="CreditNote1 " + self.company.name) self.payment = PaymentFactory(client=self.company, amount=Decimal('1500'), date=date(2012, 5, 2), concept="Payment1 " + self.company.name, status="Notified") # Create some commercial documents for company2 BillingFactory(client=self.company2, amount=Decimal('1200'), date=date(2012, 5, 1), concept="Billing2 " + self.company.name, expire_date=date(2012, 5, 30), payment_date=date(2012, 5, 25)) CreditNoteFactory(client=self.company2, amount=Decimal('200'), date=date(2012, 5, 2), concept="CreditNote2 " + self.company.name) PaymentFactory(client=self.company2, amount=Decimal('1600'), date=date(2012, 5, 7), concept="Payment2 " + self.company.name, status="Tracking") self.test_client = TestClient()
def setUp(self): # Create some data for tests # An external source ext_src = ExternalSourceFactory(name='DotprojectMachinalis') # A client client = ClientFactory(name='client', external_source=ext_src) # Some commercial documents self.billing = BillingFactory(client=client) self.cnote = CreditNoteFactory(client=client) self.payment = PaymentFactory(client=client)
def test_model_with_sane_values(self): a_user = UserFactory() turing = datetime(1912, 6, 23, 12, 00, tzinfo=utc) a_payment = PaymentFactory( paying_user=a_user, tax_rate=Decimal(0.2), datestamp=turing, transaction_fee=Decimal(0.2), ) self.assertEqual(a_payment.paying_user, a_user) dummy_model_type = ContentType.objects.get_for_model(DummyModel) self.assertEqual(a_payment.content_type, dummy_model_type) self.assertEqual(a_payment.fee_value, Decimal(1.00)) self.assertEqual(a_payment.currency, u'GBP') self.assertEqual(a_payment.tax_rate, Decimal(0.2)) self.assertEqual(a_payment.datestamp, turing) self.assertEqual(a_payment.method, u'Stripe') self.assertEqual(a_payment.transaction_fee, Decimal(0.20)) self.assertEqual(a_payment.test_mode, True)
def test_out_of_bounds_tax_rate_raises_exceptions(self): a_payment = PaymentFactory() with self.assertRaises(ValidationError): a_payment.tax_rate = -0.3 a_payment.full_clean()
def test_get_absolute_url(self): a_payment = PaymentFactory() expected_url = '/priced_items/payment/{0}/'.format(a_payment.pk) gau = a_payment.get_absolute_url() self.assertEqual(expected_url, gau)
def test_bogus_currency_raises_exceptions(self): a_payment = PaymentFactory() with self.assertRaises(ValidationError): a_payment.currency = 'potatoes' a_payment.full_clean()
def setUp(self): self.payment = PaymentFactory.create(status='created') self.client = Client()
def setUp(self): self.payment = PaymentFactory.create(status='created')
def test_out_of_bounds_fee_value_raises_exceptions(self): a_payment = PaymentFactory() with self.assertRaises(ValidationError): a_payment.fee_value = -0.3 a_payment.full_clean()