コード例 #1
0
    def test_get_cookbook_steps(self, mock_pf):
        # This asserts that a list of steps is added to the stack when `get_cookbook_steps` if called
        # First do the work:
        test_runner = DummyRunner(Event(self.path_to_event_file))
        test_runner.cmf = CrashMoveFolder(self.path_to_cmf_file)
        initial_step = plugin_controller.get_cookbook_steps(
            test_runner, None, dry_run=True, verify_on_creation=False)
        main_stack.process_stack(initial_step, None)

        # Now get the information out of the mock:
        found_list_of_steps = False
        for call in mock_pf.call_args_list:
            try:
                # print()
                # print('---------------------')
                # print('test_get_cookbook_steps')
                # print(call)
                # print('END:test_get_cookbook_steps')
                # print('---------------------')
                # retrieved_result = call[1]['result']
                retrieved_result = call[1].get('result', None)
                if all([isinstance(stp, Step) for stp in retrieved_result]):
                    # print('found_list_of_steps=True')
                    found_list_of_steps = True
            except TypeError:
                pass

        self.assertTrue(found_list_of_steps)
コード例 #2
0
def get_active_data_step_list(humev_config_path):
    """
    Generates a list of Steps, each of which execucutes a suitable naming convention test
    for a GIS dataset with the `2_Active_data` folder within the crash move folder.
    """
    humev = Event(humev_config_path)
    cmf = CrashMoveFolder(humev.cmf_descriptor_path)
    nc = name_convention.NamingConvention(cmf.data_nc_definition)
    return _step_builer(get_all_gisfiles(cmf), nc, 'data', cmf)
コード例 #3
0
 def setUp(self):
     self.parent_dir = os.path.dirname(
         os.path.dirname(os.path.realpath(__file__)))
     self.dir_to_valid_cmf_des = os.path.join(self.parent_dir, 'example')
     self.path_to_valid_cmf_des = os.path.join(
         self.dir_to_valid_cmf_des, 'cmf_description_flat_test.json')
     self.path_to_event_des = os.path.join(self.dir_to_valid_cmf_des,
                                           'event_description.json')
     self.dummy_runner = DummyRunner(Event(self.path_to_event_des))
コード例 #4
0
 def setUp(self):
     self.parent_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
     self.cmf_descriptor_path = os.path.join(self.parent_dir, 'example', 'cmf_description_flat_test.json')
     self.event_descriptor_path = os.path.join(self.parent_dir, 'example', 'event_description.json')
     self.recipe_file = os.path.join(self.parent_dir, 'example', 'example_single_map_recipe.json')
     self.non_existant_file = os.path.join(self.parent_dir, 'example', 'non-existant-file.json')
     self.cmf = CrashMoveFolder(self.cmf_descriptor_path, verify_on_creation=False)
     self.event = Event(self.event_descriptor_path)
     # self.cmf = CrashMoveFolder(self.cmf_descriptor_path)
     self.lyr_props = LayerProperties(self.cmf, '', verify_on_creation=False)
コード例 #5
0
 def setUp(self):
     self.parent_dir = os.path.dirname(
         os.path.dirname(os.path.realpath(__file__)))
     self.dir_to_valid_cmf_des = os.path.join(self.parent_dir, 'example')
     self.path_to_valid_cmf_des = os.path.join(
         self.dir_to_valid_cmf_des, 'cmf_description_flat_test.json')
     self.path_to_event_des = os.path.join(self.dir_to_valid_cmf_des,
                                           'event_description.json')
     self.cmf = CrashMoveFolder(self.path_to_valid_cmf_des)
     self.lyr_props = LayerProperties(self.cmf,
                                      '',
                                      verify_on_creation=False)
     self.dummy_runner = DummyRunner(Event(self.path_to_event_des))
