コード例 #1
0
    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
コード例 #2
0
    def test_application_database_initialisation(self):
        """testing initialising the application initialisation"""
        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 init_db
            init_db(app)
        from neomodel import config
        assert config.DATABASE_URL == app.config['NEOMODEL_DATABASE_URI']
        from neomodel import db
        from src.models.survey_model import Survey, SurveyVersion
        from src.models.conducted_survey_model import ConductedSurvey
        from src.models.conducted_survey_question_model import ConductedSurveyQuestion
        from src.models.question_model import Question, PreQuestion
        from src.models.answers_model import Answer

        assert Survey in db._NODE_CLASS_REGISTRY.values()
        assert Question in db._NODE_CLASS_REGISTRY.values()
        assert ConductedSurvey in db._NODE_CLASS_REGISTRY.values()
        assert ConductedSurveyQuestion in db._NODE_CLASS_REGISTRY.values()
        assert Answer in db._NODE_CLASS_REGISTRY.values()
        assert SurveyVersion in db._NODE_CLASS_REGISTRY.values()
        assert PreQuestion in db._NODE_CLASS_REGISTRY.values()
コード例 #3
0
ファイル: test_survey_model.py プロジェクト: DIS-SIN/Survista
    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
コード例 #4
0
    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
コード例 #5
0
def test_OPP_validate_Brands_Empty_NonZeroStatus():
    from src.logic_processor.order_products_processor import OPP
    from src.database.db import init_db
    init_db()
    from src.models.Brands import Brands
    b = Brands("Diefei",1)

    resp = OPP.validate_brands(b)
    assert resp == True
コード例 #6
0
def test_OPP_validate_bankaccout_validCheck_ZeroStatus():
    from src.logic_processor.order_products_processor import OPP
    from src.database.db import init_db
    init_db()
    from src.models.BankAccounts import Bankaccount
    p = Bankaccount("HBL","Danish","PK-0123455",1)

    resp = OPP.validate_bankaccount(p)


    assert resp == True
コード例 #7
0
def test_OPP_validate_order_transported_point_Empty_NonZeroStatus():
    from src.logic_processor.order_products_processor import OPP
    from src.database.db import init_db
    init_db()
    from src.models.Orders import Orders
    o = Orders(1,1,None,None,None,None,None,None)

    resp = OPP.validate_order(o)
    resp = json.loads(resp)

    assert resp['status'] != 0
コード例 #8
0
def test_OPP_validate_order_validCheck_ZeroStatus():
    from src.logic_processor.order_products_processor import OPP
    from src.database.db import init_db
    init_db()
    from src.models.Orders import Orders
    p = Orders(1,1,'abc',2000,1000,'lahore',12,1)

    resp = OPP.validate_order(p)


    assert resp == True
コード例 #9
0
def test_OPP_validate_product_emptyCheck_nonZeroStatus():
    from src.logic_processor.order_products_processor import OPP
    from src.database.db import init_db
    init_db()
    from src.models.Products import Products
    p = Products()

    resp = OPP.validate_product(p)
    resp = json.loads(resp)

    assert resp['status'] != 0
コード例 #10
0
def test_OPP_validate_product_nameEmpty_nonZeroStatus():
    from src.logic_processor.order_products_processor import OPP
    from src.database.db import init_db
    init_db()
    from src.models.Products import Products
    p = Products(None,bytearray('abc','utf-8'),1234,None,None,None,1)

    resp = OPP.validate_product(p)
    resp = json.loads(resp)

    assert resp['status'] != 0
コード例 #11
0
def test_OPP_validate_Brands__shopkeeper_id_Empty_NonZeroStatus():
    from src.logic_processor.order_products_processor import OPP
    from src.database.db import init_db
    init_db()
    from src.models.Brands import Brands
    b = Brands("Diefei",None)

    resp = OPP.validate_brands(b)
    resp = json.loads(resp)

    assert resp['status'] != 0
コード例 #12
0
def test_OPP_validate_product_validCheck_ZeroStatus():
    from src.logic_processor.order_products_processor import OPP
    from src.database.db import init_db
    init_db()
    from src.models.Products import Products
    p = Products("abc",bytearray('abc','utf-8'),None,None,121,None,1)

    resp = OPP.validate_product(p)


    assert resp == True
コード例 #13
0
def test_OPP_validate_bankaccount_bank_name_Empty_NonZeroStatus():
    from src.logic_processor.order_products_processor import OPP
    from src.database.db import init_db
    init_db()
    from src.models.BankAccounts import Bankaccount
    b = Bankaccount(None,"Danish",12345,1)

    resp = OPP.validate_bankaccount(b)
    resp = json.loads(resp)

    assert resp['status'] != 0
コード例 #14
0
ファイル: test_survey_model.py プロジェクト: DIS-SIN/Survista
    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
コード例 #15
0
    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
コード例 #16
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
コード例 #17
0
 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
コード例 #18
0
ファイル: test_survey_model.py プロジェクト: DIS-SIN/Survista
    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
コード例 #19
0
    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
コード例 #20
0
    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
コード例 #21
0
    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
コード例 #22
0
 def initialise_database():
     init_db(app)
コード例 #23
0
        help='Change the file name from table_records to whatever you wish')

    parser.add_argument(
        '--getpolygondata',
        default=False,
        action='store_true',
        help='Change the file name from table_records to whatever you wish')

    args = parser.parse_args()

    print("Program Start at ", datetime.now())
    if args.getpolygondata:
        print("Getting Tickers from Polygon")
        get_all_tickers_data()

    print("Getting submissions...")
    # call reddit api to get results
    current_scores, prev_scores = get_submission_generators(
        args.interval, args.sub, args.allsub, args.psaw)

    print("Populating results...")
    results_df = populate_df(current_scores, prev_scores, args.interval)
    filter_df(results_df)

    print("Program Complete at ", datetime.now())


if __name__ == '__main__':
    init_db()
    main()