
from django.test import TestCase
import datetime
from decimal import *
from transactions.models import Portfolio, Transaction
from securities.models import Security, Price
from django.utils import timezone

# Create your tests here.


class PriceTests(TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_import_historic_quotes(self):
        """Adding Transaction should lead to correct total"""
        sec = Security()
        sec.add('Test', '', '', 'APC.DE', 'Stock')
        p = Price()
        p.import_historic_quotes(years=0.5)
        date = timezone.now() - datetime.timedelta(days=30)
        price = p.get_last_price_from_stock_id(stock_id=sec.find('Test'), before_date=date)
        print(price)
        self.assertEqual(price, None)
@@ -47,85 +47,8 @@
 ime%0A
-from decimal import *%0Afrom transactions.models import Portfolio, Transaction%0A
 from
@@ -99,35 +99,23 @@
 om d
-jango.utils import timezone
+ecimal import *
 %0A%0A# 
@@ -295,16 +295,25 @@
      %22%22%22
+%0A        
 Adding T
@@ -351,16 +351,113 @@
 ct total
+%0A        Test only works as long as we scrape enough years (or date is recent enough)!!!%0A        
 %22%22%22%0A    
@@ -611,51 +611,59 @@
 e = 
-timezone.now() - datetime.timedelta(days=30
+datetime.datetime.strptime('01.08.2014', '%25d.%25m.%25Y'
 )%0A  
@@ -756,29 +756,8 @@
 te)%0A
-        print(price)%0A
     
@@ -786,11 +786,29 @@
 rice
-, None
+.price, Decimal('70.93')
 )

make test work for import quotes