Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
 def setUp(self):
     self.model = UserModel()
Ejemplo n.º 4
0
 def setUp(self):
     self.model = UserModel()