Add VatRate model tests

This commit is contained in:
Tom Price
2015-03-31 18:01:15 +01:00
parent c0522728fe
commit 4f6d2333c0
3 changed files with 24 additions and 10 deletions

View File

@@ -73,13 +73,13 @@ DATABASES = {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
},
'legacy': {
'ENGINE': 'django.db.backends.mysql',
'HOST': 'alfie.codedinternet.com',
'NAME': 'tec_rigs',
'USER': 'tec_rigs',
'PASSWORD': 'xMNb(b+Giu]&',
}
# 'legacy': {
# 'ENGINE': 'django.db.backends.mysql',
# 'HOST': 'alfie.codedinternet.com',
# 'NAME': 'tec_rigs',
# 'USER': 'tec_rigs',
# 'PASSWORD': 'xMNb(b+Giu]&',
# }
}
# User system

17
RIGS/test_models.py Normal file
View File

@@ -0,0 +1,17 @@
from django.test import TestCase
from RIGS import models
class VatRateTestCase(TestCase):
def setUp(self):
models.VatRate.objects.create(start_at='2014-03-01',rate=0.20,comment='test1')
models.VatRate.objects.create(start_at='2016-03-01',rate=0.15,comment='test2')
def test_find_correct(self):
r = models.VatRate.objects.find_rate('2015-03-01')
self.assertEqual(r.comment, 'test1')
r = models.VatRate.objects.find_rate('2016-03-01')
self.assertEqual(r.comment, 'test2')
def test_percent_correct(self):
r = models.VatRate.objects.get(rate=0.20)
self.assertEqual(r.as_percent, 20)

View File

@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.