コード例 #1
0
ファイル: test.py プロジェクト: smbantjes/bauble.classic
    def test_partial_taxonomic_with_synonymy(self):
        "exporting one genus which is not an accepted name."

        f = self.session.query(
            Family).filter(
            Family.family == u'Orchidaceae').one()
        bu = Genus(family=f, genus=u'Bulbophyllum')  # accepted
        zy = Genus(family=f, genus=u'Zygoglossum')  # synonym
        bu.synonyms.append(zy)
        self.session.add_all([f, bu, zy])
        self.session.commit()

        selection = self.session.query(Genus).filter(
            Genus.genus == u'Zygoglossum').all()
        mock_view.set_selection(selection)
        exporter = JSONExporter(mock_view)
        exporter.start(self.temp_path, selection)
        result = json.load(open(self.temp_path))
        self.assertEquals(len(result), 1)
        self.assertEquals(result[0]['rank'], 'genus')
        self.assertEquals(result[0]['epithet'], 'Zygoglossum')
        self.assertEquals(result[0]['ht-rank'], 'familia')
        self.assertEquals(result[0]['ht-epithet'], 'Orchidaceae')
        accepted = result[0].get('accepted')
        self.assertTrue(isinstance(accepted, dict))
        self.assertEquals(accepted['rank'], 'genus')
        self.assertEquals(accepted['epithet'], 'Bulbophyllum')
        self.assertEquals(accepted['ht-rank'], 'familia')
        self.assertEquals(accepted['ht-epithet'], 'Orchidaceae')
コード例 #2
0
    def test_partial_taxonomic_with_synonymy(self):
        "exporting one genus which is not an accepted name."

        f = self.session.query(
            Family).filter(
            Family.family == u'Orchidaceae').one()
        bu = Genus(family=f, genus=u'Bulbophyllum')  # accepted
        zy = Genus(family=f, genus=u'Zygoglossum')  # synonym
        bu.synonyms.append(zy)
        self.session.add_all([f, bu, zy])
        self.session.commit()

        selection = self.session.query(Genus).filter(
            Genus.genus == u'Zygoglossum').all()
        exporter = JSONExporter(MockView())
        exporter.view.selection = selection
        exporter.selection_based_on == 'sbo_selection'
        exporter.include_private = True
        exporter.filename = self.temp_path
        exporter.run()
        result = json.load(open(self.temp_path))
        self.assertEquals(len(result), 1)
        self.assertEquals(result[0]['rank'], 'genus')
        self.assertEquals(result[0]['epithet'], 'Zygoglossum')
        self.assertEquals(result[0]['ht-rank'], 'familia')
        self.assertEquals(result[0]['ht-epithet'], 'Orchidaceae')
        accepted = result[0].get('accepted')
        self.assertTrue(isinstance(accepted, dict))
        self.assertEquals(accepted['rank'], 'genus')
        self.assertEquals(accepted['epithet'], 'Bulbophyllum')
        self.assertEquals(accepted['ht-rank'], 'familia')
        self.assertEquals(accepted['ht-epithet'], 'Orchidaceae')
