Beispiel #1
0
 def verify_data(self):
     """ verify existing data and create workflow """
     # build workflow based on current data
     builder = WorkflowBuilder(self.operator_options)
     self.workflow = builder.build_workflow(self)    
     
     if self.workflow.ready:
         self.status = ProjectStatus.ReadyForExposure
     else:
         self.status = ProjectStatus.ReadyForMS
     self.errors = self.workflow.errors
     self.exposure = None
     logAPICall.log('input verification completed', logAPICall.INFO)
Beispiel #2
0
    def verify_data(self):
        """ verify existing data and create workflow """
        # build workflow based on current data
        builder = WorkflowBuilder(self.operator_options)
        self.workflow = builder.build_workflow(self)

        if self.workflow.ready:
            self.status = ProjectStatus.ReadyForExposure
        else:
            self.status = ProjectStatus.ReadyForMS
        self.errors = self.workflow.errors
        self.exposure = None
        logAPICall.log('input verification completed', logAPICall.INFO)
Beispiel #3
0
    def test_WorkflowBuilder(self):
        logging.debug('test_BuildWorkflow')
        
        def get_run_exception(func, param):
            try:
                func(param)
            except Exception as ex:
                import traceback
                traceback.print_exc() 
                return ex
            return None

        # empty proj/ms should be enough for testing
        (proj, proj_file) = self.test_CreateProject(True)
        ms = MappingScheme(self.taxonomy) 
        
        builder = WorkflowBuilder(self.operator_options)

        # test cases raising exception
        ###################
        # test case, empty project, should have errors NeedsZone, NeedsCount, NeedsMS
        workflow = builder.build_workflow(proj)
        self.assertTrue(not workflow.ready)
        self.assertEqual(len(workflow.errors), 3)
        self.assertListEqual(workflow.errors, [WorkflowErrors.NeedsZone, 
                                               WorkflowErrors.NeedsCount, 
                                               WorkflowErrors.NeedsMS])
        
        # test case, only zone, should raise exception need count
        proj.set_zones(ZonesTypes.Landuse, self.zone2_path, self.zone2_field)
        workflow = builder.build_workflow(proj)        
        self.assertTrue(not workflow.ready)
        self.assertEqual(len(workflow.errors), 2)
        self.assertListEqual(workflow.errors, [WorkflowErrors.NeedsCount, 
                                               WorkflowErrors.NeedsMS])
        
        # test case, zone / footprint, should raise exception need ms 
        proj.set_footprint(FootprintTypes.Footprint, self.fp_path)
        workflow = builder.build_workflow(proj)        
        self.assertTrue(not workflow.ready)
        self.assertEqual(len(workflow.errors), 1)
        self.assertListEqual(workflow.errors, [WorkflowErrors.NeedsMS])

        # complete footprint / zone / ms to zone, no exception
        proj.ms = ms 
        proj.set_output_type(OutputTypes.Zone)
        workflow = builder.build_workflow(proj)
        self.assertTrue(workflow.ready)
        self.assertEqual(len(workflow.errors), 0)
        
        # test cases no exception
        ###################

        # complete footprint / zone / ms to grid, no exception 
        proj.set_output_type(OutputTypes.Grid)
        workflow = builder.build_workflow(proj)
        self.assertTrue(workflow.ready)
        self.assertEqual(len(workflow.errors), 0)

        # test case, zonecount and ms to grid, no exception
        proj.set_footprint(FootprintTypes.None) # remove footprint
        proj.set_zones(ZonesTypes.LanduseCount, self.zone_path, self.zone_field, self.bldgcount_field)
        proj.ms = ms
        proj.set_output_type(OutputTypes.Grid)
        workflow = builder.build_workflow(proj)
        self.assertTrue(workflow.ready)
        self.assertEqual(len(workflow.errors), 0)
        
        # test case, zonecount and ms to zone, no exception        
        proj.set_output_type(OutputTypes.Zone)
        workflow = builder.build_workflow(proj)
        self.assertTrue(workflow.ready)
        self.assertEqual(len(workflow.errors), 0)

        # test case, complete survey, no exception
        proj.set_survey(SurveyTypes.CompleteSurvey, self.survey_path)
        workflow = builder.build_workflow(proj)
        self.assertTrue(workflow.ready)
        self.assertEqual(len(workflow.errors), 0)
        
        # clean up
        del proj
        os.remove(proj_file)