Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cases should mock ConfigFile file read #120

Closed
sethwoodworth opened this issue Aug 10, 2016 · 1 comment
Closed

Test cases should mock ConfigFile file read #120

sethwoodworth opened this issue Aug 10, 2016 · 1 comment

Comments

@sethwoodworth
Copy link
Contributor

The following five tests break when a user (or travis) haven't created a config file in the right place. It should be possible to mock config.data where needed

test_local_path (gitenberg.tests.test_book.TestBookPath) ... ERROR
test_remote_path (gitenberg.tests.test_book.TestBookPath) ... ERROR
test_remote_path_below_ten (gitenberg.tests.test_book.TestBookPath) ... ERROR
test_config_file_path (gitenberg.tests.test_config.TestConfig) ... ok
test_config_parse (gitenberg.tests.test_config.TestConfig) ... ok
test_make_local_path (gitenberg.tests.test_fetch.TestBookFetcher) ... ok
test_remote_fetch (gitenberg.tests.test_fetch.TestBookFetcher) ... ok
test_init (gitenberg.tests.test_make.TestLocalRepo) ... ERROR
test_init_repo (gitenberg.tests.test_make.TestLocalRepo) ... ERROR
test_editions (gitenberg.tests.test_metadata.PandataTest) ... ok
test_load_from_string (gitenberg.tests.test_metadata.PandataTest) ... ok
test_load_from_url (gitenberg.tests.test_metadata.PandataTest) ... ok
test_smart_properties (gitenberg.tests.test_metadata.PandataTest) ... ok
test_conversion (gitenberg.tests.test_metadata.Rdf2YamlTest) ... ok
test_marc (gitenberg.tests.test_metadata.Yaml2MarcTest) ... ok
test_pandata (gitenberg.tests.test_metadata.Yaml2MarcTest) ... ok
test_init (gitenberg.tests.test_old_metadata.TestBookMetadata) ... ok
test_parse_rdf (gitenberg.tests.test_old_metadata.TestBookMetadata) ... ok

======================================================================
ERROR: test_local_path (gitenberg.tests.test_book.TestBookPath)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/tests/test_book.py", line 15, in setUp
    self.book = Book(3456)
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/book.py", line 32, in __init__
    self.github_repo = GithubRepo(self)
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/push.py", line 26, in __init__
    self.create_api_handler()
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/push.py", line 36, in create_api_handler
    raise config.NotConfigured
NotConfigured: 
-------------------- >> begin captured logging << --------------------
requests.packages.urllib3.connectionpool: INFO: Starting new HTTPS connection (1): raw.githubusercontent.com
requests.packages.urllib3.connectionpool: DEBUG: "GET /gitenberg-dev/pg-wikipedia/master/pg-wd.csv HTTP/1.1" 200 7819
rdflib: INFO: RDFLib Version: 4.2.0
requests.packages.urllib3.connectionpool: INFO: Starting new HTTPS connection (1): raw.githubusercontent.com
requests.packages.urllib3.connectionpool: DEBUG: "GET /gitenberg-dev/Second-Folio/master/list_of_repos.txt HTTP/1.1" 200 2569
--------------------- >> end captured logging << ---------------------

======================================================================
ERROR: test_remote_path (gitenberg.tests.test_book.TestBookPath)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/tests/test_book.py", line 15, in setUp
    self.book = Book(3456)
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/book.py", line 32, in __init__
    self.github_repo = GithubRepo(self)
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/push.py", line 26, in __init__
    self.create_api_handler()
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/push.py", line 36, in create_api_handler
    raise config.NotConfigured
NotConfigured

======================================================================
ERROR: test_remote_path_below_ten (gitenberg.tests.test_book.TestBookPath)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/tests/test_book.py", line 15, in setUp
    self.book = Book(3456)
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/book.py", line 32, in __init__
    self.github_repo = GithubRepo(self)
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/push.py", line 26, in __init__
    self.create_api_handler()
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/push.py", line 36, in create_api_handler
    raise config.NotConfigured
NotConfigured

======================================================================
ERROR: test_init (gitenberg.tests.test_make.TestLocalRepo)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/tests/test_make.py", line 17, in setUp
    self.book = Book(13529)
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/book.py", line 32, in __init__
    self.github_repo = GithubRepo(self)
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/push.py", line 26, in __init__
    self.create_api_handler()
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/push.py", line 36, in create_api_handler
    raise config.NotConfigured
NotConfigured

======================================================================
ERROR: test_init_repo (gitenberg.tests.test_make.TestLocalRepo)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/tests/test_make.py", line 17, in setUp
    self.book = Book(13529)
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/book.py", line 32, in __init__
    self.github_repo = GithubRepo(self)
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/push.py", line 26, in __init__
    self.create_api_handler()
  File "/home/travis/build/gitenberg-dev/gitberg/gitenberg/push.py", line 36, in create_api_handler
    raise config.NotConfigured
NotConfigured

----------------------------------------------------------------------
Ran 18 tests in 1.115s

FAILED (errors=5)

@eshellman
Copy link
Contributor

Fixed in #123. Have just learned Mock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants