aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--README.rst8
-rwxr-xr-xdlpcvp.py2
-rw-r--r--test/__init__.py0
-rw-r--r--test/test_restAPI.py29
5 files changed, 38 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c18dd8d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+__pycache__/
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..46ee28b
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,8 @@
+Script to detect needed version updates in dlpy_ and subpkgs from
+PyPI_.
+
+.. _dlpy:
+ https://build.opensuse.org/project/show/devel:languages:python
+
+.. _PyPI:
+ https://pypi.org/
diff --git a/dlpcvp.py b/dlpcvp.py
index 189ee2a..e2e1aa1 100755
--- a/dlpcvp.py
+++ b/dlpcvp.py
@@ -20,5 +20,3 @@ def get_version_from_pypi(name, etag=None):
return info_dict['name'], info_dict['version'], resp.info()['ETag']
else:
IOError(resp.info())
-
-print(get_version_from_pypi('m2crypto'))
diff --git a/test/__init__.py b/test/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/__init__.py
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()