def test_getUser(self):
        # Initialize and close the initial database.
        self.initialDatabase.execute(
            "CREATE TABLE Users (Id char(9),AccessType STRING);")
        self.initialDatabase.execute(
            "CREATE TABLE Sessions (Id char(9),StartTime BIGINT,EndTime BIGINT);"
        )
        self.initialDatabase.execute(
            "INSERT INTO Users VALUES (\"000000001\",\"AUTHORIZED\");")
        self.initialDatabase.execute(
            "INSERT INTO Users VALUES (\"000000002\",\"ADMIN\");")
        self.initialDatabase.commit()
        self.initialDatabase.close()

        # Set the static database and assert the users are correct.
        DatabaseManager.staticDatabaseManager = DatabaseManager.DatabaseManager(
            self.databaseFile)
        self.assertEqual(
            DatabaseManager.getUser("000000001").getId(), "000000001",
            "Id is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000001").getAccessType(), "AUTHORIZED",
            "Access type is incorrect.")
        self.assertNotEqual(
            DatabaseManager.getUser("000000001").getSessionTime(), 0,
            "Session time is zero.")
        self.assertEqual(
            DatabaseManager.getUser("000000002").getId(), "000000002",
            "Id is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000002").getAccessType(), "ADMIN",
            "Access type is incorrect.")
        self.assertNotEqual(
            DatabaseManager.getUser("000000002").getSessionTime(), 0,
            "Session time is zero.")
        self.assertEqual(
            DatabaseManager.getUser("000000003").getId(), "000000003",
            "Id is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000003").getAccessType(),
            "UNAUTHORIZED", "Access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000003").getSessionTime(), 0,
            "Session time is non-zero.")
	def idSwiped(self,id):
		StateManager.idSwiped(DatabaseManager.getUser(id))
    def test_toggleAccessTypeIdSwiped(self):
        CuT = StateManager.StateManager()

        # Set the initial state.
        state = CuT.states["ToggleAccessType"]
        CuT.setStateByName("ToggleAccessType")
        self.assertEqual(state.currentUser, None, "Initial user is incorrect.")

        # Swipe an id and assert the user and access type are correct.
        CuT.idSwiped(self.testUser)
        self.assertEqual(CuT.getState().getName(), "ToggleAccessType",
                         "State is incorrect.")
        self.assertEqual(state.currentUser, self.testUser.getId(),
                         "User is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000000").getAccessType(), "AUTHORIZED",
            "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000001").getAccessType(),
            "UNAUTHORIZED", "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000002").getAccessType(), "ADMIN",
            "User access type is incorrect.")
        self.testUser = DatabaseManager.getUser(self.testUser.getId())

        # Swipe an id and assert the user and access type are correct.
        CuT.idSwiped(self.testUser)
        self.assertEqual(CuT.getState().getName(), "ToggleAccessType",
                         "State is incorrect.")
        self.assertEqual(state.currentUser, self.testUser.getId(),
                         "User is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000000").getAccessType(), "ADMIN",
            "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000001").getAccessType(),
            "UNAUTHORIZED", "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000002").getAccessType(), "ADMIN",
            "User access type is incorrect.")
        self.testUser = DatabaseManager.getUser(self.testUser.getId())

        # Swipe an id and assert the user and access type are correct.
        CuT.idSwiped(self.testUser)
        self.assertEqual(CuT.getState().getName(), "ToggleAccessType",
                         "State is incorrect.")
        self.assertEqual(state.currentUser, self.testUser.getId(),
                         "User is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000000").getAccessType(),
            "UNAUTHORIZED", "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000001").getAccessType(),
            "UNAUTHORIZED", "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000002").getAccessType(), "ADMIN",
            "User access type is incorrect.")
        self.testUser = DatabaseManager.getUser(self.testUser.getId())

        # Swipe an id and assert the user and access type are correct.
        CuT.idSwiped(self.testUser)
        self.assertEqual(CuT.getState().getName(), "ToggleAccessType",
                         "State is incorrect.")
        self.assertEqual(state.currentUser, self.testUser.getId(),
                         "User is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000000").getAccessType(), "AUTHORIZED",
            "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000001").getAccessType(),
            "UNAUTHORIZED", "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000002").getAccessType(), "ADMIN",
            "User access type is incorrect.")
        self.testUser = DatabaseManager.getUser(self.testUser.getId())

        # Swipe an id and assert the user and access type are correct.
        CuT.idSwiped(self.testUnauthorizedUser)
        self.assertEqual(CuT.getState().getName(), "ToggleAccessType",
                         "State is incorrect.")
        self.assertEqual(state.currentUser, self.testUnauthorizedUser.getId(),
                         "User is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000000").getAccessType(), "AUTHORIZED",
            "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000001").getAccessType(),
            "UNAUTHORIZED", "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000002").getAccessType(), "ADMIN",
            "User access type is incorrect.")

        # Swipe an id and assert the user and access type are correct.
        CuT.idSwiped(self.testAdminUser)
        self.assertEqual(CuT.getState().getName(), "ToggleAccessType",
                         "State is incorrect.")
        self.assertEqual(state.currentUser, self.testAdminUser.getId(),
                         "User is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000000").getAccessType(), "AUTHORIZED",
            "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000001").getAccessType(),
            "UNAUTHORIZED", "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000002").getAccessType(), "ADMIN",
            "User access type is incorrect.")

        # Swipe an id and assert the user and access type are correct.
        CuT.idSwiped(self.testAdminUser)
        self.assertEqual(CuT.getState().getName(), "ToggleAccessType",
                         "State is incorrect.")
        self.assertEqual(state.currentUser, self.testAdminUser.getId(),
                         "User is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000000").getAccessType(), "AUTHORIZED",
            "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000001").getAccessType(),
            "UNAUTHORIZED", "User access type is incorrect.")
        self.assertEqual(
            DatabaseManager.getUser("000000002").getAccessType(),
            "UNAUTHORIZED", "User access type is incorrect.")