data: Metadata.human_name() treats _ like -.
This commit is contained in:
parent
b599ddee5d
commit
a5ebc04f5d
2 changed files with 4 additions and 1 deletions
|
@ -412,6 +412,7 @@ class Metadata(MutableMapping[MetaKey, MetaValue]):
|
|||
'paypal-id': 'PayPal ID',
|
||||
'rt-id': 'Ticket',
|
||||
}
|
||||
_HUMAN_TRANSLATIONS = str.maketrans('-_', ' ')
|
||||
|
||||
def __init__(self, source: MutableMapping[MetaKey, MetaValue]) -> None:
|
||||
self.meta = source
|
||||
|
@ -479,7 +480,7 @@ class Metadata(MutableMapping[MetaKey, MetaValue]):
|
|||
try:
|
||||
retval = cls._HUMAN_NAMES[key]
|
||||
except KeyError:
|
||||
retval = key.replace('-', ' ').title()
|
||||
retval = key.translate(cls._HUMAN_TRANSLATIONS).title()
|
||||
retval = re.sub(r'\bId$', 'ID', retval)
|
||||
cls._HUMAN_NAMES[key] = retval
|
||||
return retval
|
||||
|
|
|
@ -107,6 +107,8 @@ def test_first_link_bad_type_default(simple_txn, meta_value):
|
|||
('receipt', 'Receipt'),
|
||||
('rt-id', 'Ticket'),
|
||||
('tax-statement', 'Tax Statement'),
|
||||
('meta_key', 'Meta Key'),
|
||||
('meta_id', 'Meta ID'),
|
||||
])
|
||||
def test_human_name(meta_name, expected):
|
||||
assert data.Metadata.human_name(meta_name) == expected
|
||||
|
|
Loading…
Reference in a new issue