def __init__(self): super(VolcanoPolygonPopulationFunction, self).__init__() PopulationExposureReportMixin.__init__(self) # AG: Use the proper minimum needs, update the parameters self.parameters = add_needs_parameters(self.parameters) self.no_data_warning = False self.volcano_names = tr('Not specified in data')
def __init__(self): super(TsunamiEvacuationFunction, self).__init__() PopulationExposureReportMixin.__init__(self) # AG: Use the proper minimum needs, update the parameters self.parameters = add_needs_parameters(self.parameters) self.no_data_warning = False
def __init__(self): super(ITBFatalityFunction, self).__init__() PopulationExposureReportMixin.__init__(self) # AG: Use the proper minimum needs, update the parameters self.parameters = add_needs_parameters(self.parameters) self.hardcoded_parameters = OrderedDict([ ('x', 0.62275231), ('y', 8.03314466), # Model coefficients # Rates of people displaced for each MMI level # should be consistent with defined mmi range below. - Hyeuk ('displacement_rate', { 2: 0.0, 3: 0.0, 4: 0.0, 5: 0.0, 6: 1.0, 7: 1.0, 8: 1.0, 9: 1.0, 10: 1.0 }), # it should be range(2,11) if mmi 10 is included. Otherwise we # should remove mmi 10 in the displacement_rate as well - Hyeuk ('mmi_range', range(2, 11)), ('step', 0.5), ('calculate_displaced_people', True) ]) self.total_fatalities = None
def setUp(self): """Fixture run before all tests.""" self.population_mixin_blank = PopulationExposureReportMixin() self.population_mixin = PopulationExposureReportMixin() self.population_mixin.affected_population['High'] = 100 self.population_mixin.affected_population['Medium'] = 100 self.population_mixin.affected_population['Low'] = 100 self.population_mixin.total_population = 400 self.population_mixin.unaffected_population = ( self.population_mixin.total_population - self.population_mixin.total_affected_population) self.population_mixin.minimum_needs = [ { 'frequency': 'test frequency', 'unit': {'abbreviation': 'u'}, 'name': 'test name 1', 'value': '1', }, { 'frequency': 'test frequency', 'unit': {'abbreviation': 'u'}, 'name': 'test name 2', 'value': '2', } ]
def setUp(self): """Fixture run before all tests.""" self.population_mixin_blank = PopulationExposureReportMixin() self.population_mixin = PopulationExposureReportMixin() self.population_mixin.affected_population['High'] = 100 self.population_mixin.affected_population['Medium'] = 100 self.population_mixin.affected_population['Low'] = 100 self.population_mixin.total_population = 400 self.population_mixin.unaffected_population = ( self.population_mixin.total_population - self.population_mixin.total_affected_population) self.population_mixin.minimum_needs = [{ 'frequency': 'test frequency', 'unit': { 'abbreviation': 'u' }, 'name': 'test name 1', 'value': '1', }, { 'frequency': 'test frequency', 'unit': { 'abbreviation': 'u' }, 'name': 'test name 2', 'value': '2', }]
def __init__(self): super(ContinuousHazardPopulationFunction, self).__init__() PopulationExposureReportMixin.__init__(self) self.impact_function_manager = ImpactFunctionManager() # AG: Use the proper minimum needs, update the parameters self.parameters = add_needs_parameters(self.parameters) self.no_data_warning = False
def __init__(self): super(ClassifiedPolygonHazardPopulationFunction, self).__init__() PopulationExposureReportMixin.__init__(self) # Hazard zones are all unique values from the hazard zone attribute self.hazard_zones = [] # AG: Use the proper minimum needs, update the parameters self.parameters = add_needs_parameters(self.parameters) # Set the question of the IF (as the hazard data is not an event) self.question = tr( 'In each of the hazard zones how many people might be impacted?')
def __init__(self): super(ClassifiedPolygonHazardPopulationFunction, self).__init__() PopulationExposureReportMixin.__init__(self) # Hazard zones are all unique values from the hazard zone attribute self.hazard_zones = [] # AG: Use the proper minimum needs, update the parameters self.parameters = add_needs_parameters(self.parameters) # Set the question of the IF (as the hazard data is not an event) self.question = tr( 'In each of the hazard zones how many people might be impacted.')
def __init__(self): """Constructor.""" super(FloodEvacuationRasterHazardFunction, self).__init__() PopulationExposureReportMixin.__init__(self) self.impact_function_manager = ImpactFunctionManager() # AG: Use the proper minimum needs, update the parameters self.parameters = add_needs_parameters(self.parameters) # Initialize instance attributes for readability (pylint) self.no_data_warning = False
def __init__(self): super(VolcanoPointPopulationFunction, self).__init__() PopulationExposureReportMixin.__init__(self) # AG: Use the proper minimum needs, update the parameters self.parameters = add_needs_parameters(self.parameters) # TODO: alternatively to specifying the question here we should # TODO: consider changing the 'population' metadata concept to 'people' self.question = ( 'In the event of a volcano point how many people might be impacted' ) self.no_data_warning = False self.volcano_names = tr('Not specified in data') self.hazard_zone_attribute = 'radius'
def __init__(self): """Constructor.""" super(FloodEvacuationVectorHazardFunction, self).__init__() PopulationExposureReportMixin.__init__(self) # Use affected field flag (if False, all polygon will be considered as # affected) self.use_affected_field = False # The 'wet' variable self.wet = 'wet' # AG: Use the proper minimum needs, update the parameters self.parameters = add_needs_parameters(self.parameters) self.no_data_warning = False
def __init__(self): super(VolcanoPointPopulationFunction, self).__init__() PopulationExposureReportMixin.__init__(self) # AG: Use the proper minimum needs, update the parameters self.parameters = add_needs_parameters(self.parameters) # TODO: alternatively to specifying the question here we should # TODO: consider changing the 'population' metadata concept to 'people' self.question = ( 'In the event of a volcano point how many people might be ' 'impacted?') self.no_data_warning = False # A set of volcano names self.volcano_names = set() self.hazard_zone_attribute = 'radius'
def __init__(self): """Constructor.""" super(AshRasterPopulationFunction, self).__init__() PopulationExposureReportMixin.__init__(self) self.hazard_classes = [ tr('Very Low'), tr('Low'), tr('Moderate'), tr('High'), tr('Very High'), ] self.parameters = add_needs_parameters(self.parameters) self.no_data_warning = False
class PopulationExposureReportMixinTest(unittest.TestCase): """Test the ReportMixin. .. versionadded:: 3.2 """ # noinspection PyPep8Naming def setUp(self): """Fixture run before all tests.""" self.population_mixin_blank = PopulationExposureReportMixin() self.population_mixin = PopulationExposureReportMixin() self.population_mixin.affected_population['High'] = 100 self.population_mixin.affected_population['Medium'] = 100 self.population_mixin.affected_population['Low'] = 100 self.population_mixin.total_population = 400 self.population_mixin.question = '' self.population_mixin.unaffected_population = ( self.population_mixin.total_population - self.population_mixin.total_affected_population) self.population_mixin.minimum_needs = [ { 'frequency': 'test frequency', 'unit': {'abbreviation': 'u'}, 'name': 'test name 1', 'value': '1', }, { 'frequency': 'test frequency', 'unit': {'abbreviation': 'u'}, 'name': 'test name 2', 'value': '2', } ] def tearDown(self): """Run after each test.""" del self.population_mixin_blank del self.population_mixin def test_0002_category_ordering(self): """Test correct category ordering.""" category_ordering = self.population_mixin.impact_category_ordering expected_category_ordering = ['High', 'Medium', 'Low'] message = 'Category ordering is not as expected.' self.assertListEqual( category_ordering, expected_category_ordering, message) def test_0003_minimum_needs_breakdown(self): """Test minimum needs breakdown.""" needs_breakdown = self.population_mixin.minimum_needs expected_needs = self.population_mixin.minimum_needs self.assertEquals(expected_needs, needs_breakdown) def test_0004_population_counts(self): """Test correct category ordering.""" other_population_counts = self.population_mixin.other_population_counts affected_population = self.population_mixin.affected_population unaffected_population = self.population_mixin.unaffected_population total_affected_population = ( self.population_mixin.total_affected_population) message = 'Total affected population is as expected.' self.assertEqual( total_affected_population, 300, message) message = 'Total unaffected population is as expected.' self.assertEqual( unaffected_population, 100, message) message = 'Total affected population is as expected.' self.assertEqual( total_affected_population, 300, message) message = 'Other population is empty.' self.assertDictEqual( other_population_counts, {}, message ) expected_affected_population = { 'High': 100, 'Medium': 100, 'Low': 100 } message = 'Affected population is as expected.' self.assertDictEqual( affected_population, expected_affected_population, message) def test_0005_lookup_category(self): """Test the category lookup functionality""" high = self.population_mixin.lookup_category('High') low = self.population_mixin.lookup_category('Low') total = self.population_mixin.lookup_category('Total Impacted') nothing = self.population_mixin.lookup_category('Nothing') message = 'High population category as expected.' self.assertEqual(high, 100, message) message = 'Low population category as expected.' self.assertEqual(low, 100, message) message = 'Total population category as expected.' self.assertEqual(total, 300, message) message = 'Non-existent category should not have anything.' self.assertIsNone(nothing, message) def test_0006_generate_data(self): """Test generating data.""" data = self.population_mixin.generate_data() expected = { 'action check list': { # Remove list entries in 3.5 because logic is in IF # not in mixin now and this test does not actuall # create an IF...TS 'fields': [], 'title': 'Action checklist'}, 'exposure': 'population', 'impact summary': { 'attributes': ['category', 'value'], 'fields': [ ['High', 100], ['Medium', 100], ['Low', 100], ['Total affected population', 300], ['Unaffected population', 100], ['Total population', 400], [ 'Population needing evacuation <sup>1</sup>', 300 ] ] }, 'minimum needs': OrderedDict([('test frequency', [ {'name': 'test name 1', 'value': '1', 'amount': 300, 'frequency': 'test frequency', 'table name': 'test name 1 [u]', 'unit': {'abbreviation': 'u'}}, {'name': 'test name 2', 'value': '2', 'amount': 600, 'frequency': 'test frequency', 'table name': 'test name 2 [u]', 'unit': {'abbreviation': 'u'}}])]), 'notes': {'fields': [], 'title': 'Notes and assumptions'}, 'question': ''} self.assertDictEqual(data, expected)
class PopulationExposureReportMixinTest(unittest.TestCase): """Test the ReportMixin. .. versionadded:: 3.2 """ # noinspection PyPep8Naming def setUp(self): """Fixture run before all tests.""" self.population_mixin_blank = PopulationExposureReportMixin() self.population_mixin = PopulationExposureReportMixin() self.population_mixin.affected_population['High'] = 100 self.population_mixin.affected_population['Medium'] = 100 self.population_mixin.affected_population['Low'] = 100 self.population_mixin.total_population = 400 self.population_mixin.unaffected_population = ( self.population_mixin.total_population - self.population_mixin.total_affected_population) self.population_mixin.minimum_needs = [ { 'frequency': 'test frequency', 'unit': {'abbreviation': 'u'}, 'name': 'test name 1', 'value': '1', }, { 'frequency': 'test frequency', 'unit': {'abbreviation': 'u'}, 'name': 'test name 2', 'value': '2', } ] def tearDown(self): """Run after each test.""" del self.population_mixin_blank del self.population_mixin def test_0001_generate_report(self): """Generate a blank report.""" blank_report = self.population_mixin_blank.generate_report() blank_report = blank_report.to_text() expected_strings = [ u'**Population needing evacuation <sup>1</sup>**, 0', u'**Unaffected population**, 0', u'Evacuated population minimum needs', u'Action checklist', u'How will warnings be disseminated?', u'How will we reach evacuated people?', (u'If yes, where are they located and how will we ' u'distribute them?'), (u'If no, where can we obtain additional relief items and how ' u'will we distribute them?'), u'What are the related health risks?', u'Who are the key people responsible for coordination?', ] for item in expected_strings: self.assertIn(item, blank_report) def test_0002_category_ordering(self): """Test correct category ordering.""" category_ordering = self.population_mixin.impact_category_ordering expected_category_ordering = ['High', 'Medium', 'Low'] message = 'Category ordering is not as expected.' self.assertListEqual( category_ordering, expected_category_ordering, message) def test_0003_minimum_needs_breakdown(self): """Test minimum needs breakdown.""" needs_breakdown = self.population_mixin.minimum_needs_breakdown() needs_breakdown = needs_breakdown.to_text() expected_needs = [ u'Evacuated population minimum needs', u'**Relief items to be provided test frequency**', u'test name 1 [u], 300', u'test name 2 [u], 600' ] for item in expected_needs: self.assertIn(item, needs_breakdown) def test_0004_population_counts(self): """Test correct category ordering.""" other_population_counts = self.population_mixin.other_population_counts affected_population = self.population_mixin.affected_population unaffected_population = self.population_mixin.unaffected_population total_affected_population = ( self.population_mixin.total_affected_population) message = 'Total affected population is as expected.' self.assertEqual( total_affected_population, 300, message) message = 'Total unaffected population is as expected.' self.assertEqual( unaffected_population, 100, message) message = 'Total affected population is as expected.' self.assertEqual( total_affected_population, 300, message) message = 'Other population is empty.' self.assertDictEqual( other_population_counts, {}, message ) expected_affected_population = { 'High': 100, 'Medium': 100, 'Low': 100 } message = 'Affected population is as expected.' self.assertDictEqual( affected_population, expected_affected_population, message) def test_0005_lookup_category(self): """Test the category lookup functionality""" high = self.population_mixin.lookup_category('High') low = self.population_mixin.lookup_category('Low') total = self.population_mixin.lookup_category('Total Impacted') nothing = self.population_mixin.lookup_category('Nothing') message = 'High population category as expected.' self.assertEqual(high, 100, message) message = 'Low population category as expected.' self.assertEqual(low, 100, message) message = 'Total population category as expected.' self.assertEqual(total, 300, message) message = 'Non-existent category should not have anything.' self.assertIsNone(nothing, message)
class PopulationExposureReportMixinTest(unittest.TestCase): """Test the ReportMixin. .. versionadded:: 3.2 """ # noinspection PyPep8Naming def setUp(self): """Fixture run before all tests.""" self.population_mixin_blank = PopulationExposureReportMixin() self.population_mixin = PopulationExposureReportMixin() self.population_mixin.affected_population['High'] = 100 self.population_mixin.affected_population['Medium'] = 100 self.population_mixin.affected_population['Low'] = 100 self.population_mixin.total_population = 400 self.population_mixin.unaffected_population = ( self.population_mixin.total_population - self.population_mixin.total_affected_population) self.population_mixin.minimum_needs = [ { 'frequency': 'test frequency', 'unit': {'abbreviation': 'u'}, 'name': 'test name 1', 'value': '1', }, { 'frequency': 'test frequency', 'unit': {'abbreviation': 'u'}, 'name': 'test name 2', 'value': '2', } ] def tearDown(self): """Run after each test.""" del self.population_mixin_blank del self.population_mixin def test_0002_category_ordering(self): """Test correct category ordering.""" category_ordering = self.population_mixin.impact_category_ordering expected_category_ordering = ['High', 'Medium', 'Low'] message = 'Category ordering is not as expected.' self.assertListEqual( category_ordering, expected_category_ordering, message) def test_0003_minimum_needs_breakdown(self): """Test minimum needs breakdown.""" needs_breakdown = self.population_mixin.minimum_needs expected_needs = self.population_mixin.minimum_needs self.assertEquals(expected_needs, needs_breakdown) def test_0004_population_counts(self): """Test correct category ordering.""" other_population_counts = self.population_mixin.other_population_counts affected_population = self.population_mixin.affected_population unaffected_population = self.population_mixin.unaffected_population total_affected_population = ( self.population_mixin.total_affected_population) message = 'Total affected population is as expected.' self.assertEqual( total_affected_population, 300, message) message = 'Total unaffected population is as expected.' self.assertEqual( unaffected_population, 100, message) message = 'Total affected population is as expected.' self.assertEqual( total_affected_population, 300, message) message = 'Other population is empty.' self.assertDictEqual( other_population_counts, {}, message ) expected_affected_population = { 'High': 100, 'Medium': 100, 'Low': 100 } message = 'Affected population is as expected.' self.assertDictEqual( affected_population, expected_affected_population, message) def test_0005_lookup_category(self): """Test the category lookup functionality""" high = self.population_mixin.lookup_category('High') low = self.population_mixin.lookup_category('Low') total = self.population_mixin.lookup_category('Total Impacted') nothing = self.population_mixin.lookup_category('Nothing') message = 'High population category as expected.' self.assertEqual(high, 100, message) message = 'Low population category as expected.' self.assertEqual(low, 100, message) message = 'Total population category as expected.' self.assertEqual(total, 300, message) message = 'Non-existent category should not have anything.' self.assertIsNone(nothing, message) def test_0006_generate_data(self): """Test generating data.""" data = self.population_mixin.generate_data() expected = { 'action check list': { 'fields': [ 'Which group or population is most affected?', 'Who are the vulnerable people in the population and why?', 'How will warnings be disseminated?', 'What are people\'s likely movements?', 'What are the security factors for the affected ' 'population?', 'What are the security factors for relief responders?', 'How will we reach evacuated people?', 'What kind of food does the population normally consume?', 'What are the critical non-food items required by the ' 'affected population?', 'Are there enough water supply, sanitation, hygiene, ' 'food, shelter, medicines and relief items available for ' '300 people?', 'If yes, where are they located and how will we ' 'distribute them?', 'If no, where can we obtain additional relief items and ' 'how will we distribute them?', 'What are the related health risks?', 'Who are the key people responsible for coordination?'], 'title': 'Action checklist'}, 'exposure': 'population', 'impact summary': { 'attributes': ['category', 'value'], 'fields': [ ['High', '100'], ['Medium', '100'], ['Low', '100'], ['Total affected population', '300'], ['Unaffected population', '100'], ['Total population', '400'], [ 'Population needing evacuation <sup>1</sup>', '300' ] ] }, 'minimum needs': OrderedDict([('test frequency', [ {'name': 'test name 1', 'value': '1', 'amount': 300, 'frequency': 'test frequency', 'table name': 'test name 1 [u]', 'unit': {'abbreviation': 'u'}}, {'name': 'test name 2', 'value': '2', 'amount': 600, 'frequency': 'test frequency', 'table name': 'test name 2 [u]', 'unit': {'abbreviation': 'u'}}])]), 'notes': {'fields': [], 'title': 'Notes'}, 'question': ''} self.assertEquals(data, expected)
class PopulationExposureReportMixinTest(unittest.TestCase): """Test the ReportMixin. .. versionadded:: 3.2 """ # noinspection PyPep8Naming def setUp(self): """Fixture run before all tests.""" self.population_mixin_blank = PopulationExposureReportMixin() self.population_mixin = PopulationExposureReportMixin() self.population_mixin.affected_population['High'] = 100 self.population_mixin.affected_population['Medium'] = 100 self.population_mixin.affected_population['Low'] = 100 self.population_mixin.total_population = 400 self.population_mixin.unaffected_population = ( self.population_mixin.total_population - self.population_mixin.total_affected_population) self.population_mixin.minimum_needs = [ { 'frequency': 'test frequency', 'unit': {'abbreviation': 'u'}, 'name': 'test name 1', 'value': '1', }, { 'frequency': 'test frequency', 'unit': {'abbreviation': 'u'}, 'name': 'test name 2', 'value': '2', } ] def tearDown(self): """Run after each test.""" del self.population_mixin_blank del self.population_mixin def test_0001_generate_report(self): """Generate a blank report.""" blank_report = self.population_mixin_blank.generate_report() expected_blank_report = [ {'content': ''}, {'content': ''}, { 'content': [u'Population needing evacuation <sup>1</sup>', '0'], 'header': True }, {'content': ''}, {'content': [u'Unaffected population', '0'], 'header': True}, {'content': ''}, {'content': u'Evacuated population minimum needs', 'header': True}, {'content': ''}, {'content': u'Action checklist', 'header': True}, {'content': u'How will warnings be disseminated?'}, {'content': u'How will we reach evacuated people?'}, { 'content': u'Are there enough shelters and relief items available ' u'for 0 people?' }, { 'content': u'If yes, where are they located and how will we ' u'distribute them?' }, { 'content': u'If no, where can we obtain additional relief items ' u'from and how will we transport them to here?' }, {'content': ''} ] message = 'Blank report is not as expected.' self.assertListEqual(blank_report, expected_blank_report, message) def test_0002_category_ordering(self): """Test correct category ordering.""" category_ordering = self.population_mixin.impact_category_ordering expected_category_ordering = ['High', 'Medium', 'Low'] message = 'Category ordering is not as expected.' self.assertListEqual( category_ordering, expected_category_ordering, message) def test_0003_minimum_needs_breakdown(self): """Test minimum needs breakdown.""" needs_breakdown = self.population_mixin.minimum_needs_breakdown() expected_needs_breakdown = [ { 'content': u'Evacuated population minimum needs', 'header': True }, { 'content': [ u'Needs that should be provided test frequency', u'Total'], 'header': True }, {'content': [u'test name 1 [u]', u'300']}, {'content': [u'test name 2 [u]', u'600']} ] message = 'Needs beakdown is not as expected.' self.assertListEqual( needs_breakdown, expected_needs_breakdown, message) def test_0004_population_counts(self): """Test correct category ordering.""" other_population_counts = self.population_mixin.other_population_counts affected_population = self.population_mixin.affected_population unaffected_population = self.population_mixin.unaffected_population total_affected_population = ( self.population_mixin.total_affected_population) message = 'Total affected population is as expected.' self.assertEqual( total_affected_population, 300, message) message = 'Total unaffected population is as expected.' self.assertEqual( unaffected_population, 100, message) message = 'Total affected population is as expected.' self.assertEqual( total_affected_population, 300, message) message = 'Other population is empty.' self.assertDictEqual( other_population_counts, {}, message ) expected_affected_population = { 'High': 100, 'Medium': 100, 'Low': 100 } message = 'Affected population is as expected.' self.assertDictEqual( affected_population, expected_affected_population, message) def test_0005_lookup_category(self): """Test the category lookup functionality""" high = self.population_mixin.lookup_category('High') low = self.population_mixin.lookup_category('Low') total = self.population_mixin.lookup_category('Total Impacted') nothing = self.population_mixin.lookup_category('Nothing') message = 'High population category as expected.' self.assertEqual(high, 100, message) message = 'Low population category as expected.' self.assertEqual(low, 100, message) message = 'Total population category as expected.' self.assertEqual(total, 300, message) message = 'Non-existent category should not have anything.' self.assertIsNone(nothing, message)
class PopulationExposureReportMixinTest(unittest.TestCase): """Test the ReportMixin. .. versionadded:: 3.2 """ # noinspection PyPep8Naming def setUp(self): """Fixture run before all tests.""" self.population_mixin_blank = PopulationExposureReportMixin() self.population_mixin = PopulationExposureReportMixin() self.population_mixin.affected_population['High'] = 100 self.population_mixin.affected_population['Medium'] = 100 self.population_mixin.affected_population['Low'] = 100 self.population_mixin.total_population = 400 self.population_mixin.unaffected_population = ( self.population_mixin.total_population - self.population_mixin.total_affected_population) self.population_mixin.minimum_needs = [{ 'frequency': 'test frequency', 'unit': { 'abbreviation': 'u' }, 'name': 'test name 1', 'value': '1', }, { 'frequency': 'test frequency', 'unit': { 'abbreviation': 'u' }, 'name': 'test name 2', 'value': '2', }] def tearDown(self): """Run after each test.""" del self.population_mixin_blank del self.population_mixin def test_0001_generate_report(self): """Generate a blank report.""" blank_report = self.population_mixin_blank.generate_report() blank_report = blank_report.to_text() expected_strings = [ u'**Population needing evacuation <sup>1</sup>**, 0', u'**Unaffected population**, 0', u'Evacuated population minimum needs', u'Action checklist', u'How will warnings be disseminated?', u'How will we reach evacuated people?', (u'If yes, where are they located and how will we ' u'distribute them?'), (u'If no, where can we obtain additional relief items and how ' u'will we distribute them?'), u'What are the related health risks?', u'Who are the key people responsible for coordination?', ] for item in expected_strings: self.assertIn(item, blank_report) def test_0002_category_ordering(self): """Test correct category ordering.""" category_ordering = self.population_mixin.impact_category_ordering expected_category_ordering = ['High', 'Medium', 'Low'] message = 'Category ordering is not as expected.' self.assertListEqual(category_ordering, expected_category_ordering, message) def test_0003_minimum_needs_breakdown(self): """Test minimum needs breakdown.""" needs_breakdown = self.population_mixin.minimum_needs_breakdown() needs_breakdown = needs_breakdown.to_text() expected_needs = [ u'Evacuated population minimum needs', u'**Relief items to be provided test frequency**', u'test name 1 [u], 300', u'test name 2 [u], 600' ] for item in expected_needs: self.assertIn(item, needs_breakdown) def test_0004_population_counts(self): """Test correct category ordering.""" other_population_counts = self.population_mixin.other_population_counts affected_population = self.population_mixin.affected_population unaffected_population = self.population_mixin.unaffected_population total_affected_population = ( self.population_mixin.total_affected_population) message = 'Total affected population is as expected.' self.assertEqual(total_affected_population, 300, message) message = 'Total unaffected population is as expected.' self.assertEqual(unaffected_population, 100, message) message = 'Total affected population is as expected.' self.assertEqual(total_affected_population, 300, message) message = 'Other population is empty.' self.assertDictEqual(other_population_counts, {}, message) expected_affected_population = {'High': 100, 'Medium': 100, 'Low': 100} message = 'Affected population is as expected.' self.assertDictEqual(affected_population, expected_affected_population, message) def test_0005_lookup_category(self): """Test the category lookup functionality""" high = self.population_mixin.lookup_category('High') low = self.population_mixin.lookup_category('Low') total = self.population_mixin.lookup_category('Total Impacted') nothing = self.population_mixin.lookup_category('Nothing') message = 'High population category as expected.' self.assertEqual(high, 100, message) message = 'Low population category as expected.' self.assertEqual(low, 100, message) message = 'Total population category as expected.' self.assertEqual(total, 300, message) message = 'Non-existent category should not have anything.' self.assertIsNone(nothing, message)