コード例 #3
0
ファイル: test.py プロジェクト: smbantjes/bauble.classic
    def test_writes_complete_database(self):
        "exporting without specifying what: export complete database"

        mock_view.set_selection([])
        exporter = JSONExporter(mock_view)
        exporter.start(self.temp_path)
        ## must still check content of generated file!
        result = json.load(open(self.temp_path))
        self.assertEquals(len(result), 5)
        families = [i for i in result if i['rank'] == 'familia']
        self.assertEquals(len(families), 2)
        genera = [i for i in result if i['rank'] == 'genus']
        self.assertEquals(len(genera), 2)
        species = [i for i in result if i['rank'] == 'species']
        self.assertEquals(len(species), 1)
        self.assertEquals(open(self.temp_path).read(),
                          """\
[{"epithet": "Orchidaceae", "object": "taxon", "rank": "familia"},
 {"epithet": "Myrtaceae", "object": "taxon", "rank": "familia"},
 {"author": "R. Br.", "epithet": "Calopogon", "ht-epithet": "Orchidaceae", \
"ht-rank": "familia", "object": "taxon", "rank": "genus"},
 {"author": "", "epithet": "Panisea", "ht-epithet": "Orchidaceae", \
"ht-rank": "familia", "object": "taxon", "rank": "genus"},
 {"epithet": "tuberosus", "ht-epithet": "Calopogon", "ht-rank": "genus", \
"hybrid": false, "object": "taxon", "rank": "species"}]""")
コード例 #4
0
ファイル: test.py プロジェクト: odalissalazar/bauble.classic
 def test_when_selection_huge_ask(self):
     view = MockView()
     exporter = JSONExporter(view)
     exporter.selection_based_on == 'sbo_selection'
     view.selection = range(5000)
     view.reply_yes_no_dialog = [False]
     exporter.run()
     self.assertTrue('run_yes_no_dialog' in view.invoked)
     self.assertEquals(view.reply_yes_no_dialog, [])
コード例 #5
0
ファイル: test.py プロジェクト: Ghini/ghini.desktop
    def test_writes_complete_database(self):
        "exporting without specifying what: export complete database"

        exporter = JSONExporter(MockView())
        exporter.view.selection = None
        exporter.selection_based_on == 'sbo_selection'
        exporter.include_private = False
        exporter.filename = self.temp_path
        exporter.run()
        ## must still check content of generated file!
        result = json.load(open(self.temp_path))
        self.assertEquals(len(result), 11)
        families = [i for i in result
                    if i['object'] == 'taxon' and i['rank'] == 'familia']
        self.assertEquals(len(families), 2)
        genera = [i for i in result
                  if i['object'] == 'taxon' and i['rank'] == 'genus']
        self.assertEquals(len(genera), 2)
        species = [i for i in result
                   if i['object'] == 'taxon' and i['rank'] == 'species']
        self.assertEquals(len(species), 1)
        target = [
            {"epithet": u"Orchidaceae", u"object": u"taxon", 'aggregate': u'',
             "rank": u"familia", u"author": u"", u"hybrid_marker": u""},
            {u"epithet": u"Myrtaceae", u"object": u"taxon", 'aggregate': u'',
             u"rank": u"familia", u"author": u"", u"hybrid_marker": u""},
            {u"author": u"R. Br.", u"epithet": u"Calopogon",
             u"ht-epithet": u"Orchidaceae", u"ht-rank": u"familia",
             u"object": u"taxon", u"rank": u"genus", 'aggregate': u'',
             u"hybrid_marker": u""},
            {u"object": u"taxon", u"author": u"", u"epithet": u"Panisea",
             u"ht-epithet": u"Orchidaceae", u"ht-rank": u"familia",
             'aggregate': u'', u"rank": u"genus", u"hybrid_marker": u''},
            {u"epithet": u"tuberosus", u"ht-epithet": u"Calopogon",
             u"ht-rank": u"genus", u"hybrid_marker": u"", u"object": u"taxon",
             u"rank": u"species", u'aggregate': u'', 'author': u''},
            {u"code": u"2015.0001", u"object": u"accession", u"private": False,
             u"species": u"Calopogon tuberosus"},
            {u"code": u"2015.0002", u"object": u"accession", u"private": False,
             u"species": u"Calopogon tuberosus"},
            {u"code": u"2015.0003", u"object": u"accession", u"private": True,
             u"species": u"Calopogon tuberosus"},
            {u"code": u"1", u"object": u"location"},
            {u"accession": u"2015.0001", u"code": u"1", u"location": u"1",
             u"memorial": False, u"object": u"plant", u"quantity": 1},
            {u"accession": u"2015.0003", u"code": u"1", u"location": u"1",
             u"memorial": False, u"object": u"plant", u"quantity": 1}]
        print sorted(result)
        print sorted(target)
        #self.assertEquals(sorted(result), sorted(target))
        for o1 in result:
            self.assertTrue(o1 in target, o1)
        for o2 in target:
            self.assertTrue(o1 in result, o2)
