def test(self): p24 = Privat24Integration() order = OrderFactory.create( sum=452.22, ) order_json = order2json(order) order_crypted = encrypt(get_password(), order_json) fields = { "amt": order.sum, "ccy": "UAH", "order": order_crypted, "details": "something happens", } p24.add_fields(fields) payment = u'amt={amt}&ccy={ccy}&details={details}&ext_details=&pay_way={pay_way}&order={order}&merchant={merchant}&state=test&date=160114183814&ref=test payment&payCountry=UA'.format(**p24.fields) signature = p24.build_signature(payment) data = { 'payment': payment, 'signature': signature, } session = self.client.session session['ORDER_PK'] = order.pk session.save() resp = self.client.post(reverse('payments-return'), data=data) self.assertRedirects(resp, reverse('payments-thank-you'), status_code=302, target_status_code=200)
def test_add_orders_to_strategy(self): """Strategy object can have orders associated.""" strategy = StrategyFactory( user=self.user, asset=self.asset, ) order = OrderFactory(user=self.user, asset_id=self.asset, strategy=strategy) self.assertTrue(strategy.orders.filter(pk=order.pk).exists())
def test(self): order = OrderFactory.create( sum=452.22, ) session = self.client.session session['ORDER_PK'] = order.pk session.save() resp = self.client.get(reverse('cart-order-preview')) self.assertEqual(resp.status_code, 200) self.assertTemplateUsed(resp, 'check/order_preview.html')
def order(): return OrderFactory()
def setUp(self): self.user = UserFactory() self.asset = AssetFactory(symbol="AAPL") self.strategy = StrategyFactory(asset=self.asset) self.order = OrderFactory(strategy=self.strategy, asset_id=self.asset)
def test_create_product(self): OrderFactory.create_batch(3) self.assertEqual(Order.objects.count(), 3)