Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Making GNSync buildable in a test by mocking auth storage
Browse files Browse the repository at this point in the history
  • Loading branch information
wbushey committed Jul 21, 2019
1 parent 3989535 commit 618a3b5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Expand Up @@ -18,8 +18,6 @@ os:

install:
- pip install -r requirements.txt
- python setup.py build
- python setup.py install --bash-completion-dir=/tmp --zsh-completion-dir=/tmp

# command to run tests
script: py.test
script: python -m pytest
3 changes: 3 additions & 0 deletions requirements.txt
Expand Up @@ -7,4 +7,7 @@ beautifulsoup4
proxyenv
pysqlite
lxml

# Testing requirements
pytest
mock
7 changes: 6 additions & 1 deletion tests/test_gnsync.py
Expand Up @@ -57,7 +57,8 @@ def test_strip_nochange(self):

@patch('geeknote.gnsync.logger', autospec=True)
@patch('geeknote.gnsync.GeekNote', autospec=True)
def test_create_file_with_non_ascii_chars(self, mock_geeknote, mock_logger):
@patch('geeknote.gnsync.Storage', autospec=True)
def test_create_file_with_non_ascii_chars(self, mock_storage, mock_geeknote, mock_logger):

# Mock GeekNote#loadNoteContent to provide some content with non-ascii
def mock_note_load(note):
Expand All @@ -66,6 +67,10 @@ def mock_note_load(note):
note.notebookName = 'testNotebook'
mock_geeknote.return_value.loadNoteContent.side_effect = mock_note_load

# Mock Storage().getUserToken() so the GNSync constructor doesn't throw
# an exception
mock_storage.return_value.getUserToken.return_value = True

subject = GNSync('test_notebook', self.test_dir, '*.*',
'plain', download_only=True)

Expand Down

0 comments on commit 618a3b5

Please sign in to comment.