def test_sort_nosymbols_case_insensitive_strip_accents(self): """Test the sort_nosymbols_case_insensitive_strip_accents method""" method = "sort_nosymbols_case_insensitive_strip_accents" bsm = BibSortWasher(method) self.assertEqual("thooftgerardus", bsm.get_transformed_value("'t Hooft, Gerardus")) self.assertEqual("ahearnmichaelf", bsm.get_transformed_value("A'Hearn, Michael F.")) self.assertEqual("zvolskymilan", bsm.get_transformed_value("Zvolský, Milan"))
def test_sort_alphanumerically_remove_leading_articles(self): """Test the sort_alphanumerically_remove_leading_articles method""" method = "sort_alphanumerically_remove_leading_articles" bsm = BibSortWasher(method) self.assertEqual('title of a record', bsm.get_transformed_value('The title of a record')) self.assertEqual('title of a record', bsm.get_transformed_value('a title of a record')) self.assertEqual('the', bsm.get_transformed_value('The'))
def apply_washer(data_dict, washer): '''The values are filtered using the washer function''' if not washer: return if washer.strip() == 'NOOP': return washer = washer.split(':')[0] #in case we have a locale defined try: method = BibSortWasher(washer) write_message('Washer method found: %s' % washer, verbose=5) for recid in data_dict: new_val = method.get_transformed_value(data_dict[recid]) data_dict[recid] = new_val except InvenioBibSortWasherNotImplementedError, err: write_message("Washer %s is not implemented [%s]." \ %(washer, err), stream=sys.stderr)
def apply_washer(data_dict, washer): '''The values are filtered using the washer function''' if not washer: return if washer.strip() == 'NOOP': return washer = washer.split(':')[0]#in case we have a locale defined try: method = BibSortWasher(washer) write_message('Washer method found: %s' %washer, verbose=5) for recid in data_dict: new_val = method.get_transformed_value(data_dict[recid]) data_dict[recid] = new_val except InvenioBibSortWasherNotImplementedError, err: write_message("Washer %s is not implemented [%s]." \ %(washer, err), stream=sys.stderr)
def test_sort_dates(self): """Test the sort_dates method""" method = "sort_dates" bsm = BibSortWasher(method) self.assertEqual('2010-01-10', bsm.get_transformed_value('2010-01-10')) self.assertEqual('2010-11-10', bsm.get_transformed_value('10 nov 2010')) self.assertEqual('2010-11-01', bsm.get_transformed_value('nov 2010')) self.assertEqual('2010-01-01', bsm.get_transformed_value('2010')) self.assertEqual('2010-11-08', bsm.get_transformed_value('8 nov 2010'))
def test_sort_dates(self): """Test the sort_dates method""" method = "sort_dates" bsm = BibSortWasher(method) self.assertEqual("2010-01-10", bsm.get_transformed_value("2010-01-10")) self.assertEqual("2010-11-10", bsm.get_transformed_value("10 nov 2010")) self.assertEqual("2010-11-01", bsm.get_transformed_value("nov 2010")) self.assertEqual("2010-01-01", bsm.get_transformed_value("2010")) self.assertEqual("2010-11-08", bsm.get_transformed_value("8 nov 2010"))
def test_method_creation(self): """Tests the creation of a method""" method = 'sort_alphanumerically_remove_leading_articles' bsm = BibSortWasher(method) self.assertEqual(bsm.get_washer(), method)