Ejemplo n.º 1
0
 def get_form_class(self):
     # TODO: Support email+username login when in username-mode
     if is_email_only():
         return EmailLoginForm
     else:
         return LoginForm
Ejemplo n.º 2
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from django.core.exceptions import ValidationError
from django.test import TestCase
from django.contrib.auth.models import User as AuthUser
from django.utils.unittest.case import skipUnless
from sky_visitor import utils
from sky_visitor.utils import SubclassedUser as User
from sky_visitor.forms import UniqueRequiredEmailField

subclassed_user_only_test = skipUnless(utils.is_subclassed_user(), "Only test these if configured in an sky_visitor subclassed user mode")
username_user_only_test = skipUnless(utils.is_username_user(), "Only test these if configured in username-based user mode")
email_user_only_test = skipUnless(utils.is_email_only(), "Only test these if configured in email-based user mode")
auth_user_only_test = skipUnless(utils.is_auth_user(), "Only test these if configured in auth.User")


class BaseTestCase(TestCase):
    pass

@email_user_only_test
class UniqueEmailTest(BaseTestCase):
    def test_should_error_on_duplicate_email_on_create(self):
        nonunique_email = '*****@*****.**'
        first_user = User.objects.create_user(nonunique_email, password='******')
        with self.assertRaises(ValidationError):
            second_user = User.objects.create_user(nonunique_email, password='******')

    def test_should_error_on_duplicate_email_on_update(self):
Ejemplo n.º 3
0
 def get_form_class(self):
     if is_email_only():
         return EmailRegisterForm
     else:
         return RegisterForm