コード例 #6
0
ファイル: test.py プロジェクト: smbantjes/bauble.classic
    def test_writes_full_taxonomic_info(self):
        "exporting one family: export full taxonomic information below family"

        selection = self.session.query(Family).filter(
            Family.family == u'Orchidaceae').all()
        mock_view.set_selection(selection)
        exporter = JSONExporter(mock_view)
        exporter.start(self.temp_path, selection)
        result = json.load(open(self.temp_path))
        self.assertEquals(len(result), 1)
        self.assertEquals(result[0]['rank'], 'familia')
        self.assertEquals(result[0]['epithet'], 'Orchidaceae')
コード例 #7
0
ファイル: test.py プロジェクト: smbantjes/bauble.classic
    def test_writes_partial_taxonomic_info(self):
        "exporting one genus: all species below genus"

        selection = self.session.query(Genus).filter(
            Genus.genus == u'Calopogon').all()
        mock_view.set_selection(selection)
        exporter = JSONExporter(mock_view)
        exporter.start(self.temp_path, selection)
        result = json.load(open(self.temp_path))
        self.assertEquals(len(result), 1)
        self.assertEquals(result[0]['rank'], 'genus')
        self.assertEquals(result[0]['epithet'], 'Calopogon')
        self.assertEquals(result[0]['ht-rank'], 'familia')
        self.assertEquals(result[0]['ht-epithet'], 'Orchidaceae')
        self.assertEquals(result[0]['author'], 'R. Br.')
コード例 #8
0
ファイル: test.py プロジェクト: smbantjes/bauble.classic
    def test_writes_partial_taxonomic_info_species(self):
        "exporting one species: all species below species"

        selection = self.session.query(
            Species).filter(Species.sp == u'tuberosus').join(
            Genus).filter(Genus.genus == u"Calopogon").all()
        mock_view.set_selection(selection)
        exporter = JSONExporter(mock_view)
        exporter.start(self.temp_path, selection)
        result = json.load(open(self.temp_path))
        self.assertEquals(len(result), 1)
        self.assertEquals(result[0]['rank'], 'species')
        self.assertEquals(result[0]['epithet'], 'tuberosus')
        self.assertEquals(result[0]['ht-rank'], 'genus')
        self.assertEquals(result[0]['ht-epithet'], 'Calopogon')
        self.assertEquals(result[0]['hybrid'], False)
コード例 #9
0
ファイル: test.py プロジェクト: odalissalazar/bauble.classic
    def test_export_with_vernacular(self):
        "exporting one genus which is not an accepted name."

        ## precondition
        sola = Family(family='Solanaceae')
        brug = Genus(family=sola, genus=u'Brugmansia')
        arbo = Species(genus=brug, sp=u'arborea')
        vern = VernacularName(species=arbo,
                              language=u"es", name=u"Floripondio")
        self.session.add_all([sola, brug, arbo, vern])
        self.session.commit()

        ## action
        exporter = JSONExporter(MockView())
        exporter.view.selection = None
        exporter.selection_based_on = 'sbo_taxa'
        exporter.include_private = False
        exporter.filename = self.temp_path
        exporter.run()

        ## check
        result = json.load(open(self.temp_path))
        vern_from_json = [i for i in result
                          if i['object'] == 'vernacular_name']
        self.assertEquals(len(vern_from_json), 1)
        self.assertEquals(vern_from_json[0]['language'], 'es')
コード例 #10
0
ファイル: test.py プロジェクト: odalissalazar/bauble.classic
 def test_export_private_if_sbo_plants(self):
     exporter = JSONExporter(MockView())
     exporter.view.selection = None
     exporter.selection_based_on = 'sbo_plants'
     exporter.include_private = True
     exporter.filename = self.temp_path
     exporter.run()
     result = json.load(open(self.temp_path))
     self.assertEquals(len(result), 8)
