Example #1
0
def get_questionnaire_store(user_id, user_ik):
    # Sets up a single QuestionnaireStore instance throughout app.
    store = g.get('_questionnaire_store')
    if store is None:
        storage = get_storage(user_id, user_ik)
        store = g._questionnaire_store = QuestionnaireStore(storage)

    return store
    def __init__(self, user_id, user_ik):
        self.data = {}

        if user_id and user_ik:
            self.user_id = user_id
            self.user_ik = user_ik
        else:
            raise ValueError("No user_id or user_ik found in session")

        self.storage = get_storage()

        if self.storage.has_data(self.user_id):
            logger.debug("User %s has previous data loading", user_id)
            self.data = self.storage.get(self.user_id, self.user_ik)
 def tearDown(self):
     storage = get_storage()
     storage.clear()
Example #4
0
 def test_database_storage(self):
     settings.EQ_SERVER_SIDE_STORAGE_ENCRYPTION = False
     self.assertIsInstance(get_storage("1", "key"), QuestionnaireStorage)
Example #5
0
 def test_encrypted_storage(self):
     settings.EQ_SERVER_SIDE_STORAGE_ENCRYPTION = True
     self.assertIsInstance(get_storage("1", "key"),
                           EncryptedQuestionnaireStorage)
 def test_database_storage(self):
     settings.EQ_SERVER_SIDE_STORAGE_TYPE = "database"
     settings.EQ_SERVER_SIDE_STORAGE_ENCRYPTION = False
     self.assertIsInstance(get_storage(), DatabaseStorage)
 def test_encrypted_storage(self):
     settings.EQ_SERVER_SIDE_STORAGE_TYPE = "database"
     settings.EQ_SERVER_SIDE_STORAGE_ENCRYPTION = True
     self.assertIsInstance(get_storage(), EncryptedStorage)
 def tearDown(self):
     with self.application.test_request_context():
         get_storage().clear()