Changeset - 9f45a393b3c1
[Not reviewed]
0 1 1
Brett Smith - 6 years ago 2018-04-02 17:00:09
brettcsmith@brettcsmith.org
tests: Separate test_hooks_add_entity file.

All the hooks are going to get their own test files over time.
2 files changed with 37 insertions and 34 deletions:
0 comments (0 inline, 0 general)
tests/test_hooks.py
Show inline comments
...
 
@@ -19,40 +19,6 @@ def test_load_all():
 
    actual_order = list(sorted(expected_order, key=positions.__getitem__))
 
    assert actual_order == expected_order
 

	
 
@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(argparse.Namespace())
 
    hook.run(data)
 
    assert data[out_key] == expected
 

	
 

	
 
class DateRangeConfig:
 
    def __init__(self, start_date=None, end_date=None):
 
        self.start_date = start_date
tests/test_hooks_add_entity.py
Show inline comments
 
new file 100644
 
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
0 comments (0 inline, 0 general)