diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2018-06-19 21:29:28 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2018-06-19 21:29:28 +0200 |
commit | 1dea6cee281ac09e813d29d29edc32db83f80202 (patch) | |
tree | 125eb4711af782eac3df09d25452597d793d9355 /test/test_restAPI.py | |
parent | f1ed1220a287e3321a4efaeb32a3613ef4d7942d (diff) | |
download | dlp_check_version_PyPI-1dea6cee281ac09e813d29d29edc32db83f80202.tar.gz |
Add some embryo of a test suite.
Diffstat (limited to 'test/test_restAPI.py')
-rw-r--r-- | test/test_restAPI.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/test_restAPI.py b/test/test_restAPI.py new file mode 100644 index 0000000..ac00996 --- /dev/null +++ b/test/test_restAPI.py @@ -0,0 +1,29 @@ +import unittest +from unittest.mock import patch, MagicMock + +import dlpcvp + +class TestUrlopen(unittest.TestCase): + @patch('dlpcvp.urllib.request.urlopen') + def test_get_version_called_url(self, mock_obj): + result = dlpcvp.get_version_from_pypi('m2crypto') + url = dlpcvp.PyPI_base.format('m2crypto') + req_obj = mock_obj.call_args[0][0] + self.assertEqual(req_obj.full_url, url) + mock_obj.assert_called_once() + + @unittest.skip('Not done yet') + @patch('dlpcvp.urllib.request.urlopen') + def test_get_version_returned(self, mock_obj): + mock_obj.read.return_value = { + 'info': { + "name": "M2CryptoTest", + "version": '42' + } + } + mock_obj.info.return_value = 'AAA' + expected = ('M2CryptoTest', '0.30.1', 'AAA') + + result = dlpcvp.get_version_from_pypi('m2crypto') + self.assertEqual(result, expected) + mock_obj.assert_called_once() |