コード例 #6
0
 def setUp(self):
     self.parent_dir = os.path.dirname(
         os.path.dirname(os.path.realpath(__file__)))
     self.path_to_valid_cmf_des = os.path.join(
         self.parent_dir, 'tests', 'test_data',
         'fixture_cmf_description_flat_test.json')
     self.cmf = CrashMoveFolder(self.path_to_valid_cmf_des)
     self.event = Event(
         os.path.join(self.parent_dir, 'tests', 'test_data',
                      'event_description.json'))
     self.my_mxd_fname = os.path.join(
         self.parent_dir, 'tests', 'test_data',
         'output_arcgis_10_6_reference_landscape_bottom.mxd')
     self.layer_props = LayerProperties(self.cmf, '.lyr')
     self.cookBook = MapCookbook(self.cmf, self.layer_props)
コード例 #7
0
    def setUp(self):
        self.parent_dir = os.path.dirname(
            os.path.dirname(os.path.realpath(__file__)))
        self.path_to_valid_cmf_des = os.path.join(
            self.parent_dir, 'tests', 'test_data',
            'fixture_cmf_description_flat_test.json')
        self.cmf = CrashMoveFolder(self.path_to_valid_cmf_des)
        self.event = Event(
            os.path.join(self.cmf.path, 'event_description.json'))
        self.arcmap_runner = arcmap_runner.ArcMapRunner(self.event)

        # 1) insert map
        self.df1 = mock.Mock(name='data_frame1')
        self.df1.name = 'data_frame1'
        self.df1.elementHeight = 19
        self.df1.elementWidth = 17
        # 2) main map
        self.df2 = mock.Mock(name='data_frame2')
        self.df2.name = 'data_frame2'
        self.df2.elementHeight = 100
        self.df2.elementWidth = 200
        # 3) main map (same size different asspect ratio)
        self.df3 = mock.Mock(name='data_frame3')
        self.df3.name = 'data_frame3'
        self.df3.elementHeight = 50
        self.df3.elementWidth = 400
        # 4) main map - identical to df3
        self.df4 = mock.Mock(name='data_frame4')
        self.df4.name = 'data_frame4'
        self.df4.elementHeight = 50
        self.df4.elementWidth = 400
        # 5) main map - widest, but not the largest area
        self.df5 = mock.Mock(name='data_frame5')
        self.df5.name = 'data_frame5'
        self.df5.elementHeight = 10
        self.df5.elementWidth = 500
        # 6) inset map - identical to df1 in every way including the name
        self.df6 = mock.Mock(name='data_frame6')
        self.df6.name = 'data_frame1'
        self.df6.elementHeight = 19
        self.df6.elementWidth = 17
    def setUp(self):
        self.parent_dir = os.path.dirname(
            os.path.dirname(os.path.realpath(__file__)))
        self.cmf_descriptor_path = os.path.join(
            self.parent_dir, 'example', 'cmf_description_flat_test.json')
        self.cmf = CrashMoveFolder(self.cmf_descriptor_path,
                                   verify_on_creation=False)
        self.event_descriptor_path = os.path.join(self.parent_dir, 'example',
                                                  'event_description.json')
        self.event = Event(self.event_descriptor_path)
        # self.cmf = CrashMoveFolder(self.cmf_descriptor_path)
        self.lyr_props = LayerProperties(self.cmf,
                                         '',
                                         verify_on_creation=False)

        self.recipe_descriptor_path = os.path.join(
            self.parent_dir, 'example', 'example_single_map_recipe.json')
        with open(self.recipe_descriptor_path) as json_file:
            self.recipe_def = json.load(json_file)

        self.recipe = MapRecipe(self.recipe_def, self.lyr_props)