コード例 #11
0
ファイル: test.py プロジェクト: watermelon337/ghini.desktop
    def test_partial_taxonomic_with_synonymy(self):
        "exporting one genus which is not an accepted name."

        f = self.session.query(Family).filter(
            Family.epithet == u'Orchidaceae').one()
        bu = Genus(family=f, epithet=u'Bulbophyllum')  # accepted
        zy = Genus(family=f, epithet=u'Zygoglossum')  # synonym
        bu.synonyms.append(zy)
        self.session.add_all([f, bu, zy])
        self.session.commit()

        selection = self.session.query(Genus).filter(
            Genus.epithet == u'Zygoglossum').all()
        exporter = JSONExporter(MockView())
        exporter.view.selection = selection
        exporter.selection_based_on == 'sbo_selection'
        exporter.include_private = True
        exporter.filename = self.temp_path
        exporter.run()
        result = json.load(open(self.temp_path))
        self.assertEquals(len(result), 1)
        self.assertEquals(result[0]['rank'], 'genus')
        self.assertEquals(result[0]['epithet'], 'Zygoglossum')
        self.assertEquals(result[0]['ht-rank'], 'familia')
        self.assertEquals(result[0]['ht-epithet'], 'Orchidaceae')
        accepted = result[0].get('accepted')
        self.assertTrue(isinstance(accepted, dict))
        self.assertEquals(accepted['rank'], 'genus')
        self.assertEquals(accepted['epithet'], 'Bulbophyllum')
        self.assertEquals(accepted['ht-rank'], 'familia')
        self.assertEquals(accepted['ht-epithet'], 'Orchidaceae')
コード例 #12
0
ファイル: test.py プロジェクト: odalissalazar/bauble.classic
 def test_on_btnbrowse_clicked(self):
     view = MockView()
     exporter = JSONExporter(view)
     view.reply_file_chooser_dialog = ['/tmp/test.json']
     exporter.on_btnbrowse_clicked('button')
     exporter.on_text_entry_changed('filename')
     self.assertEquals(exporter.filename, '/tmp/test.json')
     self.assertEquals(JSONExporter.last_folder, '/tmp')
コード例 #13
0
ファイル: test.py プロジェクト: odalissalazar/bauble.classic
 def test_export_ignores_private_if_sbo_selection(self):
     exporter = JSONExporter(MockView())
     selection = [o for o in self.objects if isinstance(o, Accession)]
     non_private = [a for a in selection if a.private is False]
     self.assertEquals(len(selection), 3)
     self.assertEquals(len(non_private), 2)
     exporter.view.selection = selection
     exporter.selection_based_on == 'sbo_selection'
     exporter.include_private = False
     exporter.filename = self.temp_path
     exporter.run()
     result = json.load(open(self.temp_path))
     self.assertEquals(len(result), 3)
コード例 #14
0
ファイル: test.py プロジェクト: odalissalazar/bauble.classic
    def test_writes_full_taxonomic_info(self):
        "exporting one family: export full taxonomic information below family"

        selection = self.session.query(Family).filter(
            Family.family == u'Orchidaceae').all()
        exporter = JSONExporter(MockView())
        exporter.selection_based_on == 'sbo_selection'
        exporter.include_private = False
        exporter.view.selection = selection
        exporter.filename = self.temp_path
        exporter.run()
        result = json.load(open(self.temp_path))
        self.assertEquals(len(result), 1)
        self.assertEquals(result[0]['rank'], 'familia')
        self.assertEquals(result[0]['epithet'], 'Orchidaceae')
