Example #1
0
    def test_002_add_user(self):

        #not valid size
        with self.assertRaises(blog.EmailNotValidSize):
            self.assertTrue(blog.add_user('mla'))

        #not valid email
        with self.assertRaises(blog.EmailNotValidException):
           self.assertTrue(blog.add_user('mladen'))

        #not valid duplicate @
        with self.assertRaises(blog.EmailNotValidException):
           self.assertTrue(blog.add_user('ml@[email protected]'))

        #invalid char ^
        with self.assertRaises(blog.EmailNotValidException):
            self.assertTrue(blog.add_user('mla^[email protected]'))

        #not valid dot at the end of email
        with self.assertRaises(blog.EmailNotValidException):
            self.assertTrue(blog.add_user('[email protected].'))

        self.assertEqual(0, blog.get_sum_users())

        #add new user
        self.add_user('*****@*****.**')

        self.assertEqual(1, blog.get_sum_users())

        #user already exist
        with self.assertRaises(blog.UserAlreadyExistsException):
            self.assertTrue(self.add_user('*****@*****.**'))
Example #2
0
    def test_003_get_user(self):
        #user with given id doesnt exist
        self.assertEqual(0, blog.get_sum_users())

        with self.assertRaises(blog.UserDoesntExist):
            blog.get_user('uOOO1')

        # add new user with given email, get id and check user exists
        id = blog.add_user('*****@*****.**')
        self.assertEqual(1, blog.get_sum_users())

        self.assertTrue(blog.get_user(id))
Example #3
0
    def test_001_get_users(self):

        self.assertEqual(0, blog.get_sum_users())
        #users doesnt exist
        with self.assertRaises(blog.UsersDoesntExist):
            blog.get_users()

        #add 2 users and get list of users
        blog.add_user('*****@*****.**')
        blog.add_user('*****@*****.**')
        blog.add_user('*****@*****.**')
        self.assertEqual(3,blog.get_sum_users())

        self.assertTrue(blog.get_users())
Example #4
0
 def add_user(self, email):
     id_user = blog.add_user(email)
     return id_user
Example #5
0
def add_new_user(username: str, password: str):
    return add_user(username, password)