Commit a9ad5ff9 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

more tests

parent 74162333
...@@ -6,4 +6,5 @@ venv ...@@ -6,4 +6,5 @@ venv
.DS_Store .DS_Store
db.sqlite3 db.sqlite3
*.mo *.mo
.idea .idea
\ No newline at end of file .coverage
\ No newline at end of file
...@@ -2,7 +2,7 @@ from django.conf import settings ...@@ -2,7 +2,7 @@ from django.conf import settings
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.core.cache import cache from django.core.cache import cache
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.test import TestCase, RequestFactory from django.test import TestCase, RequestFactory, override_settings
from django.urls import reverse from django.urls import reverse
from basetheme_bootstrap import user_preferences from basetheme_bootstrap import user_preferences
...@@ -16,6 +16,9 @@ class AboutPageTests(TestCase): ...@@ -16,6 +16,9 @@ class AboutPageTests(TestCase):
class SignUpTests(TestCase): class SignUpTests(TestCase):
def setUp(self):
cache.clear()
def test_works(self): def test_works(self):
response = self.client.get(reverse('basetheme_bootstrap:signup')) response = self.client.get(reverse('basetheme_bootstrap:signup'))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
...@@ -36,6 +39,9 @@ class SignUpTests(TestCase): ...@@ -36,6 +39,9 @@ class SignUpTests(TestCase):
class SuperuserSignUpTests(TestCase): class SuperuserSignUpTests(TestCase):
def setUp(self):
cache.clear()
def test_sign_up_for_superuser(self): def test_sign_up_for_superuser(self):
response = self.client.post(reverse('basetheme_bootstrap:signup'), { response = self.client.post(reverse('basetheme_bootstrap:signup'), {
'username': "userAAA", 'username': "userAAA",
...@@ -64,6 +70,7 @@ class SuperuserSignUpTests(TestCase): ...@@ -64,6 +70,7 @@ class SuperuserSignUpTests(TestCase):
class ChangePasswordTests(TestCase): class ChangePasswordTests(TestCase):
def setUp(self): def setUp(self):
cache.clear()
self.user_pwd = "eil2guj4cuSho2Vai3hu" self.user_pwd = "eil2guj4cuSho2Vai3hu"
self.user_pwd_2 = "aig7thah4eethahdaDae" self.user_pwd_2 = "aig7thah4eethahdaDae"
self.user = get_user_model().objects.create( self.user = get_user_model().objects.create(
...@@ -116,6 +123,7 @@ class ChangePasswordTests(TestCase): ...@@ -116,6 +123,7 @@ class ChangePasswordTests(TestCase):
class ChangeFirstnameTests(TestCase): class ChangeFirstnameTests(TestCase):
def setUp(self): def setUp(self):
cache.clear()
self.user_pwd = "eil2guj4cuSho2Vai3hu" self.user_pwd = "eil2guj4cuSho2Vai3hu"
self.user_pwd_2 = "aig7thah4eethahdaDae" self.user_pwd_2 = "aig7thah4eethahdaDae"
self.user = get_user_model().objects.create( self.user = get_user_model().objects.create(
...@@ -160,6 +168,7 @@ class ChangeFirstnameTests(TestCase): ...@@ -160,6 +168,7 @@ class ChangeFirstnameTests(TestCase):
class DeleteAccountTests(TestCase): class DeleteAccountTests(TestCase):
def setUp(self): def setUp(self):
cache.clear()
self.user_pwd = "eil2guj4cuSho2Vai3hu" self.user_pwd = "eil2guj4cuSho2Vai3hu"
self.user_pwd_2 = "aig7thah4eethahdaDae" self.user_pwd_2 = "aig7thah4eethahdaDae"
self.user = get_user_model().objects.create( self.user = get_user_model().objects.create(
...@@ -185,6 +194,7 @@ class DeleteAccountTests(TestCase): ...@@ -185,6 +194,7 @@ class DeleteAccountTests(TestCase):
class TemplatesTagsTests(TestCase): class TemplatesTagsTests(TestCase):
def setUp(self): def setUp(self):
cache.clear()
self.factory = RequestFactory() self.factory = RequestFactory()
def test_is_active_or_desc(self): def test_is_active_or_desc(self):
...@@ -247,6 +257,7 @@ class TemplatesTagsTests(TestCase): ...@@ -247,6 +257,7 @@ class TemplatesTagsTests(TestCase):
class UserPreferencesTests(TestCase): class UserPreferencesTests(TestCase):
def setUp(self): def setUp(self):
cache.clear()
self.user_pwd = "eil2guj4cuSho2Vai3hu" self.user_pwd = "eil2guj4cuSho2Vai3hu"
self.user = get_user_model().objects.create( self.user = get_user_model().objects.create(
username="user", username="user",
...@@ -280,6 +291,7 @@ class UserPreferencesTests(TestCase): ...@@ -280,6 +291,7 @@ class UserPreferencesTests(TestCase):
default_pref.user = None default_pref.user = None
default_pref.save() default_pref.save()
pref.save() pref.save()
str(pref)
default_pref = user_preferences.get_user_preferences_for_user(None) default_pref = user_preferences.get_user_preferences_for_user(None)
self.assertIsNotNone(default_pref) self.assertIsNotNone(default_pref)
...@@ -300,3 +312,29 @@ class UserPreferencesTests(TestCase): ...@@ -300,3 +312,29 @@ class UserPreferencesTests(TestCase):
cache.get("has_no_user_preferences_model", False) or cache.get("has_no_user_preferences_model", False) or
getattr(settings, "BASETHEME_BOOTSTRAP_USER_PREFERENCE_MODEL_ENABLED", False) getattr(settings, "BASETHEME_BOOTSTRAP_USER_PREFERENCE_MODEL_ENABLED", False)
) )
@override_settings(
BASETHEME_BOOTSTRAP_USER_PREFERENCE_MODEL_ENABLED=False,
)
class SignUpTestsUserPrefDown(SignUpTests):
pass
def test_dummy(self):
self.client.post(reverse('basetheme_bootstrap:signup'), {
'username': "userAAA",
'email': "userAAA@mp.com",
'password1': "user@mp.comuser@mp.comuser@mp.comuser@mp.com",
'password2': "user@mp.comuser@mp.comuser@mp.comuser@mp.com",
'first_name': "user"
})
user_preferences.get_user_preference_class()
user_preferences.get_user_preference_class()
user_preferences.get_user_preferences_for_user(get_user_model().objects.first())
@override_settings(
BASETHEME_BOOTSTRAP_USER_PREFERENCE_MODEL_NAME="AAAAA",
)
class SignUpTestsUserWrongUserPrefLocation(SignUpTests):
pass
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import glob
from setuptools import setup from setuptools import setup
readme = open('README.rst').read() readme = open('README.rst').read()
...@@ -18,5 +17,6 @@ setup( ...@@ -18,5 +17,6 @@ setup(
'django', 'django',
'django-crispy-forms' 'django-crispy-forms'
], ],
license="BSD" license="BSD",
test_suite="runtests.run_all_tests",
) )
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment