diff --git a/.gitignore b/.gitignore index 1809222a8d07d0745c4d9e4bcde8f073cd34a62a..166439a1e3cc24bb23c6bf971dc9c25191d6cc12 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ venv .DS_Store db.sqlite3 *.mo -.idea \ No newline at end of file +.idea +.coverage \ No newline at end of file diff --git a/basetheme_bootstrap/tests.py b/basetheme_bootstrap/tests.py index 76d5aca2e5281bdadd70121cf6565ef84c74d589..75ea8df8f084b0fc9d35ec246a117a7579a0c336 100644 --- a/basetheme_bootstrap/tests.py +++ b/basetheme_bootstrap/tests.py @@ -2,7 +2,7 @@ from django.conf import settings from django.contrib.auth import get_user_model from django.core.cache import cache 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 basetheme_bootstrap import user_preferences @@ -16,6 +16,9 @@ class AboutPageTests(TestCase): class SignUpTests(TestCase): + def setUp(self): + cache.clear() + def test_works(self): response = self.client.get(reverse('basetheme_bootstrap:signup')) self.assertEqual(response.status_code, 200) @@ -36,6 +39,9 @@ class SignUpTests(TestCase): class SuperuserSignUpTests(TestCase): + def setUp(self): + cache.clear() + def test_sign_up_for_superuser(self): response = self.client.post(reverse('basetheme_bootstrap:signup'), { 'username': "userAAA", @@ -64,6 +70,7 @@ class SuperuserSignUpTests(TestCase): class ChangePasswordTests(TestCase): def setUp(self): + cache.clear() self.user_pwd = "eil2guj4cuSho2Vai3hu" self.user_pwd_2 = "aig7thah4eethahdaDae" self.user = get_user_model().objects.create( @@ -116,6 +123,7 @@ class ChangePasswordTests(TestCase): class ChangeFirstnameTests(TestCase): def setUp(self): + cache.clear() self.user_pwd = "eil2guj4cuSho2Vai3hu" self.user_pwd_2 = "aig7thah4eethahdaDae" self.user = get_user_model().objects.create( @@ -160,6 +168,7 @@ class ChangeFirstnameTests(TestCase): class DeleteAccountTests(TestCase): def setUp(self): + cache.clear() self.user_pwd = "eil2guj4cuSho2Vai3hu" self.user_pwd_2 = "aig7thah4eethahdaDae" self.user = get_user_model().objects.create( @@ -185,6 +194,7 @@ class DeleteAccountTests(TestCase): class TemplatesTagsTests(TestCase): def setUp(self): + cache.clear() self.factory = RequestFactory() def test_is_active_or_desc(self): @@ -247,6 +257,7 @@ class TemplatesTagsTests(TestCase): class UserPreferencesTests(TestCase): def setUp(self): + cache.clear() self.user_pwd = "eil2guj4cuSho2Vai3hu" self.user = get_user_model().objects.create( username="user", @@ -280,6 +291,7 @@ class UserPreferencesTests(TestCase): default_pref.user = None default_pref.save() pref.save() + str(pref) default_pref = user_preferences.get_user_preferences_for_user(None) self.assertIsNotNone(default_pref) @@ -300,3 +312,29 @@ class UserPreferencesTests(TestCase): cache.get("has_no_user_preferences_model", False) or 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 diff --git a/setup.py b/setup.py index ac6a521f70d05b62702a487781ca619d0214e4a1..9ae7f360d9cd40af9c96e3db805aaf623414acb6 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import glob from setuptools import setup readme = open('README.rst').read() @@ -18,5 +17,6 @@ setup( 'django', 'django-crispy-forms' ], - license="BSD" + license="BSD", + test_suite="runtests.run_all_tests", )