def test_profiling(self): """Test running impact function on test data.""" hazard_layer = load_test_vector_layer('gisv4', 'hazard', 'classified_vector.geojson') exposure_layer = load_test_vector_layer('gisv4', 'exposure', 'building-points.geojson') aggregation_layer = load_test_vector_layer('gisv4', 'aggregation', 'small_grid.geojson') # Set up impact function impact_function = ImpactFunction() impact_function.aggregation = aggregation_layer impact_function.exposure = exposure_layer impact_function.hazard = hazard_layer status, message = impact_function.run() self.assertEqual(ANALYSIS_FAILED_BAD_INPUT, status, message) impact_function.prepare() status, message = impact_function.run() self.assertEqual(ANALYSIS_SUCCESS, status, message) message = impact_function.performance_log_message().to_text() expected_result = get_control_text('test-profiling-logs.txt') for line in expected_result: line = line.replace('\n', '') if line == '' or line == '-': continue self.assertIn(line, message) # Notes(IS): For some unknown reason I need to do this to make # test_provenance pass del hazard_layer
def test_profiling(self): """Test running impact function on test data.""" hazard_layer = load_test_vector_layer( 'gisv4', 'hazard', 'classified_vector.geojson') exposure_layer = load_test_vector_layer( 'gisv4', 'exposure', 'building-points.geojson') aggregation_layer = load_test_vector_layer( 'gisv4', 'aggregation', 'small_grid.geojson') # Set up impact function impact_function = ImpactFunction() impact_function.aggregation = aggregation_layer impact_function.exposure = exposure_layer impact_function.hazard = hazard_layer status, message = impact_function.run() self.assertEqual(ANALYSIS_FAILED_BAD_INPUT, status, message) impact_function.prepare() status, message = impact_function.run() self.assertEqual(ANALYSIS_SUCCESS, status, message) message = impact_function.performance_log_message().to_text() expected_result = get_control_text( 'test-profiling-logs.txt') for line in expected_result: line = line.replace('\n', '') if line == '' or line == '-': continue self.assertIn(line, message) # Notes(IS): For some unknown reason I need to do this to make # test_provenance pass del hazard_layer
def test_definitions_help(self): """Test definitions help generation.""" help_text = definitions_help.definitions_help().to_text() expected_result = get_control_text('test-definition-help-response.txt') for line in expected_result: line = line.replace('\n', '') self.assertIn(line, help_text)
def test_definitions_help(self): """Test definitions help generation.""" help_text = definitions_help.definitions_help().to_text() expected_result = get_control_text( 'test-definition-help-response.txt') for line in expected_result: line = line.replace('\n', '') self.assertIn(line, help_text)
def test_definition_to_message(self): """Test definitions to message renderer.""" help_text = definitions_help.definition_to_message( self.test_definition).to_text() expected_result = get_control_text( 'test-definition-to-message-response.txt') for line in expected_result: line = line.replace('\n', '') self.assertIn(line, help_text)
def test_definition_to_message(self): """Test definitions to message renderer.""" message = m.Message() table_of_contents = m.Message() definitions_help.definition_to_message( self.test_definition, message=message, table_of_contents=table_of_contents) help_text = message.to_text() expected_result = get_control_text( 'test-definition-to-message-response.txt') for line in expected_result: line = line.replace('\n', '') self.assertIn(line, help_text)
def test_definition_to_message(self): """Test definitions to message renderer.""" message = m.Message() table_of_contents = m.Message() definitions_help.definition_to_message( self.test_definition, message=message, table_of_contents=table_of_contents ) help_text = message.to_text() expected_result = get_control_text( 'test-definition-to-message-response.txt') for line in expected_result: line = line.replace('\n', '') self.assertIn(line, help_text)