コード例 #15
0
ファイル: test.py プロジェクト: odalissalazar/bauble.classic
    def test_writes_complete_database(self):
        "exporting without specifying what: export complete database"

        exporter = JSONExporter(MockView())
        exporter.view.selection = None
        exporter.selection_based_on == 'sbo_selection'
        exporter.include_private = False
        exporter.filename = self.temp_path
        exporter.run()
        ## must still check content of generated file!
        result = json.load(open(self.temp_path))
        self.assertEquals(len(result), 11)
        families = [i for i in result
                    if i['object'] == 'taxon' and i['rank'] == 'familia']
        self.assertEquals(len(families), 2)
        genera = [i for i in result
                  if i['object'] == 'taxon' and i['rank'] == 'genus']
        self.assertEquals(len(genera), 2)
        species = [i for i in result
                   if i['object'] == 'taxon' and i['rank'] == 'species']
        self.assertEquals(len(species), 1)
        target = [
            {"epithet": "Orchidaceae", "object": "taxon", "rank": "familia"},
            {"epithet": "Myrtaceae", "object": "taxon", "rank": "familia"},
            {"author": "R. Br.", "epithet": "Calopogon",
             "ht-epithet": "Orchidaceae", "ht-rank": "familia",
             "object": "taxon", "rank": "genus"},
            {"author": "", "epithet": "Panisea", "ht-epithet": "Orchidaceae",
             "ht-rank": "familia", "object": "taxon", "rank": "genus"},
            {"epithet": "tuberosus", "ht-epithet": "Calopogon",
             "ht-rank": "genus", "hybrid": False, "object": "taxon",
             "rank": "species"},
            {"code": "2015.0001", "object": "accession", "private": False,
             "species": "Calopogon tuberosus"},
            {"code": "2015.0002", "object": "accession", "private": False,
             "species": "Calopogon tuberosus"},
            {"code": "2015.0003", "object": "accession", "private": True,
             "species": "Calopogon tuberosus"},
            {"code": "1", "object": "location"},
            {"accession": "2015.0001", "code": "1", "location": "1",
             "memorial": False, "object": "plant", "quantity": 1},
            {"accession": "2015.0003", "code": "1", "location": "1",
             "memorial": False, "object": "plant", "quantity": 1}]
        for o1 in result:
            self.assertTrue(o1 in target)
        for o2 in target:
            self.assertTrue(o1 in result)
コード例 #16
0
ファイル: test.py プロジェクト: odalissalazar/bauble.classic
    def test_writes_partial_taxonomic_info(self):
        "exporting one genus: all species below genus"

        selection = self.session.query(Genus).filter(
            Genus.genus == u'Calopogon').all()
        exporter = JSONExporter(MockView())
        exporter.view.selection = selection
        exporter.selection_based_on == 'sbo_selection'
        exporter.include_private = False
        exporter.filename = self.temp_path
        exporter.run()
        result = json.load(open(self.temp_path))
        self.assertEquals(len(result), 1)
        self.assertEquals(result[0]['rank'], 'genus')
        self.assertEquals(result[0]['epithet'], 'Calopogon')
        self.assertEquals(result[0]['ht-rank'], 'familia')
        self.assertEquals(result[0]['ht-epithet'], 'Orchidaceae')
        self.assertEquals(result[0]['author'], 'R. Br.')
コード例 #17
0
ファイル: test.py プロジェクト: odalissalazar/bauble.classic
    def test_writes_partial_taxonomic_info_species(self):
        "exporting one species: all species below species"

        selection = self.session.query(
            Species).filter(Species.sp == u'tuberosus').join(
            Genus).filter(Genus.genus == u"Calopogon").all()
        exporter = JSONExporter(MockView())
        exporter.view.selection = selection
        exporter.selection_based_on == 'sbo_selection'
        exporter.include_private = False
        exporter.filename = self.temp_path
        exporter.run()
        result = json.load(open(self.temp_path))
        self.assertEquals(len(result), 1)
        self.assertEquals(result[0]['rank'], 'species')
        self.assertEquals(result[0]['epithet'], 'tuberosus')
        self.assertEquals(result[0]['ht-rank'], 'genus')
        self.assertEquals(result[0]['ht-epithet'], 'Calopogon')
        self.assertEquals(result[0]['hybrid'], False)