def testNameForCurrentTask(self):
     """
     Test retrieving friendly name for currenttask
     """
     scenario_layer = make_scenario_layer()
     scenario_registry = ScenarioRegistry(source_layer=scenario_layer,
                                          id_field='id',
                                          name_field='name',
                                          meshblock_electorate_layer=None)
     context = LinzRedistrictingContext(scenario_registry=scenario_registry)
     context.task = LinzRedistrictingContext.TASK_GN
     self.assertEqual(context.get_name_for_current_task(),
                      'General (North Island)')
     context.task = LinzRedistrictingContext.TASK_GS
     self.assertEqual(context.get_name_for_current_task(),
                      'General (South Island)')
     context.task = LinzRedistrictingContext.TASK_M
     self.assertEqual(context.get_name_for_current_task(), 'Māori')
 def testTitle(self):
     """
     Test title updates
     """
     scenario_layer = make_scenario_layer()
     scenario_registry = ScenarioRegistry(source_layer=scenario_layer,
                                          id_field='id',
                                          name_field='name',
                                          meshblock_electorate_layer=None)
     context = LinzRedistrictingContext(scenario_registry=scenario_registry)
     context.task = LinzRedistrictingContext.TASK_GS
     context.scenario = 1
     widget = LinzRedistrictingDockWidget(context=context, iface=IFACE)
     self.assertEqual(
         widget.windowTitle(),
         'Redistricting - General (South Island) - Scenario 1')
     context.task = LinzRedistrictingContext.TASK_GN
     context.scenario = 3
     widget.update_dock_title(context=context)
     self.assertEqual(
         widget.windowTitle(),
         'Redistricting - General (North Island) - scenario 3')
 def testBasic(self):
     """
     Test getters/settings
     """
     scenario_layer = make_scenario_layer()
     scenario_registry = ScenarioRegistry(source_layer=scenario_layer,
                                          id_field='id',
                                          name_field='name',
                                          meshblock_electorate_layer=None)
     context = LinzRedistrictingContext(scenario_registry=scenario_registry)
     self.assertIn(context.task, (LinzRedistrictingContext.TASK_GN,
                                  LinzRedistrictingContext.TASK_GS,
                                  LinzRedistrictingContext.TASK_M))
     context.task = LinzRedistrictingContext.TASK_GS
     self.assertEqual(context.task, LinzRedistrictingContext.TASK_GS)
     self.assertIsNotNone(context.scenario)
     context.scenario = 10
     self.assertEqual(context.scenario, 10)
     context.set_scenario(3)
     self.assertEqual(context.scenario, 3)