Exemplo n.º 1
0
 def setUp(self):
     self.db_context = TestDBContext.db_context
     self.access_user = UsersAccessor(self.db_context)
Exemplo n.º 2
0
class UsersAccessorTest(unittest.TestCase):
    def setUp(self):
        self.db_context = TestDBContext.db_context
        self.access_user = UsersAccessor(self.db_context)

    def testConstructor(self):
        assert self.access_user is not None

    def testUserList(self):
        assert self.access_user.get_user_list().count > 3

    def testGetUser(self):
        first = self.access_user.get_user_list()[0]
        assert self.access_user.get_user(first.user_id) is not None

    def testUpdateUser(self):
        user = self.access_user.get_user_list()[0]
        assert user.username != "TEST"
        user.username = "******"
        assert self.access_user.update_user(user)
        assert self.access_user.get_user(user.user_id).username == "TEST"

    def testInsertUser(self):
        count1 = len(self.access_user.get_user_list())
        self.access_user.insert_user(User("testy", User.ROLE_CONSUMER, "*****@*****.**", "hash", "McTesterson", "Testy"))
        count2 = len(self.access_user.get_user_list())
        assert count2 > count1


    def testDeleteUser(self):
        assert self.access_user.get_user(1) is not None
        assert self.access_user.delete_user(1)
        assert self.access_user.get_user(1) is None