Beispiel #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)
Beispiel #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)
Beispiel #3
0
 def setUp(self):
     self.model = UserModel()
Beispiel #4
0
 def setUp(self):
     self.model = UserModel()