from datetime import timedelta
from django.utils import timezone
from caspy import models


class TestCurrency:
    currency_data = {
            'code': 'MM',
            'shortcut': 'M',
            'symbol': 'M',
            'long_name': 'Monopoly Money',
        }

    def test_str(self):
        cur_obj = models.Currency(**self.currency_data)
        assert str(cur_obj) == 'MM'


class TestBook:
    def test_null_created_at(self):
        "If created_at isn't set, it should be set to now"
        before = timezone.now()
        book_obj = models.Book(name='Test Book')
        book_obj.set_created_at()
        after = timezone.now()
        assert before <= book_obj.created_at <= after

    def test_nonnull_created_at(self):
        "If created_at is set, it should remain unchanged"
        before = timezone.now() - timedelta(1)
        book_obj = models.Book(name='Test Book', created_at=before)
        book_obj.set_created_at()
        assert book_obj.created_at == before

@@ -113,185 +113,83 @@
     
-currency_data = %7B%0A            'code': 'MM',%0A            'shortcut': 'M',%0A            'symbol': 'M',%0A            'long_name': 'Monopoly Money',%0A        %7D%0A%0A    def test_str(self):
+def test_str(self):%0A        %22String representation should be currency code%22
 %0A   
@@ -223,28 +223,18 @@
 ncy(
-**self.currency_data
+code='USD'
 )%0A  
@@ -267,10 +267,11 @@
 == '
-MM
+USD
 '%0A%0A%0A

Simplify currency str() test