Skip to content

Commit 51356c2

Browse files
committed
ticket:1 Add some tests
1 parent 1ead3cd commit 51356c2

5 files changed

Lines changed: 23 additions & 7 deletions

File tree

apps/hello/admin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
from django.contrib import admin
22

3-
# Register your models here.
3+
from .models import Contact
4+
5+
admin.site.register(Contact)

apps/hello/models.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
from django.db import models
22

3-
# Create your models here.
3+
4+
class Contact(models.Model):
5+
name = models.CharField(max_length=200)
6+
lastname = models.CharField(max_length=200)
7+
date_of_birth = models.DateField()
8+
email = models.CharField(max_length=75)
9+
jabber = models.CharField(max_length=75)
10+
skype = models.CharField(max_length=200)
11+
bio = models.TextField()
12+
other_contact = models.TextField()

apps/hello/tests.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from django.test import TestCase
2-
3-
# Create your tests here.
2+
from .models import Contact
43

54

65
class SomeTests(TestCase):
76
def test_math(self):
8-
"put docstrings in your tests"
9-
assert(2 + 2 == 5)
7+
"Check if information is correct"
8+
contact = Contact.objects.get(id=1)
9+
assert(contact.name == u'Oleksii')
10+
assert(contact.lastname == u'Miroshnychenko')
11+
assert(contact.bio == u'Python Dev')
12+
assert(contact.other_contact == u'https://github.com/skl1f')

fortytwo_test_task/settings/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
# Always use forward slashes, even on Windows.
114114
# Don't forget to use absolute paths, not relative paths.
115115
os.path.join(BASE_DIR, 'assets'),
116+
os.path.join(BASE_DIR, 'apps/home/static'),
116117
)
117118

118119

@@ -123,6 +124,7 @@
123124
# Always use forward slashes, even on Windows.
124125
# Don't forget to use absolute paths, not relative paths.
125126
os.path.join(BASE_DIR, 'templates'),
127+
os.path.join(BASE_DIR, 'apps/home/templates'),
126128
)
127129

128130
# Turn off south during test

fortytwo_test_task/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
urlpatterns = patterns(
77
'',
88
# Examples:
9-
# url(r'^$', 'fortytwo_test_task.views.home', name='home'),
9+
url(r'^$', 'hello.views.home', name='home'),
1010
# url(r'^blog/', include('blog.urls')),
1111

1212
url(r'^admin/', include(admin.site.urls)),

0 commit comments

Comments
 (0)