-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
836 additions
and
771 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Configuration for coverage.py (https://pypi.python.org/pypi/coverage) | ||
|
||
[run] | ||
# Enable branch coverage | ||
branch = True | ||
|
||
[report] | ||
|
||
# Regexes for lines to exclude from consideration | ||
exclude_lines = | ||
# Allow source to designate lines/branches to be skipped | ||
pragma: no cover | ||
|
||
# Ignore non-runnable code | ||
if __name__ == .__main__.: | ||
|
||
# Only check coverage for source files | ||
include = | ||
yv_suggest/open.py | ||
yv_suggest/search.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
# Files generated by OS | ||
.DS_Store | ||
*.pyc | ||
__pycache__ | ||
|
||
# Python bytecode | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# Unit test / coverage reports | ||
cover/ | ||
.coverage | ||
coverage.xml | ||
nosetests.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,15 @@ | ||
#!/usr/bin/env python | ||
|
||
import unittest | ||
import nose.tools as nose | ||
import pep8 | ||
import glob | ||
import os | ||
|
||
|
||
class TestPep8(unittest.TestCase): | ||
"""test all python source files for pep8 compliance""" | ||
|
||
def test_source_pep8_compliant(self): | ||
"""source files should comply with pep8""" | ||
style_guide = pep8.StyleGuide(quiet=True) | ||
result = style_guide.check_files(glob.iglob('yv_suggest/*.py')) | ||
self.assertEqual(result.total_errors, 0, | ||
'Source files are not pep8-compliant') | ||
|
||
def test_test_pep8_compliant(self): | ||
"""unit tests should comply with pep8""" | ||
def test_source_compliance(): | ||
"""source files should comply with pep8""" | ||
files = glob.iglob('*/*.py') | ||
for file in files: | ||
style_guide = pep8.StyleGuide(quiet=True) | ||
result = style_guide.check_files(glob.iglob('tests/*.py')) | ||
self.assertEqual(result.total_errors, 0, | ||
'Unit tests not pep8-compliant') | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
total_errors = style_guide.input_file(file) | ||
msg = '{} is not pep8-compliant'.format(file) | ||
yield nose.assert_equal, total_errors, 0, msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,81 @@ | ||
#!/usr/bin/env python | ||
|
||
import unittest | ||
import nose.tools as nose | ||
import yv_suggest.search as yvs | ||
|
||
|
||
class SearchBookTestCase(unittest.TestCase): | ||
"""test the searching of Bible books""" | ||
|
||
def test_partial(self): | ||
"""should match books by partial name""" | ||
results = yvs.get_result_list('luk') | ||
self.assertEqual(len(results), 1) | ||
self.assertEqual(results[0]['title'], 'Luke') | ||
|
||
def test_case(self): | ||
"""should match books irrespective of case""" | ||
query_str = 'Matthew' | ||
results = yvs.get_result_list(query_str) | ||
results_lower = yvs.get_result_list(query_str.lower()) | ||
results_upper = yvs.get_result_list(query_str.upper()) | ||
self.assertEqual(len(results), 1) | ||
self.assertListEqual(results_lower, results) | ||
self.assertListEqual(results_upper, results) | ||
|
||
def test_whitespace(self): | ||
"""should match books irrespective of surrounding whitespace""" | ||
results = yvs.get_result_list(' romans ') | ||
self.assertEqual(len(results), 1) | ||
self.assertEqual(results[0]['title'], 'Romans') | ||
|
||
def test_partial_ambiguous(self): | ||
"""should match books by ambiguous partial name""" | ||
results = yvs.get_result_list('r') | ||
self.assertEqual(len(results), 3) | ||
self.assertEqual(results[0]['title'], 'Ruth') | ||
self.assertEqual(results[1]['title'], 'Romans') | ||
self.assertEqual(results[2]['title'], 'Revelation') | ||
|
||
def test_multiple_words(self): | ||
"""should match books with names comprised of multiple words""" | ||
results = yvs.get_result_list('song of songs') | ||
self.assertEqual(len(results), 1) | ||
self.assertEqual(results[0]['title'], 'Song of Songs') | ||
|
||
def test_numbered_partial(self): | ||
"""should match numbered books by partial numbered name""" | ||
results = yvs.get_result_list('1 cor') | ||
self.assertEqual(len(results), 1) | ||
self.assertEqual(results[0]['title'], '1 Corinthians') | ||
|
||
def test_numbered_whitespace(self): | ||
"""should match numbered books irrespective of extra whitespace""" | ||
results = yvs.get_result_list('1 cor') | ||
self.assertEqual(len(results), 1) | ||
self.assertEqual(results[0]['title'], '1 Corinthians') | ||
|
||
def test_nonnumbered_partial(self): | ||
"""should match numbered books by partial non-numbered name""" | ||
results = yvs.get_result_list('john') | ||
self.assertEqual(len(results), 4) | ||
self.assertEqual(results[0]['title'], 'John') | ||
self.assertEqual(results[1]['title'], '1 John') | ||
self.assertEqual(results[2]['title'], '2 John') | ||
self.assertEqual(results[3]['title'], '3 John') | ||
|
||
def test_id(self): | ||
"""should use correct ID for books""" | ||
results = yvs.get_result_list('philippians') | ||
self.assertEqual(results[0]['uid'], 'niv/php.1') | ||
|
||
def test_nonexistent(self): | ||
"""should not match nonexistent books""" | ||
results = yvs.get_result_list('jesus') | ||
self.assertEqual(len(results), 0) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
def test_partial(): | ||
"""should match books by partial name""" | ||
results = yvs.get_result_list('luk') | ||
nose.assert_equal(len(results), 1) | ||
nose.assert_equal(results[0]['title'], 'Luke') | ||
|
||
|
||
def test_case(): | ||
"""should match books irrespective of case""" | ||
query_str = 'Matthew' | ||
results = yvs.get_result_list(query_str) | ||
results_lower = yvs.get_result_list(query_str.lower()) | ||
results_upper = yvs.get_result_list(query_str.upper()) | ||
nose.assert_equal(len(results), 1) | ||
nose.assert_list_equal(results_lower, results) | ||
nose.assert_list_equal(results_upper, results) | ||
|
||
|
||
def test_whitespace(): | ||
"""should match books irrespective of surrounding whitespace""" | ||
results = yvs.get_result_list(' romans ') | ||
nose.assert_equal(len(results), 1) | ||
nose.assert_equal(results[0]['title'], 'Romans') | ||
|
||
|
||
def test_partial_ambiguous(): | ||
"""should match books by ambiguous partial name""" | ||
results = yvs.get_result_list('r') | ||
nose.assert_equal(len(results), 3) | ||
nose.assert_equal(results[0]['title'], 'Ruth') | ||
nose.assert_equal(results[1]['title'], 'Romans') | ||
nose.assert_equal(results[2]['title'], 'Revelation') | ||
|
||
|
||
def test_multiple_words(): | ||
"""should match books with names comprised of multiple words""" | ||
results = yvs.get_result_list('song of songs') | ||
nose.assert_equal(len(results), 1) | ||
nose.assert_equal(results[0]['title'], 'Song of Songs') | ||
|
||
|
||
def test_numbered_partial(): | ||
"""should match numbered books by partial numbered name""" | ||
results = yvs.get_result_list('1 cor') | ||
nose.assert_equal(len(results), 1) | ||
nose.assert_equal(results[0]['title'], '1 Corinthians') | ||
|
||
|
||
def test_numbered_whitespace(): | ||
"""should match numbered books irrespective of extra whitespace""" | ||
results = yvs.get_result_list('1 cor') | ||
nose.assert_equal(len(results), 1) | ||
nose.assert_equal(results[0]['title'], '1 Corinthians') | ||
|
||
|
||
def test_nonnumbered_partial(): | ||
"""should match numbered books by partial non-numbered name""" | ||
results = yvs.get_result_list('john') | ||
nose.assert_equal(len(results), 4) | ||
nose.assert_equal(results[0]['title'], 'John') | ||
nose.assert_equal(results[1]['title'], '1 John') | ||
nose.assert_equal(results[2]['title'], '2 John') | ||
nose.assert_equal(results[3]['title'], '3 John') | ||
|
||
|
||
def test_id(): | ||
"""should use correct ID for books""" | ||
results = yvs.get_result_list('philippians') | ||
nose.assert_equal(results[0]['uid'], 'niv/php.1') | ||
|
||
|
||
def test_nonexistent(): | ||
"""should not match nonexistent books""" | ||
results = yvs.get_result_list('jesus') | ||
nose.assert_equal(len(results), 0) |
Oops, something went wrong.