コード例 #9
0
def main(args):
    args = parser.parse_args()
    event = Event(args.eventDescriptionFile)
    runner = ArcProRunner(event)

    recipe_without_positive_iso3_code = ('''{
            "mapnumber": "MA001",
            "category": "Reference",
            "product": "DJI Overview Map",
            "summary": "Overview of DJI with topography displayed",
            "export": true,
            "template": "reference",
            "map_frames": [
                {
                    "name": "Main map",
                    "layers": [
                        {
                            "name": "mainmap-stle-stl-pt-s0-allmaps",
                            "reg_exp": "^[a-z][a-z][a-z]_stle_stl_pt_(.*?)_(.*?)_([phm][phm])(.*?).shp$",
                            "schema_definition": "stle_ste_pt.yml",
                            "definition_query": "fclass IN ('national_capital', 'city', 'capital', 'town')",
                            "display": true,
                            "add_to_legend": true,
                            "label_classes": [
                                {
                                    "class_name": "National Capital",
                                    "expression": "[name]",
                                    "sql_query": "('fclass' = 'national_capital')",
                                    "show_class_labels": true
                                },
                                {
                                    "class_name": "Admin 1 Capital",
                                    "expression": "[name]",
                                    "sql_query": "('fclass' = 'town')",
                                    "show_class_labels": true
                                }
                            ]
                        },
                        {
                            "name": "mainmap-carto-fea-py-s0-allmaps",
                            "reg_exp": "^[a-z][a-z][a-z]_carto_fea_py_(.*?)_(.*?)_([phm][phm])(.*?).shp$",
                            "schema_definition": "null-schema.yml",
                            "definition_query": "",
                            "display": true,
                            "add_to_legend": false,
                            "label_classes": []
                        },
                        {
                            "name": "mainmap-elev-cst-ln-s0-allmaps",
                            "reg_exp": "^[a-z][a-z][a-z]_elev_cst_ln_(.*?)_(.*?)_([phm][phm])(.*?).shp$",
                            "schema_definition": "null-schema.yml",
                            "definition_query": "",
                            "display": true,
                            "add_to_legend": false,
                            "label_classes": []
                        },
                        {
                            "name": "mainmap-admn-ad0-ln-s0-reference",
                            "reg_exp": "^[a-z][a-z][a-z]_admn_ad0_ln_(.*?)_(.*?)_([phm][phm])(.*?).shp$",
                            "schema_definition": "null-schema.yml",
                            "definition_query": "",
                            "display": true,
                            "add_to_legend": false,
                            "label_classes": []
                        },
                        {
                            "name": "mainmap-admn-ad1-ln-s0-reference",
                            "reg_exp": "^[a-z][a-z][a-z]_admn_ad1_ln_(.*?)_(.*?)_([phm][phm])(.*?).shp$",
                            "schema_definition": "admin1_reference.yml",
                            "definition_query": "",
                            "display": true,
                            "add_to_legend": true,
                            "label_classes": []
                        },
                        {
                            "name": "mainmap-phys-riv-ln-s0-reference",
                            "reg_exp": "^[a-z][a-z][a-z]_phys_riv_ln_(.*?)_(.*?)_([phm][phm])(.*?).shp$",
                            "schema_definition": "null-schema.yml",
                            "definition_query": "",
                            "display": true,
                            "add_to_legend": true,
                            "label_classes": []
                        },
                        {
                            "name": "mainmap-admn-ad1-py-s0-reference",
                            "reg_exp": "^[a-z][a-z][a-z]_admn_ad1_py_(.*?)_(.*?)_([phm][phm])(.*?).shp$",
                            "schema_definition": "admin1_reference.yml",
                            "definition_query": "",
                            "display": true,
                            "add_to_legend": true,
                            "label_classes": []
                        },
                        {
                            "name": "mainmap-admn-ad0-ln-s0-surroundingcountries",
                            "reg_exp": "^[a-z][a-z][a-z]_admn_ad0_ln_(.*?)_(.*?)_([phm][phm])(.*?).shp$",
                            "schema_definition": "null-schema.yml",
                            "definition_query": "",
                            "display": true,
                            "add_to_legend": true,
                            "label_classes": []
                        }
                    ]
                }
            ]
        }''')

    layerProperties = LayerProperties(event.cmf_descriptor_path,
                                      '.lyr',
                                      verify_on_creation=False)
    recipe = MapRecipe(recipe_without_positive_iso3_code, layerProperties)
    recipe = runner.get_templates(state=recipe)
    recipe = runner.create_ouput_map_project(state=recipe)
    recipe = runner.build_project_files(state=recipe)

    themes = set()
    themes.add("Health")
    propertiesDict = {}
    propertiesDict['themes'] = themes
    propertiesDict['accessnotes'] = "My super access note"
    recipe = runner.export_maps(state=recipe, properties=propertiesDict)
コード例 #10
0
 def new_event(**kwargs):
     return Event(kwargs['state'])