class TestChain(TestCase): def setUp(self): self.thinker = self.make_user('thinker') self.thinker.save() self.doer = self.make_user('doer') self.doer.save() def test_topic_to_blockchain(self): self.topic = Topic.objects.create( title='Improve test module', body='implement class that autogenerates users', owner=self.thinker, ) #self.topic.create_snapshot(blockchain=1) self.topic.create_snapshot(blockchain=False) self.topic.save() self.assertEqual( TopicSnapshot.objects.filter(topic=self.topic).count(), 1) self.comment = Comment(topic=self.topic, text=""" - {1.5},{?0.5} for coming up with basic class structure, - {?2.5} for implementation, - {?3.5} for testing. Here is the result so far: https://github.com/wefindx/infty2.0/commit/9f096dc54f94c31eed9558eb32ef0858f51b1aec """, owner=self.doer) self.comment.save() # self.comment.create_snapshot(blockchain=1) self.comment.create_snapshot(blockchain=False) self.assertEqual( CommentSnapshot.objects.filter(comment=self.comment).count(), 1)
class APITestCaseAuthorizedUser(APITestCase): def setUp(self): self.username = "******" self.email = "*****@*****.**" self.password = "******" self.testuser = User.objects.create_user( self.username, self.email, is_superuser=False, is_staff=False) self.testuser.set_password(self.password) self.testuser.save() self.client.force_authenticate(user=User.objects.first()) self.topic = Topic.objects.create( title='Test topic 1', owner=self.testuser, ) self.topic_url = reverse('topic-detail', kwargs={'pk': self.topic.pk}) self.comment = Comment( topic=self.topic, # 1. time spent inside "{...}" brackets # 2. estimates of future time needed inside "{?...}" # 3. declared work result - the content of comment text=""" - {1.5},{?0.5} for coming up with basic class structure, - {?2.5} for implementation, - {?13.5} for testing. Here is the result so far: https://github.com/wefindx/infty2.0/commit/9f096dc54f94c31eed9558eb32ef0858f51b1aec """, owner=self.testuser, ) self.comment.save() self.comment_url = reverse( 'comment-detail', kwargs={ 'pk': self.comment.pk }) self.snapshot = self.comment.create_snapshot() self.usd = Currency(label='usd') self.usd.save() self.hprice = HourPriceSnapshot( name='FRED', base=self.usd, data=json.loads(""" {"realtime_start":"2017-07-28","realtime_end":"2017-07-28","observation_start":"1600-01-01","observation_end":"9999-12-31","units":"lin","output_type":1,"file_type":"json","order_by":"observation_date","sort_order":"desc","count":136,"offset":0,"limit":1,"observations":[{"realtime_start":"2017-07-28","realtime_end":"2017-07-28","date":"2017-06-01","value":"26.25"}]}""" ), endpoint= 'https://api.stlouisfed.org/fred/series/observations?series_id=CES0500000003&api_key=0a90ca7b5204b2ed6e998d9f6877187e&limit=1&sort_order=desc&file_type=json', ) self.hprice.save() self.cprice = CurrencyPriceSnapshot( name='FIXER', base=self.usd, data=json.loads(""" {"base":"EUR","date":"2017-07-28","rates":{"AUD":1.4732,"BGN":1.9558,"BRL":3.7015,"CAD":1.4712,"CHF":1.1357,"CNY":7.9087,"CZK":26.048,"DKK":7.4364,"GBP":0.89568,"HKD":9.1613,"HRK":7.412,"HUF":304.93,"IDR":15639.0,"ILS":4.1765,"INR":75.256,"JPY":130.37,"KRW":1317.6,"MXN":20.809,"MYR":5.0229,"NOK":9.3195,"NZD":1.5694,"PHP":59.207,"PLN":4.2493,"RON":4.558,"RUB":69.832,"SEK":9.5355,"SGD":1.5947,"THB":39.146,"TRY":4.1462,"USD":1.1729,"ZAR":15.281}}""" ), endpoint='https://api.fixer.io/latest?base=eur', ) self.cprice.save() self.transaction = Transaction( comment=self.comment, snapshot=self.snapshot, hour_price=self.hprice, currency_price=self.cprice, payment_amount=Decimal(10), payment_currency=self.usd, payment_recipient=self.testuser, payment_sender=self.testuser, hour_unit_cost=(1)) self.transaction.save()