-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from gm3dmo/moretests
Adding some more tests.
- Loading branch information
Showing
2 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import pytest | ||
|
||
from django.contrib.auth import get_user_model | ||
from django.test import TestCase | ||
|
||
from cmp.views import original_unit, belongsTo | ||
|
||
from cmp.models import Rank | ||
|
||
from cmp import views | ||
|
||
class TestOriginalUnit(TestCase): | ||
|
||
def test_original_unit_with_input_0(self): | ||
|
@@ -78,8 +84,10 @@ def test_original_unit_with_input_22199408(self): | |
class UsersManagersTests(TestCase): | ||
def test_create_user(self): | ||
User = get_user_model() | ||
user = User.objects.create_user(email="[email protected]", password="foo") | ||
self.assertEqual(user.email, "[email protected]") | ||
expected_email = "[email protected]" | ||
user = User.objects.create_user(email=expected_email, password="foo") | ||
self.assertEqual(user.email, expected_email) | ||
self.assertEqual(user.__str__(), expected_email) | ||
self.assertTrue(user.is_active) | ||
self.assertFalse(user.is_staff) | ||
self.assertFalse(user.is_superuser) | ||
|
@@ -115,3 +123,49 @@ def test_create_superuser(self): | |
User.objects.create_superuser( | ||
email="[email protected]", password="foo", is_superuser=False | ||
) | ||
with self.assertRaises(ValueError): | ||
User.objects.create_superuser( | ||
email="[email protected]", password="foo", is_staff=False | ||
) | ||
|
||
|
||
|
||
|
||
@pytest.mark.django_db | ||
class RankModelTest(TestCase): | ||
def test_create_rank(self): | ||
name = "Private" | ||
abbreviation = "Pte" | ||
rank_class = "Other Rank" | ||
rank = Rank.objects.create(name=name, abbreviation=abbreviation, rank_class=rank_class) | ||
self.assertEqual(rank.name, name) | ||
self.assertEqual(rank.abbreviation, abbreviation) | ||
self.assertEqual(rank.rank_class, rank_class) | ||
self.assertEqual(str(rank), name) | ||
|
||
@pytest.mark.django_db | ||
class testViewsModule(TestCase): | ||
def test_powcamps_view(self): | ||
response = self.client.get("/pow-camps/") | ||
self.assertEqual(response.status_code, 200) | ||
self.assertTemplateUsed(response, "cmp/pow-camps.html") | ||
|
||
def test_cemeteries_view(self): | ||
response = self.client.get("/cemeteries/") | ||
self.assertEqual(response.status_code, 200) | ||
self.assertTemplateUsed(response, "cmp/cemeteries.html") | ||
|
||
def test_ranks_view(self): | ||
response = self.client.get("/ranks/") | ||
self.assertEqual(response.status_code, 200) | ||
self.assertTemplateUsed(response, "cmp/ranks.html") | ||
|
||
def test_countries_view(self): | ||
response = self.client.get("/countries/") | ||
self.assertEqual(response.status_code, 200) | ||
self.assertTemplateUsed(response, "cmp/countries.html") | ||
|
||
def test_index_view(self): | ||
response = self.client.get("/") | ||
self.assertEqual(response.status_code, 200) | ||
self.assertTemplateUsed(response, "cmp/index.html") |