Esempio n. 1
0
    def test_action_status_id_error(self):
        with app.app_context():
            action = add_simple_action(db.session)
            waiting_id = ModelStatus.by_name(ModelStatus.WAITING).id
            error_id = ModelStatus.by_name(ModelStatus.ERROR).id

            analysis = add_simple_models_analysis(db.session, action.id)
            for model in analysis.models:
                model.status_id = waiting_id

            analysis = add_simple_models_analysis(db.session, action.id)
            for model in analysis.models:
                model.status_id = error_id

            action_status_count = Action.query.filter(
                Action.action_status_id == error_id).count()
            self.assertEquals(action_status_count, 1)
            self.assertEquals(action.action_status_id, error_id)
Esempio n. 2
0
    def test_action_status_id_processing(self):
        with app.app_context():
            action = add_simple_action(db.session)
            processing_id = ModelStatus.by_name(ModelStatus.PROCESSING).id
            finished_id = ModelStatus.by_name(ModelStatus.FINISHED).id

            analysis = add_simple_models_analysis(db.session, action.id)
            for model in analysis.models:
                model.status_id = finished_id

            analysis = add_simple_models_analysis(db.session, action.id)
            for model in analysis.models:
                model.status_id = processing_id

            action_status_count = Action.query.filter(
                Action.action_status_id == processing_id).count()
            self.assertEquals(action_status_count, 1)
            self.assertEquals(action.action_status_id, processing_id)
Esempio n. 3
0
 def test_duplicating_analysis_deep(self):
     with app.app_context():
         action = add_simple_action(db.session)
         analysis = add_simple_models_analysis(db.session, action.id)
         duplicated = analysis.duplicate({'name': 'Another'})
         self.assertNotEqual(analysis.id, duplicated.id)
         self.assertEqual(analysis.lost_time, duplicated.lost_time)
         self.assertEqual(analysis.models.count(),
                          duplicated.models.count())
Esempio n. 4
0
 def test_analysis_updating_unfinished(self):
     with app.app_context():
         action = add_simple_action(db.session)
         analysis = add_simple_models_analysis(db.session, action.id)
         processing_id = ModelStatus.by_name(ModelStatus.PROCESSING).id
         for model in analysis.models:
             model.status_id = processing_id
         with self.assertRaises(ValueError):
             analysis_data = {'ipp_latitude': 1123123}
             analysis.update(analysis_data, None, None)
Esempio n. 5
0
    def test_action_status_id_finished(self):
        with app.app_context():
            action = add_simple_action(db.session)
            analysis = add_simple_models_analysis(db.session, action.id)
            finished_id = ModelStatus.by_name(ModelStatus.FINISHED).id
            for model in analysis.models:
                model.status_id = finished_id

            analysis = add_simple_models_analysis(db.session, action.id)
            finished_id = ModelStatus.by_name(ModelStatus.FINISHED).id
            for model in analysis.models:
                model.status_id = finished_id
            # two analyses, all finished
            analyses_count = Analysis.query.count()
            self.assertEquals(analyses_count, 2)

            action_status_count = Action.query.filter(
                Action.action_status_id == finished_id).count()
            self.assertEquals(action_status_count, 1)

            # as well as on instance level
            self.assertEquals(action.action_status_id, finished_id)
Esempio n. 6
0
    def test_analysis_status_id_draft(self):
        with app.app_context():
            action = add_simple_action(db.session)
            analysis = add_simple_models_analysis(db.session, action.id)
            analyses_count = Analysis.query.count()
            draft_id = ModelStatus.draft_id()

            for model in analysis.models:
                model.status_id = draft_id
            # only one analysis, no models
            self.assertEquals(analyses_count, 1)
            # and the one has status draft on class level
            draft_count = Analysis.query.filter(
                Analysis.analysis_status_id == draft_id).count()
            self.assertEquals(draft_count, 1)
            # as well as on instance level
            self.assertEquals(analysis.analysis_status_id, draft_id)
Esempio n. 7
0
 def test_analysis_status_id_processing(self):
     with app.app_context():
         action = add_simple_action(db.session)
         analysis = add_simple_models_analysis(db.session, action.id)
         finished_id = ModelStatus.by_name(ModelStatus.FINISHED).id
         processing_id = ModelStatus.by_name(ModelStatus.PROCESSING).id
         for model in analysis.models:
             model.status_id = finished_id
         analysis.models.first().status_id = processing_id
         # only one analysis, all finished but one processing
         analyses_count = Analysis.query.count()
         self.assertEquals(analyses_count, 1)
         # and the one has status processing on class level
         analyses_status_count = Analysis.query.filter(
             Analysis.analysis_status_id == processing_id).count()
         self.assertEquals(analyses_status_count, 1)
         # as well as on instance level
         self.assertEquals(analysis.analysis_status_id, processing_id)
Esempio n. 8
0
 def test_analysis_status_id_error(self):
     with app.app_context():
         action = add_simple_action(db.session)
         analysis = add_simple_models_analysis(db.session, action.id)
         waiting_id = ModelStatus.by_name(ModelStatus.WAITING).id
         error_id = ModelStatus.by_name(ModelStatus.ERROR).id
         for model in analysis.models:
             model.status_id = waiting_id
         analysis.models.first().status_id = error_id
         # only one analysis, all waiting but one error
         analyses_count = Analysis.query.count()
         self.assertEquals(analyses_count, 1)
         # and the one has status error on class level
         analyses_status_count = Analysis.query.filter(
             Analysis.analysis_status_id == error_id).count()
         self.assertEquals(analyses_status_count, 1)
         # as well as on instance level
         self.assertEquals(analysis.analysis_status_id, error_id)
Esempio n. 9
0
    def test_starting_analysis_with_simple_models(self):
        expected_content = {
            "HorDistIPP": "3897890975230495710",
            "ElevChgIPP": "4709831647259734695",
            "HorChgIPP": "4375692374598762347",
            "TrackOffset": "3476273469987234659",
            "DispAngle": "3892345235423495710",
            "FindLocation": "4709831647263434695",
            "Mobility": "4375692374598762346",
        }

        httpretty.register_uri(httpretty.POST,
                               server_path('analysis'),
                               body=json.dumps(expected_content),
                               content_type="application/json")

        with app.app_context():
            action = add_simple_action(db.session)
            analysis = add_simple_models_analysis(db.session, action.id)
            analysis.start_computation()
            for model in analysis.simple_models():
                self.assertEquals(model.result_id,
                                  expected_content[model.name])