diff --git a/.travis.yml b/.travis.yml index 4e4f1e4..535605a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/requirements.txt b/requirements.txt index e393f0f..1c5fc71 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,7 @@ beautifulsoup4 proxyenv pysqlite lxml + +# Testing requirements +pytest mock diff --git a/tests/test_gnsync.py b/tests/test_gnsync.py index faa72f9..70cccba 100644 --- a/tests/test_gnsync.py +++ b/tests/test_gnsync.py @@ -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): @@ -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)