Beispiel #1
0
    def __init__(self, study=None, **kwargs):
        super(StudyEditorExtendedForm, self).__init__(study=study, **kwargs)

        # Populate the choices for the environmental packages
        # Get environmental packages returns a list of tuples of the form
        # (env package name, table name), but we need a list of
        # (table name, env package name) so the actual environmental package
        # name is displayed on the GUI
        self.environmental_packages.choices = [
            (name, name) for name, table in get_environmental_packages()
        ]

        # Get the available timeseries types to populate the timeseries field
        choices = [[time_id, '%s, %s' % (int_t, time_t)]
                   for time_id, time_t, int_t in get_timeseries_types()]
        # Change None, None to 'No timeseries', just for GUI purposes
        choices[0][1] = 'No timeseries'
        self.timeseries.choices = choices

        # If a study is provided, put its values in the form
        if study:
            study_info = study.info

            self.environmental_packages.data = study.environmental_packages
            self.timeseries.data = study_info['timeseries_type_id']
Beispiel #2
0
 def test_get_environmental_packages(self):
     obs = get_environmental_packages()
     exp = [['air',
             'ep_air'], ['built environment', 'ep_built_environment'],
            ['host-associated', 'ep_host_associated'],
            ['human-amniotic-fluid', 'ep_human_amniotic_fluid'],
            ['human-associated', 'ep_human_associated'],
            ['human-blood', 'ep_human_blood'],
            ['human-gut', 'ep_human_gut'], ['human-oral', 'ep_human_oral'],
            ['human-skin', 'ep_human_skin'],
            ['human-urine', 'ep_human_urine'],
            ['human-vaginal', 'ep_human_vaginal'],
            ['microbial mat/biofilm', 'ep_microbial_mat_biofilm'],
            [
                'miscellaneous natural or artificial environment',
                'ep_misc_artif'
            ], ['plant-associated', 'ep_plant_associated'],
            ['sediment', 'ep_sediment'], ['soil', 'ep_soil'],
            ['wastewater/sludge', 'ep_wastewater_sludge'],
            ['water', 'ep_water']]
     self.assertEqual(sorted(obs), sorted(exp))
Beispiel #3
0
 def test_get_environmental_packages(self):
     obs = get_environmental_packages()
     exp = [['air', 'ep_air'],
            ['built environment', 'ep_built_environment'],
            ['host-associated', 'ep_host_associated'],
            ['human-amniotic-fluid', 'ep_human_amniotic_fluid'],
            ['human-associated', 'ep_human_associated'],
            ['human-blood', 'ep_human_blood'],
            ['human-gut', 'ep_human_gut'],
            ['human-oral', 'ep_human_oral'],
            ['human-skin', 'ep_human_skin'],
            ['human-urine', 'ep_human_urine'],
            ['human-vaginal', 'ep_human_vaginal'],
            ['microbial mat/biofilm', 'ep_microbial_mat_biofilm'],
            ['miscellaneous natural or artificial environment',
             'ep_misc_artif'],
            ['plant-associated', 'ep_plant_associated'],
            ['sediment', 'ep_sediment'],
            ['soil', 'ep_soil'],
            ['wastewater/sludge', 'ep_wastewater_sludge'],
            ['water', 'ep_water']]
     self.assertEqual(sorted(obs), sorted(exp))
Beispiel #4
0
 def test_get_environmental_packages(self):
     obs = get_environmental_packages()
     exp = [
         ["air", "ep_air"],
         ["built environment", "ep_built_environment"],
         ["host-associated", "ep_host_associated"],
         ["human-amniotic-fluid", "ep_human_amniotic_fluid"],
         ["human-associated", "ep_human_associated"],
         ["human-blood", "ep_human_blood"],
         ["human-gut", "ep_human_gut"],
         ["human-oral", "ep_human_oral"],
         ["human-skin", "ep_human_skin"],
         ["human-urine", "ep_human_urine"],
         ["human-vaginal", "ep_human_vaginal"],
         ["microbial mat/biofilm", "ep_microbial_mat_biofilm"],
         ["miscellaneous natural or artificial environment", "ep_misc_artif"],
         ["plant-associated", "ep_plant_associated"],
         ["sediment", "ep_sediment"],
         ["soil", "ep_soil"],
         ["wastewater/sludge", "ep_wastewater_sludge"],
         ["water", "ep_water"],
     ]
     self.assertEqual(sorted(obs), sorted(exp))
Beispiel #5
0
    def __init__(self, study=None, **kwargs):
        super(StudyEditorExtendedForm, self).__init__(study=study, **kwargs)

        # Populate the choices for the environmental packages
        # Get environmental packages returns a list of tuples of the form
        # (env package name, table name), but we need a list of
        # (table name, env package name) so the actual environmental package
        # name is displayed on the GUI
        self.environmental_packages.choices = [
            (name, name) for name, table in get_environmental_packages()]

        # Get the available timeseries types to populate the timeseries field
        choices = [[time_id, '%s, %s' % (int_t, time_t)]
                   for time_id, time_t, int_t in get_timeseries_types()]
        # Change None, None to 'No timeseries', just for GUI purposes
        choices[0][1] = 'No timeseries'
        self.timeseries.choices = choices

        # If a study is provided, put its values in the form
        if study:
            study_info = study.info

            self.environmental_packages.data = study.environmental_packages
            self.timeseries.data = study_info['timeseries_type_id']