Exemplo n.º 1
0
 def test_import_existing_updates(self):
     "importing existing taxon updates it"
     json_string = '[{"rank": "Species", "epithet": "tuberosus", "ht-rank"'\
         ': "Genus", "ht-epithet": "Calopogon", "hybrid": false, "author"'\
         ': "Britton et al."}]'
     with open(self.temp_path, "w") as f:
         f.write(json_string)
     previously = Species.retrieve_or_create(
         self.session, {'ht-epithet': u"Calopogon",
                        'epithet': u"tuberosus"})
     self.assertEquals(previously.sp_author, None)
     importer = JSONImporter(MockImportView())
     importer.filename = self.temp_path
     importer.on_btnok_clicked(None)
     self.session.commit()
     afterwards = Species.retrieve_or_create(
         self.session, {'ht-epithet': u"Calopogon",
                        'epithet': u"tuberosus"})
     self.assertEquals(afterwards.sp_author, u"Britton et al.")
Exemplo n.º 2
0
    def test_import_ignores_id_updating(self):
        "importing taxon disregards id value if present (updating taxon)."
        previously = Species.retrieve_or_create(self.session,
                                                {'ht-epithet': u"Calopogon",
                                                 'epithet': u"tuberosus"}).id
        json_string = '[{"rank": "Species", "epithet": "tuberosus", '\
            '"ht-rank": "Genus", "ht-epithet": "Calopogon", "hybrid": false, '\
            '"id": 8}]'
        with open(self.temp_path, "w") as f:
            f.write(json_string)
        importer = JSONImporter(MockImportView())
        importer.filename = self.temp_path
        importer.on_btnok_clicked(None)

        self.session.commit()
        afterwards = Species.retrieve_or_create(self.session,
                                                {'ht-epithet': u"Calopogon",
                                                 'epithet': u"tuberosus"}).id
        self.assertEquals(previously, afterwards)
Exemplo n.º 3
0
def species_to_fix(ssn, binomial, author, create=False):
    if binomial.find(' ') == -1:
        return None
    binomial = utils.to_unicode(binomial)
    author = utils.to_unicode(author)
    gen_epithet, sp_epithet = binomial.split(' ', 1)
    return Species.retrieve_or_create(
        ssn, {'object': 'taxon',
              'rank': 'species',
              'ht-epithet': gen_epithet,
              'epithet': sp_epithet,
              'ht-rank': 'genus',
              'author': author},
        create=create)
Exemplo n.º 4
0
def species_to_fix(ssn, binomial, author, create=False):
    if binomial.find(' ') == -1:
        return None
    binomial = utils.to_unicode(binomial)
    author = utils.to_unicode(author)
    gen_epithet, sp_epithet = binomial.split(' ', 1)
    return Species.retrieve_or_create(
        ssn, {'object': 'taxon',
              'rank': 'species',
              'ht-epithet': gen_epithet,
              'epithet': sp_epithet,
              'ht-rank': 'genus',
              'author': author},
        create=create)
Exemplo n.º 5
0
def species_to_fix(ssn, binomial, author, create=False):
    if binomial.find(" ") == -1:
        return None
    binomial = utils.to_unicode(binomial)
    author = utils.to_unicode(author)
    gen_epithet, sp_epithet = binomial.split(" ", 1)
    return Species.retrieve_or_create(
        ssn,
        {
            "object": "taxon",
            "rank": "species",
            "ht-epithet": gen_epithet,
            "epithet": sp_epithet,
            "ht-rank": "genus",
            "author": author,
        },
        create=create,
    )