Exemple #1
0
 def setUp(self):
     self.model = UserModel()
Exemple #2
0
 def setUp(self):
     self.model = UserModel()
Exemple #3
0
class TestUserModel(unittest.TestCase):
    def setUp(self):
        self.model = UserModel()

    def test_create_user(self):
        self.model.collection.remove()
        self.model.create_user({'username': "******", 'password': '******'})
        eq_(self.model.collection.count(), 1)

    def test_check_user(self):
        self.model.collection.remove()
        user_dict = {"username": "******", "password": "******"}
        self.model.create_user(user_dict)

        result = self.model.check_user({
            "username": "******",
            "password": "******"
        })

        # username, pass, _id
        eq_(len(result), 3)

        result = self.model.check_user({"username": "******", "password": ""})

        eq_(result, {})

    def test_username_exists(self):
        self.model.collection.remove()

        result = self.model.username_exists("test")
        eq_(result, 0)

        self.model.create_user({'username': "******", 'password': '******'})

        result = self.model.username_exists("test")
        eq_(result, 1)

    def test_change_password(self):
        self.model.collection.remove()
        user_dict = {"username": "******", "password": "******"}
        self.model.create_user(user_dict)

        self.model.update_password({"username": "******"}, '456')

        result = self.model.check_user({'username': '******', 'password': '******'})
        assert_true(result)

        result = self.model.check_user({
            'username': '******',
            'password': '******'
        })
        assert_false(result)
Exemple #4
0
class TestUserModel(unittest.TestCase):

    def setUp(self):
        self.model = UserModel()


    def test_create_user(self):
        self.model.collection.remove()
        self.model.create_user({'username': "******", 'password': '******'})
        eq_(self.model.collection.count(),1)
    

    def test_check_user(self):
        self.model.collection.remove()
        user_dict = {"username": "******", "password": "******"}
        self.model.create_user(user_dict)

        result = self.model.check_user({"username": "******", "password": "******"})

        # username, pass, _id
        eq_(len(result), 3)

        result = self.model.check_user({"username": "******","password": ""})

        eq_(result, {})


    def test_username_exists(self):
        self.model.collection.remove()
        
        result = self.model.username_exists("test")
        eq_(result, 0)
        
        self.model.create_user({'username': "******", 'password': '******'})

        result = self.model.username_exists("test")
        eq_(result, 1)

    def test_change_password(self):
        self.model.collection.remove()
        user_dict = {"username": "******", "password": "******"}
        self.model.create_user(user_dict)

        self.model.update_password({"username": "******"}, '456')

        result = self.model.check_user({'username': '******', 'password': '******'})
        assert_true(result)

        result = self.model.check_user({'username': '******', 'password': '******'})
        assert_false(result)