Beispiel #1
0
 def test_iterate_two_users(self):
     user1 = generate_user()
     user2 = generate_user()
     with self.create_storage() as storage:
         storage.add(user1, user2)
     with self.create_storage() as storage:
         users = storage.users_iterate()
     self.assertEquals(2, len(list(users)))
Beispiel #2
0
 def test_user_add_different_session(self):
     user = generate_user()
     with self.create_storage() as storage:
         storage.add(user)
     with self.create_storage() as storage:
         read = storage.get_user_by_email(user.email)
         self.assertUser(user, read)
Beispiel #3
0
 def test_iterate_one_user(self):
     user = generate_user()
     with self.create_storage() as storage:
         storage.add(user)
     with self.create_storage() as storage:
         users = storage.users_iterate()
     self.assertEquals(1, len(list(users)))
Beispiel #4
0
 def test_by_activate_token_existing(self):
     with self.create_storage() as storage:
         user = generate_user()
         storage.add(user)
         read = storage.get_user_by_activate_token(
             user.token(ActionType.ACTIVATE))
         self.assertUser(user, read)
Beispiel #5
0
 def test_user_add_different_session(self):
     user = generate_user()
     with self.create_storage() as storage:
         storage.add(user)
     with self.create_storage() as storage:
         read = storage.get_user_by_email(user.email)
         self.assertUser(user, read)
Beispiel #6
0
 def test_iterate_user_unsubscribed(self):
     user = generate_user()
     user.unsubscribed = True
     with self.create_storage() as storage:
         storage.add(user)
     with self.create_storage() as storage:
         users = storage.users_iterate()
     self.assertEquals(0, len(list(users)))
Beispiel #7
0
 def test_user_password_hash_fits_column(self):
     with self.create_storage() as storage:
         user = generate_user()
         user.password_hash = hash(user.password_hash)
         storage.add(user)
     with self.create_storage() as storage:
         read = storage.get_user_by_email(user.email)
         self.assertUser(user, read)
Beispiel #8
0
 def test_user_password_hash_fits_column(self):
     with self.create_storage() as storage:
         user = generate_user()
         user.password_hash = hash(user.password_hash)
         storage.add(user)
     with self.create_storage() as storage:
         read = storage.get_user_by_email(user.email)
         self.assertUser(user, read)
Beispiel #9
0
 def test_user_delete(self):
     user = generate_user()
     with self.create_storage() as storage:
         storage.add(user)
     with self.create_storage() as storage:
         user = storage.get_user_by_email(user.email)
         storage.delete_user(user)
         after_delete = storage.get_user_by_email(user.email)
         self.assertUser(None, after_delete)
Beispiel #10
0
 def test_user_delete(self):
     user = generate_user()
     with self.create_storage() as storage:
         storage.add(user)
     with self.create_storage() as storage:
         user = storage.get_user_by_email(user.email)
         storage.delete_user(user)
         after_delete = storage.get_user_by_email(user.email)
         self.assertUser(None, after_delete)
Beispiel #11
0
 def test_get_users_emails(self):
     user = generate_user()
     with self.create_storage() as storage:
         storage.add(user)
     with self.create_storage() as storage:
         read = storage.get_users_emails(
             'SELECT email FROM user WHERE email="{0}"'.format(user.email))
         self.assertEquals(1, len(read))
         self.assertEquals(user.email, read[0])
Beispiel #12
0
 def test_domain_by_update_token_existing(self):
     user = generate_user()
     domain = generate_domain()
     domain.user = user
     with self.create_storage() as storage:
         storage.add(user, domain)
     with self.create_storage() as storage:
         read = storage.get_domain_by_update_token(domain.update_token)
     self.assertDomain(domain, read)
     self.assertUser(user, read.user)
Beispiel #13
0
 def test_domain_by_update_token_existing(self):
     user = generate_user()
     domain = generate_domain()
     domain.user = user
     with self.create_storage() as storage:
         storage.add(user, domain)
     with self.create_storage() as storage:
         read = storage.get_domain_by_update_token(domain.update_token)
     self.assertDomain(domain, read)
     self.assertUser(user, read.user)
Beispiel #14
0
    def test_update_user(self):
        user = generate_user()
        user.active = False
        with self.create_storage() as storage:
            storage.add(user)

        with self.create_storage() as storage:
            update = storage.get_user_by_email(user.email)
            update.active = True

        with self.create_storage() as storage:
            read = storage.get_user_by_email(user.email)
            self.assertTrue(read.active)
Beispiel #15
0
    def test_update_user(self):
        user = generate_user()
        user.active = False
        with self.create_storage() as storage:
            storage.add(user)

        with self.create_storage() as storage:
            update = storage.get_user_by_email(user.email)
            update.active = True

        with self.create_storage() as storage:
            read = storage.get_user_by_email(user.email)
            self.assertTrue(read.active)
Beispiel #16
0
    def test_clear(self):
        user = generate_user()
        domain = generate_domain()
        domain.user = user
        with self.create_storage() as storage:
            storage.add(user, domain)

        with self.create_storage() as storage:
            storage.clear()

        with self.create_storage() as storage:
            read_domain = storage.get_domain_by_name(domain.user_domain)
            read_user = storage.get_user_by_email(user.email)

        self.assertUser(None, read_user)
        self.assertDomain(None, read_domain)
Beispiel #17
0
    def test_clear(self):
        user = generate_user()
        domain = generate_domain()
        domain.user = user
        with self.create_storage() as storage:
            storage.add(user, domain)

        with self.create_storage() as storage:
            storage.clear()

        with self.create_storage() as storage:
            read_domain = storage.get_domain_by_name(domain.user_domain)
            read_user = storage.get_user_by_email(user.email)

        self.assertUser(None, read_user)
        self.assertDomain(None, read_domain)
Beispiel #18
0
 def test_by_activate_token_existing(self):
     with self.create_storage() as storage:
         user = generate_user()
         storage.add(user)
         read = storage.get_user_by_activate_token(user.token(ActionType.ACTIVATE))
         self.assertUser(user, read)
Beispiel #19
0
 def test_user_add(self):
     with self.create_storage() as storage:
         user = generate_user()
         storage.add(user)
         read = storage.get_user_by_email(user.email)
         self.assertUser(user, read)
Beispiel #20
0
 def test_user_add(self):
     with self.create_storage() as storage:
         user = generate_user()
         storage.add(user)
         read = storage.get_user_by_email(user.email)
         self.assertUser(user, read)