Skip to content

Commit

Permalink
Test stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
gforcada committed May 31, 2017
1 parent b79bbcb commit 245c2a7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions run_tests.py
Expand Up @@ -3,6 +3,7 @@
from tempfile import mkdtemp

import os
import mock
import unittest


Expand Down Expand Up @@ -116,6 +117,24 @@ def test_version(self):
self.assertTrue(ret[0][2].startswith('P001 found '))
self.assertIn('1.3.3', ret[0][2])

@mock.patch('flake8_plone_api.stdin_utils.stdin_get_value')
def test_stdin(self, stdin_get_value):
stdin_value = mock.Mock()
stdin_value.splitlines.return_value = [
'from plone import searchResults\n',
'\n',
'searchResults(3)\n',
]
stdin_get_value.return_value = stdin_value

checker = PloneAPIChecker(None, 'stdin')
ret = list(checker.run())
self.assertEqual(len(ret), 1)
self.assertEqual(ret[0][0], 3)
self.assertEqual(ret[0][1], 0)
self.assertTrue(ret[0][2].startswith('P001 found '))
self.assertIn('1.3.3', ret[0][2])


if __name__ == '__main__':
unittest.main()
3 changes: 3 additions & 0 deletions tox.ini
Expand Up @@ -2,13 +2,16 @@
envlist=py

[testenv]
deps=
mock
passenv=
TRAVIS*
commands=
python run_tests.py

[testenv:coverage]
deps=
mock
pytest
pytest-cov
coveralls
Expand Down

0 comments on commit 245c2a7

Please sign in to comment.