Skip to content

Commit

Permalink
Fixed coverage to cover modules only
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinali1 committed May 24, 2015
1 parent 450b936 commit 79fa7a2
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 90 deletions.
Empty file removed forex/management/__init__.py
Empty file.
Empty file.
9 changes: 0 additions & 9 deletions forex/management/commands/hello.py

This file was deleted.

8 changes: 6 additions & 2 deletions forex/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import models
from django.db.models import Manager
from django.core.validators import MinValueValidator

# Import misc packages
import numpy as np
Expand Down Expand Up @@ -92,8 +93,11 @@ class CurrencyPrices(models.Model):
date = models.DateField()

# Price Data per $1 of US
ask_price = models.DecimalField(max_digits=20, decimal_places=4,)
bid_price = models.DecimalField(max_digits=20, decimal_places=4, blank=True, null=True)
ask_price = models.DecimalField(max_digits=20, decimal_places=4,
validators=[MinValueValidator(Decimal('0.00'))])
bid_price = models.DecimalField(max_digits=20, decimal_places=4,
validators=[MinValueValidator(Decimal('0.00'))],
blank=True, null=True)

# Add custom managers
objects=CurrencyPricesManager()
Expand Down
16 changes: 0 additions & 16 deletions forex/tests/.coveragerc

This file was deleted.

4 changes: 0 additions & 4 deletions forex/tests/factories.py

This file was deleted.

45 changes: 28 additions & 17 deletions forex/tests/models_tests.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Tests for the models of the forex app."""
from django.test import TestCase
from ..models import Currency, CurrencyPrices
from django.core.validators import ValidationError
from datetime import date
from decimal import Decimal

# from . import factories
# Import models
from ..models import Currency, CurrencyPrices


class DummyModelTestCase(TestCase):
Expand Down Expand Up @@ -38,6 +39,11 @@ def setUp(self):
ask_price = 7,
bid_price = 8)

def field_tests(self):
required_fields = [u'id', 'name', 'symbol', 'ascii_symbol', 'num_code', 'digits', 'description']
actual_fields = [field.name for field in Currency._meta.fields]
self.assertEqual(set(required_fields), set(actual_fields))

def test_dataframe_generation_base(self):
test_curr1 = Currency.objects.get(symbol="TEST")
df = test_curr1.generate_dataframe()
Expand Down Expand Up @@ -66,29 +72,34 @@ def setUp(self):
date=date(2015,1,1),
ask_price = 3,
bid_price = 4)

def test_mid_price(self):

def field_tests(self):
required_fields = ['id', 'currency', 'date', 'ask_price', 'bid_price']
actual_fields = [field.name for field in CurrencyPrices._meta.fields]
self.assertEqual(set(required_fields), set(actual_fields))

def test_ask_price_min_validation(self):
test_curr1 = Currency.objects.get(symbol="TEST")
price = CurrencyPrices.objects.get(currency=test_curr1, date=date(2015,1,1))
price.ask_price = 3
price.bid_price = 4
price.ask_price = 0
price.save()
self.assertEqual(price.mid_price, Decimal('3.5'))
self.assertEqual(price.ask_price, Decimal('0'))

def test_mid_price_negative(self):
price.ask_price = -1
# try:
# price.save()
# raise AssertionError("Ask Price cannot be less than zero")
# except ValidationError:
# pass


def test_mid_price(self):
test_curr1 = Currency.objects.get(symbol="TEST")
price = CurrencyPrices.objects.get(currency=test_curr1, date=date(2015,1,1))
price.ask_price = -1
price.ask_price = 3
price.bid_price = 4
price.save()
midprice = price.mid_price
self.assertEqual(midprice, Decimal('1.5'))

price.ask_price = 2
price.bid_price = -8
price.save()
self.assertEqual(price.mid_price, Decimal('-3'))

self.assertEqual(price.mid_price, Decimal('3.5'))

def test_ask_us(self):
test_curr1 = Currency.objects.get(symbol="TEST")
Expand Down
28 changes: 0 additions & 28 deletions forex/tests/south_settings.py

This file was deleted.

Empty file removed forex/tests/test_app/__init__.py
Empty file.
Empty file removed forex/tests/test_app/models.py
Empty file.
1 change: 0 additions & 1 deletion forex/tests/test_app/templates/400.html

This file was deleted.

1 change: 0 additions & 1 deletion forex/tests/test_app/templates/500.html

This file was deleted.

1 change: 0 additions & 1 deletion forex/tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@

INTERNAL_APPS = [
'forex',
#'forex.tests.test_app',
]

INSTALLED_APPS = EXTERNAL_APPS + INTERNAL_APPS
Expand Down
11 changes: 0 additions & 11 deletions forex/tests/urls.py

This file was deleted.

0 comments on commit 79fa7a2

Please sign in to comment.