def test_box_geometry(self): xml_parameters = { 'catalogue_geometry': 'box', 'dark_matter_simulation': self.simulation.id, # self.simulation.id, 'galaxy_model': self.galaxy_model.id, #self.galaxy_model.id, 'redshift': self.snapshot.redshift, 'box_size': 11.3, 'output_properties' : [self.filter.id, self.output_prop.id], } xml_parameters.update({ 'username' : 'test', # self.user.username, 'dark_matter_simulation': self.simulation.name, 'galaxy_model': self.galaxy_model.name, 'output_properties_1_name' : self.filter.name, 'output_properties_1_label' : self.filter.label, 'output_properties_1_units' : self.filter.units, 'output_properties_1_description' : 'FD', # self.filter.units, 'output_properties_2_name' : self.output_prop.name, 'output_properties_2_label' : self.output_prop.label, 'output_properties_2_description' : 'OD', # self.filter.units, 'output_properties_3_name' : self.computed_filter.name, 'output_properties_3_label' : self.computed_filter.label, 'output_properties_3_description' : self.computed_filter.description, }) xml_parameters.update({ 'filter': self.filter.name, 'filter_min' : '1000000', 'filter_max' : 'None', }) xml_parameters.update({ 'ssp_encoding': self.stellar_model.encoding, 'band_pass_filter_label': self.band_pass_filter.label, 'band_pass_filter_id': self.band_pass_filter.filter_id, 'band_pass_filter_name': self.band_pass_filter.filter_id, 'dust_model_name': self.dust_model.name, }) xml_parameters.update({ 'light_cone_id': FormsGraph.LIGHT_CONE_ID, 'csv_dump_id': FormsGraph.OUTPUT_ID, 'bandpass_filter_id': FormsGraph.BANDPASS_FILTER_ID, 'sed_id': FormsGraph.SED_ID, 'dust_id': FormsGraph.DUST_ID, }) xml_str = light_cone_xml(xml_parameters) form = make_form_xml(LightConeForm, xml_str, prefix='light_cone') self.assertEquals(LightConeForm.BOX, form.data['light_cone-catalogue_geometry']) self.assertEquals(self.dataset.id, form.data['light_cone-galaxy_model']) self.assertEquals(self.simulation.id, form.data['light_cone-dark_matter_simulation']) self.assertEquals(self.snapshot.id, form.data['light_cone-snapshot']) self.assertEquals(11.3, float(form.data['light_cone-box_size'])) op_list = form.data['light_cone-output_properties'] self.assertEquals(3, len(op_list)) self.assertTrue(self.filter.id in op_list) self.assertTrue(self.output_prop.id in op_list)
def test_light_cone_geometry(self): xml_parameters = { 'catalogue_geometry': 'light-cone', 'dark_matter_simulation': self.simulation.id, 'galaxy_model': self.galaxy_model.id, 'redshift_min': 0.2, 'redshift_max': 0.3, 'ra_opening_angle': 71.565, 'dec_opening_angle': 41.811, 'output_properties': [self.filter.id, self.output_prop.id], 'light_cone_type': 'unique', 'number_of_light_cones': 1, } xml_parameters.update({ 'username' : 'test', # self.user.username, 'dark_matter_simulation': self.simulation.name, 'galaxy_model': self.galaxy_model.name, 'output_properties_1_name' : self.filter.name, 'output_properties_1_label' : self.filter.label, 'output_properties_1_units' : self.filter.units, 'output_properties_1_description' : self.filter.description, 'output_properties_2_name' : self.output_prop.name, 'output_properties_2_label' : self.output_prop.label, 'output_properties_2_description' : self.filter.description, 'output_properties_3_name' : self.computed_filter.name, 'output_properties_3_label' : self.computed_filter.label, 'output_properties_3_description' : self.computed_filter.description, }) xml_parameters.update({ 'filter': self.filter.name, 'filter_min' : '1000000', 'filter_max' : 'None', }) xml_parameters.update({ 'ssp_encoding': self.stellar_model.encoding, 'band_pass_filter_label': self.band_pass_filter.label, 'band_pass_filter_id': self.band_pass_filter.filter_id, 'band_pass_filter_name': self.band_pass_filter.filter_id, 'dust_model_name': self.dust_model.name, }) xml_parameters.update({ 'light_cone_id': FormsGraph.LIGHT_CONE_ID, 'csv_dump_id': FormsGraph.OUTPUT_ID, 'bandpass_filter_id': FormsGraph.BANDPASS_FILTER_ID, 'sed_id': FormsGraph.SED_ID, 'dust_id': FormsGraph.DUST_ID, }) xml_str = light_cone_xml(xml_parameters) mock_ui_holder = MockUIHolder() mock_ui_holder.dataset = self.dataset form = make_form_xml(LightConeForm, xml_str, prefix='light_cone', ui_holder=mock_ui_holder) self.assertEquals(LightConeForm.CONE, form.data['light_cone-catalogue_geometry']) self.assertEquals(self.dataset.id, form.data['light_cone-galaxy_model']) self.assertEquals(self.simulation.id, form.data['light_cone-dark_matter_simulation']) self.assertEquals('unique', form.data['light_cone-light_cone_type']) self.assertEquals('1', form.data['light_cone-number_of_light_cones']) self.assertEquals('0.2', form.data['light_cone-redshift_min']) self.assertEquals('0.3', form.data['light_cone-redshift_max']) self.assertEquals('71.565', form.data['light_cone-ra_opening_angle']) self.assertEquals('71.565', form.data['light_cone-ra_opening_angle']) self.assertEquals('41.811', form.data['light_cone-dec_opening_angle']) op_list = form.data['light_cone-output_properties'] self.assertEquals(3, len(op_list)) self.assertTrue(self.filter.id in op_list) self.assertTrue(self.output_prop.id in op_list)
def make_xml_parameters(self): return light_cone_xml(self.make_parameters())
}) xml_parameters.update({ 'ssp_encoding': self.stellar_model.encoding, 'band_pass_filter_label': 'BPFN', # self.band_pass_filter.label, 'band_pass_filter_id': 1L, # self.band_pass_filter.filter_id, 'band_pass_filter_name': 'BPFN', 'dust_model_name': 'DM', # self.dust_model.name, }) xml_parameters.update({ 'light_cone_id': FormsGraph.LIGHT_CONE_ID, 'csv_dump_id': FormsGraph.OUTPUT_ID, 'bandpass_filter_id': FormsGraph.BANDPASS_FILTER_ID, 'sed_id': FormsGraph.SED_ID, 'dust_id': FormsGraph.DUST_ID, }) xml_str = light_cone_xml(xml_parameters) form = make_form_xml(OutputFormatForm, xml_str, prefix='output_format') self.assertEquals('csv', form.data['output_format-supported_formats']) def test_output_format_selection(self): xml_parameters = { 'catalogue_geometry': 'light-cone', 'dark_matter_simulation': self.simulation.id, 'galaxy_model': self.galaxy_model.id, 'redshift_min': 0.2, 'redshift_max': 0.3, 'ra_opening_angle': 71.565, 'dec_opening_angle': 41.811, 'output_properties' : [1L, 2L], #[self.filter.id, self.output_prop.id], 'light_cone_type': 'unique', 'number_of_light_cones': 1,
def test_unique_cone(self): form_parameters = { 'catalogue_geometry': 'light-cone', 'dark_matter_simulation': self.simulation.id, 'galaxy_model': self.galaxy_model.id, 'redshift_min': 0.0, 'redshift_max': 0.2, 'ra_opening_angle': 12.001, 'dec_opening_angle': 10.003, 'output_properties' : [self.filter.id, self.output_prop.id, self.computed_filter.id], 'light_cone_type': 'unique', 'number_of_light_cones': 8, } xml_parameters = form_parameters.copy() xml_parameters.update({ 'username' : self.user.username, 'dark_matter_simulation': self.simulation.name, 'galaxy_model': self.galaxy_model.name, 'output_properties_1_name' : self.filter.name, 'output_properties_1_label' : self.filter.label, 'output_properties_1_units' : self.filter.units, 'output_properties_1_description' : self.filter.description, 'output_properties_2_name' : self.output_prop.name, 'output_properties_2_label' : self.output_prop.label, 'output_properties_2_description' : self.output_prop.description, 'output_properties_3_name' : self.computed_filter.name, 'output_properties_3_label' : self.computed_filter.label, 'output_properties_3_description' : self.computed_filter.description, }) xml_parameters.update({ 'filter': self.filter.name, 'filter_min' : '1000000', 'filter_max' : 'None', }) xml_parameters.update({ 'apply_sed': False, }) xml_parameters.update({ 'ssp_encoding': self.stellar_model.encoding, 'band_pass_filter_label': self.band_pass_filter.label, 'band_pass_filter_id': self.band_pass_filter.filter_id, 'band_pass_filter_name': self.band_pass_filter.filter_id, 'dust_model_name': self.dust_model.name, }) xml_parameters.update({ 'light_cone_id': FormsGraph.LIGHT_CONE_ID, 'csv_dump_id': FormsGraph.OUTPUT_ID, 'bandpass_filter_id': FormsGraph.BANDPASS_FILTER_ID, 'sed_id': FormsGraph.SED_ID, 'dust_id': FormsGraph.DUST_ID, }) # TODO: there are commented out elements which are not implemented yet # comments are ignored by assertXmlEqual expected_parameter_xml = light_cone_xml(xml_parameters) mock_ui_holder = MockUIHolder() light_cone_form = make_form({}, LightConeForm, form_parameters, ui_holder=mock_ui_holder, prefix='light_cone') sed_form = make_form({}, SEDForm, self.sed_parameters, ui_holder=mock_ui_holder, prefix='sed') output_form = make_form({}, OutputFormatForm, {'supported_formats': 'csv'}, ui_holder=mock_ui_holder, prefix='output_format') mock_ui_holder.update(light_cone = light_cone_form, sed = sed_form, output_format = output_form) record_filter_form = make_form({}, RecordFilterForm, {'filter':'D-'+str(self.filter.id),'min':str(1000000)}, ui_holder=mock_ui_holder, prefix='record_filter') self.assertEqual({}, light_cone_form.errors) self.assertEqual({}, sed_form.errors) self.assertEqual({}, record_filter_form.errors) self.assertEqual({}, output_form.errors) mock_ui_holder.update(record_filter = record_filter_form) mock_ui_holder.dataset = self.dataset job = workflow.save(self.user, mock_ui_holder) actual_parameter_xml = job.parameters self.assertEqual(self.dataset.database, job.database) self.assertXmlEqual(expected_parameter_xml, actual_parameter_xml)