Beispiel #1
0
class WriterModelTest(unittest.TestCase):
    '''
    Test class to test behaviours of the [Class] class
    Args:
        unittest.TestCase : Test case class that helps create test cases
    '''

    def setUp(self):
        '''
        Set up method that will run before every Test
        '''
        self.writer = Writer(password = '******')


    def test_password_setter(self):
        self.assertTrue(self.writer.pass_secure is not None)


    def test_no_access_password(self):
        with self.assertRaises(AttributeError):
            self.writer.password


    def test_password_verification(self):
        self.assertTrue(self.writer.verify_password('aggy'))
Beispiel #2
0
class CommentModelTest(unittest.TestCase):
    def setUp(self):
        self.new_writer = Writer(username='******',
                                 password='******',
                                 email='*****@*****.**')
        self.new_post = Post(post_title='Test', post_content='Posts test')
        self.new_comment = Comment(id=1,
                                   comment='Test comment',
                                   writer=self.new_writer)

    def test_password_setter(self):
        self.assertTrue(self.new_writer.pass_secure is not None)

    def test_no_access_password(self):
        with self.assertRaises(AttributeError):
            self.new_writer.password

    def test_password_verification(self):
        self.assertTrue(self.new_writer.verify_password('potato'))

        # self.new_comment.query.delete()

    def test_check_instance_variables(self):
        self.assertEquals(self.new_comment.comment, 'Test comment')
        self.assertEquals(self.new_comment.writer, self.new_writer)
Beispiel #3
0
class WriterModelTest(unittest.TestCase):
    def setUp(self):
        self.new_writer = Writer(password='******')

    def test_password_setter(self):
        self.assertTrue(self.new_writer.pass_secure is not None)

    def test_password_verification(self):
        self.assertTrue(self.new_writer.verify_password('hello'))
Beispiel #4
0
class UserModelTest(unittest.TestCase):
    def setUp(self):
        self.new_writer = Writer(password='******')
        self.new_writer2 = Writer(password='******')

    def test_password_setter(self):
        self.assertTrue(self.new_writer.password_hash is not None)

    def test_no_access_password(self):
        with self.assertRaises(AttributeError):
            self.new_writer.password

    def test_password_verification(self):
        self.assertTrue(self.new_writer.verify_password('password'))
        self.assertFalse(self.new_writer.verify_password('testing'))

    def test_password_salts_are_random(self):
        self.assertTrue(
            self.new_writer.password_hash != self.new_writer2.password_hash)
Beispiel #5
0
class WriterModelTest(unittest.TestCase):
    def setUp(self):
        self.new_writer = Writer(password='******')

    def test_password_setter(self):
        self.assertTrue(self.new_writer.pass_secure is not None)

    def test_no_access_password(self):
        with self.assertRaises(AttributeError):
            self.new_writer.password

    def test_password_verification(self):
        self.assertTrue(self.new_writer.verify_password('bella'))
Beispiel #6
0
class WriterModelTest(unittest.TestCase):
    def setUp(self):
        self.new_writer=Writer(password='******')
        '''
        we then need to confirm that after the password is hashed the variable containsa value
        '''
    def test_password_hasher(self):
        self.assertTrue(self.new_writer .pass_secure is not None)

    def no_access(self):
        with self.assertRaises(AttributeError):
            self.new_writer.password
            '''
            we  test to see our hashed password can be confirmed
            '''

    def test_verification(self):
        self.assertTrue(self.new_writer.verify_password('car'))