Source

Kiva Editor's Assistant / tests / test.py

Full commit
#!/bin/env python
from expect import expect


def test_alphanumeric():
    """Test combinations of letters and numbers"""
    expect(u'', u'')
    expect(u'100p of 43th', u'100 p of 43 th')
    expect(u'0th')
    expect(u'1st', u'first')
    expect(u'2nd', u'second')
    expect(u'3rd', u'third')
    expect(u'4th', u'fourth')
    expect(u'10th')
    expect(u'11th')
    expect(u'101st')
    expect(u'102nd')
    expect(u'102st', u'102 st')
    expect(u'1,999,871st')
    expect(u'1th', u'one th')
    expect(u'2rd', u'two rd')


def test_numeric():
    """ Test handling of numbers.
    """
    expect(u'KES50, 000', u'50,000 Kenyan Shilling (KES)')
    expect(u'15, 17, 19')
    expect(u'50, 000, 34', u'50,000, 34')
    expect(u'3.234.134', u'3,234,134')
    expect(u'1', u'one')
    expect(u'1.5')
    expect(u'1000 USD', u'$1000')
    expect(u'10000 USD', u'$10,000')
    expect(u'100000 USD', u'$100,000')
    expect(u'1000000 USD', u'$1,000,000')
    expect(u'10000000 USD', u'$10,000,000')
    expect(u'100000000 USD', u'$100,000,000')


def test_asterisk():
    """Test handling of asterisks used as footnote indicators."""
    expect(u'*foo')
    expect(u'* foo', u'*foo')
    expect(u'foo * bar', u'foo* bar')
    expect(u'foo* bar')


def test_honorifics():
    """Test recognition and capitalization of honorifics."""
    expect('mr.', 'Mr.')
    expect('mrs.', 'Mrs.')
    expect('Mr.')
    expect('Mrs.')


# def test_improve_expand():
#     """Test variations on the improve/expand replacement."""
#     expect("to improve/expand his business.", "to improve and expand it.")
#     expect("to improve/expand her business.", "to improve and expand it.")
#     expect("to improve/expand the borrower's business.", "to improve and expand it.")


def test_output_generation():
    """Test spacing of punctuation in output."""
    expect(u'hello, world')
    expect(u'Kiva/SMT')