示例#1
0
def test_whitespace_words():
    """should handle spaces appropriately"""
    ref_content = yvs.get_copied_ref('111/psa.23')
    nose.assert_regexp_matches(ref_content, 'adipiscing elit.',
                               'should respect content consisting of spaces')
    nose.assert_regexp_matches(ref_content, 'consectetur adipiscing',
                               'should collapse consecutive spaces')
示例#2
0
def test_main(out):
    """main function should output copied reference content"""
    ref_uid = '59/psa.23'
    ref_content = yvs.get_copied_ref(ref_uid)
    yvs.main(ref_uid)
    main_json = json.loads(out.getvalue())
    nose.assert_equal(main_json, {
        'alfredworkflow': {
            'arg': ref_uid,
            'variables': {
                'copied_ref': ref_content,
                'full_ref_name': 'Psalms 23 (ESV)'
            }
        }
    })
示例#3
0
def test_whitespace_lines():
    """should add line breaks where appropriate"""
    ref_content = yvs.get_copied_ref('111/psa.23')
    nose.assert_regexp_matches(ref_content, r'Psalms 23 \(NIV\)\n\n\S',
                               'should add two line breaks after header')
    nose.assert_regexp_matches(ref_content, r'amet,\nconsectetur',
                               'should add newline before each p block')
    nose.assert_regexp_matches(ref_content, r'erat.\n\n\S',
                               'should add newline after each p block')
    nose.assert_regexp_matches(ref_content, r'orci,\ndapibus',
                               'should add newline between each qc block')
    nose.assert_regexp_matches(ref_content, r'nec\nfermentum',
                               'should add newline between each q block')
    nose.assert_regexp_matches(ref_content, r'elit.\n\nUt',
                               'should add newlines around each li1 block')
    nose.assert_regexp_matches(ref_content, r'leo,\n\nhendrerit',
                               'should add two newlines for each b block')
示例#4
0
def test_header_language():
    """reference header should reflect chosen language"""
    ref_content = yvs.get_copied_ref('128/psa.23')
    nose.assert_regexp_matches(ref_content, r'^Salmo 23 \(NVI\)')
示例#5
0
def test_header():
    """should prepend reference header to copied string"""
    ref_content = yvs.get_copied_ref('59/psa.23')
    nose.assert_regexp_matches(ref_content, r'^Psalms 23 \(ESV\)')
示例#6
0
def test_refformat():
    """should honor the chosen reference format"""
    ref_content = yvs.get_copied_ref('59/psa.23.6')
    nose.assert_equals(ref_content, '"Proin nulla orci,"\n\n(Psalms 23:6 ESV)')
示例#7
0
def test_copy_verse_range():
    """should copy reference content for verse range"""
    ref_content = yvs.get_copied_ref('111/psa.23.1-2')
    nose.assert_regexp_matches(ref_content, 'Lorem')
    nose.assert_regexp_matches(ref_content, 'nunc nulla')
    nose.assert_not_regexp_matches(ref_content, 'fermentum')
示例#8
0
def test_copy_chapter():
    """should copy reference content for chapter"""
    ref_content = yvs.get_copied_ref('111/psa.23')
    nose.assert_regexp_matches(ref_content, 'Lorem')
    nose.assert_regexp_matches(ref_content, 'nunc nulla')
    nose.assert_regexp_matches(ref_content, 'fermentum')
示例#9
0
def test_nonexistent_verse():
    """should return empty string for nonexistent verses"""
    ref_content = yvs.get_copied_ref('111/psa.23.13')
    nose.assert_equal(ref_content, '')
示例#10
0
def test_unicode_content():
    """should return copied reference content as Unicode"""
    ref_content = yvs.get_copied_ref('111/psa.23')
    nose.assert_is_instance(ref_content, str)
示例#11
0
def test_cache_url_content():
    """should cache chapter URL content after first fetch"""
    yvs.get_copied_ref('59/psa.23.2')
    with patch('urllib.request.Request') as request:
        yvs.get_copied_ref('59/psa.23.3')
        request.assert_not_called()
示例#12
0
def test_url_always_chapter(get_url_content):
    """should always fetch HTML from chapter URL"""
    yvs.get_copied_ref('59/psa.23.2')
    get_url_content.assert_called_once_with(
        'https://www.bible.com/bible/59/PSA.23')
示例#13
0
def test_versenumbers_range_middle():
    """should handle range labels when verse in middle of range is given"""
    ref_content = yvs.get_copied_ref('111/psa.23.8')
    nose.assert_regexp_matches(ref_content, r'7-9 dapibus et augue in,')
    nose.assert_not_regexp_matches(ref_content, r'#')
示例#14
0
def test_versenumbers_range():
    """should handle verse range labels (used by versions like the MSG)"""
    ref_content = yvs.get_copied_ref('111/psa.23.7-9')
    nose.assert_regexp_matches(ref_content, r'7-9 dapibus et augue in,')
    nose.assert_not_regexp_matches(ref_content, r'#')
示例#15
0
def test_versenumbers():
    """should honor the versenumbers preference"""
    ref_content = yvs.get_copied_ref('111/psa.23')
    nose.assert_regexp_matches(ref_content, r'5 fermentum')
    nose.assert_not_regexp_matches(ref_content, r'#')