示例#1
0
    def test_close_time_only(self):

        dycast_parameters = test_helper_functions.get_dycast_parameters()
        risk_service = risk_service_module.RiskService(dycast_parameters)

        comparative_test_service = comparative_test_service_module.ComparativeTestService(dycast_parameters)
        session = database_service.get_sqlalchemy_session()

        riskdate = datetime.date(int(2016), int(3), int(25))
        gridpoints = geography_service.generate_grid(dycast_parameters)

        clusters_per_point_query = risk_service.get_clusters_per_point_query(session, gridpoints, riskdate)
        clusters_per_point = risk_service.get_clusters_per_point_from_query(clusters_per_point_query)

        risk_service.enrich_clusters_per_point_with_close_space_and_time(clusters_per_point)

        # Compare to old query
        daily_cases_query = comparative_test_service.get_daily_cases_query(session,
                                                                           riskdate)
        for point in gridpoints:
            cases_in_cluster_query = comparative_test_service.get_cases_in_cluster_query(daily_cases_query,
                                                                                         point)
            count_old = comparative_test_service.get_close_time_only(cases_in_cluster_query)

            for cluster in clusters_per_point:
                if cluster.point.equals(geography_service.get_shape_from_sqlalch_element(point)):
                    self.assertEquals(cluster.close_in_time, count_old)
示例#2
0
    def test_get_clusters_per_point_query(self):

        dycast_parameters = test_helper_functions.get_dycast_parameters(large_dataset=True)
        risk_service = risk_service_module.RiskService(dycast_parameters)
        comparative_test_service = comparative_test_service_module.ComparativeTestService(dycast_parameters)

        session = database_service.get_sqlalchemy_session()

        riskdate = datetime.date(int(2016), int(3), int(25))
        gridpoints = geography_service.generate_grid(dycast_parameters)

        clusters_per_point_query = risk_service.get_clusters_per_point_query(session, gridpoints, riskdate)
        clusters_per_point = risk_service.get_clusters_per_point_from_query(clusters_per_point_query)

        daily_cases_query = comparative_test_service.get_daily_cases_query(session, riskdate)

        for cluster in clusters_per_point:
            point_wkt_element = geography_service.get_wktelement_from_wkt(cluster.point.wkt)

            cases_in_cluster_query = comparative_test_service.get_cases_in_cluster_query(daily_cases_query,
                                                                                         point_wkt_element)

            vector_count_new = cluster.get_case_count()
            vector_count_old = database_service.get_count_for_query(cases_in_cluster_query)

            self.assertEqual(vector_count_new, vector_count_old)
示例#3
0
    def test_get_daily_cases_query_old(self):

        dycast_parameters = test_helper_functions.get_dycast_parameters()
        comparative_test_service = comparative_test_service_module.ComparativeTestService(dycast_parameters)

        session = database_service.get_sqlalchemy_session()

        riskdate = datetime.date(int(2016), int(3), int(25))

        daily_cases_query = comparative_test_service.get_daily_cases_query(session, riskdate)
        count = database_service.get_count_for_query(daily_cases_query)

        self.assertGreater(count, 0)
示例#4
0
    def test_get_cases_in_cluster_query_old(self):

        dycast_parameters = test_helper_functions.get_dycast_parameters()
        comparative_test_service = comparative_test_service_module.ComparativeTestService(dycast_parameters)

        session = database_service.get_sqlalchemy_session()

        riskdate = datetime.date(int(2016), int(3), int(25))

        gridpoints = geography_service.generate_grid(dycast_parameters)
        point = gridpoints[0]

        daily_cases_query = comparative_test_service.get_daily_cases_query(session, riskdate)

        cases_in_cluster_query = comparative_test_service.get_cases_in_cluster_query(daily_cases_query, point)
        vector_count = database_service.get_count_for_query(cases_in_cluster_query)

        self.assertGreater(vector_count, 0)