Esempio n. 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('*****@*****.**'))

        blog.delete_all_users()
Esempio n. 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))

        blog.delete_all_users()
Esempio n. 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())
        blog.delete_all_users()
Esempio n. 4
0
    def test_007_add_article(self):
        self.assertEqual(0, blog.get_sum_articles())

        id_user = self.add_user('*****@*****.**')

        with self.assertRaises(blog.SlugNotValidException):
            blog.add_article('slug E! rorsti', 'Artical title', id_user, '',
                             '')

        with self.assertRaises(blog.SlugNotValidException):
            blog.add_article('Slug Eror!@#!@#!@#!@#', 'Title with some char',
                             id_user, '', '')

        with self.assertRaises(blog.TitleNotValidException):
            blog.add_article(' ', 'Title with Not valid Char !sdasd', id_user,
                             '', '')

        with self.assertRaises(blog.TitleNotValidException):
            blog.add_article('correctslug', 'not Valid Title !sdasd', id_user,
                             '', '')

        blog.add_article('correctslugsd', 'asda sdasd', id_user, '', '')

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

        with self.assertRaises(blog.ArticleAlreadyExistsException):
            blog.add_article('correctslugsd', 'asda sdasd', id_user, '', '')

        with self.assertRaises(blog.ArticleAlreadyExistsException):
            blog.add_article('', 'ispravan stitle', id_user, '', '')

        self.assertTrue(blog.delete_all_articles())
        self.assertTrue(blog.delete_all_users())
Esempio n. 5
0
    def test_000_delete_all_users(self):

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

        id = self.add_user('*****@*****.**')

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

        self.assertTrue(blog.delete_all_users())

        self.assertEqual(0, blog.get_sum_users())
Esempio n. 6
0
    def test_008_get_articles(self):
        self.assertEqual(0, blog.get_sum_articles())
        self.assertEqual(0, blog.get_sum_users())

        self.add_article(None, '*****@*****.**')
        self.add_article(None, '*****@*****.**')
        self.add_article(None, '*****@*****.**')

        self.assertEqual(3, blog.get_sum_articles())
        self.assertEqual(3, blog.get_sum_users())

        self.assertTrue(blog.delete_all_users())
        self.assertTrue(blog.delete_all_articles())
Esempio n. 7
0
    def test_009_get_article(self):
        self.assertEqual(0, blog.get_sum_articles())
        self.assertEqual(0, blog.get_sum_users())

        id = self.add_article(None, '*****@*****.**')
        id2 = self.add_article(None, '*****@*****.**')
        #didati get artikal sa errorom
        self.assertEqual(2, blog.get_sum_articles())
        self.assertEqual(2, blog.get_sum_users())

        title = blog.get_article(id2).title
        self.assertEqual(title, blog.get_article(id2).title)
        self.assertFalse(blog.get_article('asdasdas'))

        self.assertTrue(blog.delete_all_users())
        self.assertTrue(blog.delete_all_articles())
Esempio n. 8
0
 def tearDown(self):
     blog.delete_all_users()