diff --git a/tests/test_hooks_add_entity.py b/tests/test_hooks_add_entity.py new file mode 100644 index 0000000000000000000000000000000000000000..8db443009b1297dbc7a3dc952afa8bcd9861c838 --- /dev/null +++ b/tests/test_hooks_add_entity.py @@ -0,0 +1,37 @@ +import pytest + +from import2ledger.hooks import add_entity +from . import Config + +@pytest.mark.parametrize('in_key,payee,out_key,expected', [ + ('payee', 'Alex Smith', 'entity', 'Smith-Alex'), + ('payee', 'Dakota D. Doe', 'entity', 'Doe-Dakota-D'), + ('payee', 'Björk', 'entity', 'Bjork'), + ('payee', 'Fran Doe-Smith', 'entity', 'Doe-Smith-Fran'), + ('payee', 'Alex(Nickname) Smith', 'entity', 'Smith-Alex'), + ('payee', '稲荷', 'entity', '稲荷'), + ('payee', '稲(Jan)荷', 'entity', '稲荷'), + ('payee', 'Pøweł', 'entity', 'Powel'), + ('payee', 'Elyse Jan Smith', 'entity', 'Smith-Elyse-Jan'), + ('payee', 'Jan van Smith', 'entity', 'van-Smith-Jan'), + ('payee', 'Francis da Silva', 'entity', 'da-Silva-Francis'), + ('payee', 'A van der B', 'entity', 'van-der-B-A'), + ('payee', 'A de B de la C', 'entity', 'de-la-C-A-de-B'), + ('corporation', 'Company A', 'corp_entity', 'Company-A'), + ('corporation', 'Company A 99', 'corp_entity', 'Company-A-99'), + ('corporation', 'DX Co.', 'corp_entity', 'DX'), + ('corporation', 'DX Company', 'corp_entity', 'DX'), + ('corporation', 'DX Company Inc.', 'corp_entity', 'DX'), + ('corporation', 'DX Corp', 'corp_entity', 'DX'), + ('corporation', 'DX Corp LLC', 'corp_entity', 'DX'), + ('corporation', 'DX Corporation', 'corp_entity', 'DX'), + ('corporation', 'DX, Inc.', 'corp_entity', 'DX'), + ('corporation', 'DX Incorporated', 'corp_entity', 'DX'), + ('payee', 'Poe Inc', 'entity', 'Inc-Poe'), + ('corporation', 'Silly Van', 'corp_entity', 'Silly-Van'), +]) +def test_add_entity(in_key, payee, out_key, expected): + data = {in_key: payee} + hook = add_entity.AddEntityHook(Config()) + hook.run(data) + assert data[out_key] == expected