def validate_email(self):
     feature = RegisterUserFeature()
     if not self.data.get('email'):
         self.set_error('email', 'Required')
     elif not feature.email_valid(self.data.get('email')):
         self.set_error('email', 'Invalid email address')
     elif feature.email_taken(self.data.get('email')):
         self.set_error('email', 'Email already taken')
Exemple #2
0
 def test_failing_register_attempt_redirects_back(self):
     response = self.client.post('/register',
                                 data={
                                     'email': '*****@*****.**',
                                     'password1': '123456',
                                     'password2': '1234567'
                                 })
     assert response.status_code == 302
     assert not RegisterUserFeature().email_taken('*****@*****.**')
Exemple #3
0
 def test_can_register_user(self):
     response = self.client.post('/register',
                                 data={
                                     'email': '*****@*****.**',
                                     'password1': '123456',
                                     'password2': '123456'
                                 })
     assert response.status_code == 302
     assert RegisterUserFeature().email_taken('*****@*****.**')
 def setUp(self):
     self.feature = RegisterUserFeature()
class RegisterUserFeatureTest(Test):
    def setUp(self):
        self.feature = RegisterUserFeature()

    def tearDown(self):
        User.delete().execute()

    def register_foobar(self):
        return self.feature.register_user('*****@*****.**', '123456')

    def test_user_can_register(self):
        self.register_foobar()
        assert self.feature.email_taken('*****@*****.**')

    def test_password_is_encrypted(self):
        user = self.register_foobar()
        assert user.password != '123456'

    def test_cannot_register_taken_email(self):
        self.register_foobar()
        with self.assertRaises(RegisterUserFeature.EmailTaken):
            self.register_foobar()

    def test_cannot_register_invalid_email(self):
        with self.assertRaises(RegisterUserFeature.InvalidEmail):
            self.feature.register_user('foobar', '123456')

    def test_cannot_register_empty_password(self):
        with self.assertRaises(RegisterUserFeature.EmptyPassword):
            self.feature.register_user('*****@*****.**', '')

    def test_first_registered_user_is_admin(self):
        user = self.register_foobar()
        assert user.type == User.ADMIN

    def test_second_registered_user_is_employee(self):
        self.register_foobar()
        user = self.feature.register_user('*****@*****.**', '123456')
        assert user.type == User.EMPLOYEE

    def test_cannot_register_taken_email_changing_case(self):
        self.register_foobar()
        with self.assertRaises(RegisterUserFeature.EmailTaken):
            self.feature.register_user('*****@*****.**', '123456')

    def test_cannot_register_email_with_diacritics(self):
        with self.assertRaises(RegisterUserFeature.InvalidEmail):
            self.feature.register_user('fó[email protected]', '123456')
 def register_user(self):
     feature = RegisterUserFeature()
     feature.register_user(
         email=self.data.get('email'),
         password=self.data.get('password1'),
     )
Exemple #7
0
 def setUpClass(self):
     super(UserTest, self).setUpClass()
     feature = RegisterUserFeature()
     self.admin = feature.register_user("*****@*****.**", "123456")
     self.employee = feature.register_user("*****@*****.**", "123456")
 def setUp(self):
     self.feature = RegisterUserFeature()
class RegisterUserFeatureTest(Test):

    def setUp(self):
        self.feature = RegisterUserFeature()

    def tearDown(self):
        User.delete().execute()

    def register_foobar(self):
        return self.feature.register_user('*****@*****.**', '123456')

    def test_user_can_register(self):
        self.register_foobar()
        assert self.feature.email_taken('*****@*****.**')

    def test_password_is_encrypted(self):
        user = self.register_foobar()
        assert user.password != '123456'

    def test_cannot_register_taken_email(self):
        self.register_foobar()
        with self.assertRaises(RegisterUserFeature.EmailTaken):
            self.register_foobar()

    def test_cannot_register_invalid_email(self):
        with self.assertRaises(RegisterUserFeature.InvalidEmail):
            self.feature.register_user('foobar', '123456')

    def test_cannot_register_empty_password(self):
        with self.assertRaises(RegisterUserFeature.EmptyPassword):
            self.feature.register_user('*****@*****.**', '')

    def test_first_registered_user_is_admin(self):
        user = self.register_foobar()
        assert user.type == User.ADMIN

    def test_second_registered_user_is_employee(self):
        self.register_foobar()
        user = self.feature.register_user('*****@*****.**', '123456')
        assert user.type == User.EMPLOYEE

    def test_cannot_register_taken_email_changing_case(self):
        self.register_foobar()
        with self.assertRaises(RegisterUserFeature.EmailTaken):
            self.feature.register_user('*****@*****.**', '123456')

    def test_cannot_register_email_with_diacritics(self):
        with self.assertRaises(RegisterUserFeature.InvalidEmail):
            self.feature.register_user('fó[email protected]', '123456')
Exemple #10
0
 def setUpClass(self):
     super(UserTest, self).setUpClass()
     feature = RegisterUserFeature()
     self.admin = feature.register_user('*****@*****.**', '123456')
     self.employee = feature.register_user('*****@*****.**', '123456')
Exemple #11
0
 def setUp(self):
     self.feature = LoginFeature()
     self.client = app.test_client()
     self.user = RegisterUserFeature().register_user('*****@*****.**', '123456')
Exemple #12
0
 def register_example_user(self):
     RegisterUserFeature().register_user('*****@*****.**', '123456')