def test_create_relationship(self): with self.app.app_context(): from src.database.db import init_db, distroy_db, get_db from src.models.question_model import Question, PreQuestion distroy_db(self.app) init_db(self.app) current_transaction = get_db().transaction with current_transaction: test_question_1 = Question( question="Test Question 1", slug="test_question_1", language="en" ) test_question_1.save() test_prequestion_1 = PreQuestion( text = "This is an example prequestion", slug = "test_prequestion_1", language = "en" ) test_prequestion_1.save() rel = test_prequestion_1.questions.connect(test_question_1) pytest.test_question_1 = test_question_1 pytest.test_prequestion_1 = test_prequestion_1 pytest.test_prequestion_question_rel_1 = rel
def test_create_relationship(self): with self.app.app_context(): from src.database.db import get_db, init_db, distroy_db from src.models.question_model import PreQuestion from src.models.survey_model import SurveyVersion distroy_db(self.app) init_db(self.app) current_transaction = get_db().transaction with current_transaction: test_prequestion_1 = PreQuestion( slug="test_prequestion_1", text="This is and example PreQuestion 1", language="en") test_prequestion_1.save() test_surveyversion_1 = SurveyVersion( title="Test SurveyVersion 1") test_surveyversion_1.save() rel = test_surveyversion_1.prequestions.connect( test_prequestion_1) pytest.test_prequestion_1 = test_prequestion_1 pytest.test_surveyversion_1 = test_surveyversion_1 pytest.test_surveyversion_prequestion_rel_1 = rel
def test_create_relationship(self): with self.app.app_context(): from src.database.db import init_db, get_db, distroy_db from src.models.survey_model import Survey distroy_db(self.app) init_db(self.app) current_transaction = get_db().transaction with current_transaction: test_survey_1 = Survey( language="en", slug = "test_survey_1" ) test_survey_1.save() test_survey_2 = Survey( language="fr", slug = "test_survey_2" ) test_survey_2.save() rel = test_survey_1.related_surveys.connect( test_survey_2, { 'reason': 'language', 'description': "These surveys are related" } ) pytest.test_survey_1 = test_survey_1 pytest.test_survey_2 = test_survey_2 pytest.test_survey_survey_rel_1 = rel
def test_create_relationship(self): with self.app.app_context(): from src.database.db import get_db, init_app, distroy_db from src.models.survey_model import Survey, SurveyVersion distroy_db(self.app) init_app(self.app) current_transaction = get_db().transaction with current_transaction: test_Survey_1 = Survey( slug="test_survey_1", language="en" ) test_SurveyVersion_1 = SurveyVersion( title="Test Survey 1" ) test_Survey_1.save() test_SurveyVersion_1.save() rel = test_Survey_1.versions.connect(test_SurveyVersion_1) assert len(test_SurveyVersion_1.survey.all()) == 1 pytest.test_Survey_SurveyVersion_rel_1 = rel pytest.test_Survey_1 = test_Survey_1 pytest.test_SurveyVersion_1 = test_SurveyVersion_1
def test_database_deletion(self): from src import create_app app = create_app(mode='development', static_path='../static', templates_path='../templates', instance_path='../instance') with app.app_context(): from src.database.db import distroy_db distroy_db(app) from neomodel import db labels = [lab for lab in db.cypher_query("CALL db.labels")[0]] assert len(labels) == 0
def test_create_node(self): with self.app.app_context(): from src.database.db import get_db, distroy_db, init_db distroy_db(self.app) init_db(self.app) from src.models.conducted_survey_model import ConductedSurvey transaction_factory = get_db() current_transaction = transaction_factory.transaction with current_transaction: from src.models.conducted_survey_model import ConductedSurvey test_conducted_survey_1 = ConductedSurvey() test_conducted_survey_1.save() pytest.test_conducted_survey_1 = test_conducted_survey_1 pytest.nodeId = test_conducted_survey_1.nodeId
def test_create_node(self): with self.app.app_context(): from src.database.db import get_db, distroy_db, init_db from src.models.survey_model import SurveyVersion distroy_db(self.app) init_db(self.app) current_transaction = get_db().transaction with current_transaction: test_survey_version_1 = SurveyVersion( title="Survey Version 1" ) test_survey_version_1.save() pytest.test_survey_version_1 = test_survey_version_1
def test_set_up(self): with self.app.app_context(): from src.database.db import get_db, init_db, distroy_db from src.models.survey_model import Survey distroy_db(self.app) init_db(self.app) current_transaction = get_db().transaction with current_transaction: test_survey_1 = Survey(slug="test_survey_1", language="en") test_survey_1.save() pytest.test_survey_1 = test_survey_1 # type: Survey
def test_create_answer_node(self): with self.app.app_context(): from src.database.db import get_db, init_db, distroy_db distroy_db(self.app) init_db(self.app) from src.models.answers_model import Answer current_transaction = get_db().transaction with current_transaction: test_answer_1 = Answer(answer="this is an answer 1") test_answer_1.save() node = get_db().cypher_query("MATCH (a:Answer) RETURN a") assert test_answer_1.answer == \ node[0][0][0]._properties['answer'] assert test_answer_1.updatedOn is not None assert test_answer_1.addedOn is not None assert test_answer_1.id is not None
def test_create_node(self): with self.app.app_context(): from src.database.db import get_db, init_db, distroy_db from src.models.conducted_survey_question_model import ConductedSurveyQuestion distroy_db(self.app) init_db(self.app) current_transaction = get_db().transaction with current_transaction: test_conducted_survey_question_1 = ConductedSurveyQuestion() test_conducted_survey_question_1.save() assert test_conducted_survey_question_1.nodeId is not None assert test_conducted_survey_question_1.addedOn is not None assert isinstance(test_conducted_survey_question_1.addedOn, datetime) assert test_conducted_survey_question_1.sentimentSet is True assert test_conducted_survey_question_1.sentimentCalculated is False
def test_create_node(self): with self.app.app_context(): from src.database.db import get_db, distroy_db, init_db distroy_db(self.app) init_db(self.app) from src.models.survey_model import Survey transaction_factory = get_db() current_transaction = transaction_factory.transaction with current_transaction: from src.models.survey_model import Survey test_survey_1 = Survey( slug="test_survey_1", language="en" ) test_survey_1.save() pytest.test_survey_1 = test_survey_1
def test_schema_dump(self): with self.app.app_context(): from src.database.db import get_db, init_db, distroy_db from src.models.survey_model import Survey from src.utils.marshmallow.survey_schema import SurveySchema distroy_db(self.app) init_db(self.app) current_transaction = get_db().transaction with current_transaction: test_survey_1 = Survey( slug="test_survey_1", language="en", ) test_survey_1.save() test_output_1 = SurveySchema().dump(test_survey_1) pytest.test_survey_1 = test_survey_1 pytest.test_output_1_data = test_output_1.data assert bool(test_output_1.errors) is False
def test_schema_dump(self): with self.app.app_context(): from src.database.db import get_db, init_db, distroy_db from src.models.survey_model import SurveyVersion from src.utils.marshmallow.surveyversion_schema import SurveyVersionSchema distroy_db(self.app) init_db(self.app) current_transaction = get_db().transaction with current_transaction: test_surveyversion_1 = SurveyVersion( title="Test SurveyVersion 1", ) test_surveyversion_1.save() pytest.test_surveyversion_1 = test_surveyversion_1 test_output_1 = SurveyVersionSchema().dump(test_surveyversion_1) pytest.test_output_1_data = test_output_1.data pytest.test_output_1_errors = test_output_1.errors assert bool(pytest.test_output_1_errors) == False
def distroy_database(): distroy_db(app)