def test_scenarios_calls_parser(self, mock_data_handler): mapper = ScenarioMapper() model = ScenarioResponseModel() model.naam = 'Naam' scenarios = mapper.get_scenarios(1) mock_data_handler.assert_called_with(1)
def test_delete_scenario_calls_data_handler(self, mock__get_scenarios, mock__data_handler): mapper = ScenarioMapper() mapper.delete_scenario(1, 1) mock__data_handler.assert_called_with( 'DELETE FROM scenario WHERE id = %s', (1, ), False)
def test_add_scenario_calls_data_handler(self, mock__get_scenarios, mock_stored_procedure): model = ScenarioResponseModel() mapper = ScenarioMapper() mapper.add_scenario(model, 1) mock_stored_procedure.assert_called_with( 'maak_scenario_en_stop_in_project', ('scenario', 'toelichting', 1))
def test_update_scenario_calls_data_handler(self, mock__get_scenarios, mock__data_handler): model = ScenarioResponseModel() mapper = ScenarioMapper() mapper.update_scenario(model, 1) mock__data_handler.assert_called_with("UPDATE scenario " \ "SET naam = %s, toelichting = %s " \ "WHERE id = %s", ('scenario', 'toelichting', 1), False)
def test_get_scenario_by_id_calls_get_scenarios_with_details( self, mock_get_scenarios_with_details): # Arrange mapper = ScenarioMapper() # Act mapper.get_scenario_by_id(1, 1) # Assert mock_get_scenarios_with_details.assert_called()
def test_remove_jaar_from_gebeurtenis_call_get_scenarios( self, mock__get_scenarios, mock__data_handler): # Arrange mapper = ScenarioMapper() # Act mapper.remove_jaar_from_gebeurtenis(1, 1, 1, 1) # Assert mock__get_scenarios.assert_called()
def test_update_jaar_in_gebeurtenis_in_scenario_call_get_scenarios( self, mock__get_scenarios, mock__data_handler): # Arrange mapper = ScenarioMapper() # Act mapper.update_jaar_in_gebeurtenis_in_scenario(1, 1, 1, 1, 1) # Assert mock__get_scenarios.assert_called()
def test_add_gebeurtenis_to_scenario_call_get_scenarios( self, mock__get_scenarios, mock__data_handler): # Arrange mapper = ScenarioMapper() # Act mapper.add_gebeurtenis_to_scenario(1, 1, 1) # Assert mock__get_scenarios.assert_called()
def test_data_handler_throws_exception(self): with self.assertRaises(Exception) as excep: mapper = ScenarioMapper() mapper._data_handler("WRONGQUERY", "", False)
def test_data_handler_returns_None(self, mock_db_connection): mapper = ScenarioMapper() result = mapper._data_handler("", "", False) assert result == None
def test_data_handler_calls_connection(self, mock_db_connection): mapper = ScenarioMapper() mapper._data_handler("", "", True) mock_db_connection.assert_called_with()
def test_db_connection(self, mock_connect): mapper = ScenarioMapper() mapper._db_connection() mock_connect.assert_called()
def __init__(self): self.repository = ScenarioMapper() self.scenarios = [] self.JAREN = 100
def import_to_db_scenario(self, json_model_array, project_id): mapper = ScenarioMapper() for i in range(len(json_model_array)): mapper.add_scenario(json_model_array[i], project_id)