2015-09-15 17:12:15 +00:00
|
|
|
from io import StringIO
|
2015-05-31 01:12:01 +00:00
|
|
|
import mock
|
|
|
|
from netlib import version_check, version
|
|
|
|
|
|
|
|
|
2015-08-03 16:06:31 +00:00
|
|
|
@mock.patch("sys.exit")
|
|
|
|
def test_check_pyopenssl_version(sexit):
|
2015-09-15 17:12:15 +00:00
|
|
|
fp = StringIO()
|
2015-08-03 16:06:31 +00:00
|
|
|
version_check.check_pyopenssl_version(fp=fp)
|
|
|
|
assert not fp.getvalue()
|
|
|
|
assert not sexit.called
|
|
|
|
|
|
|
|
version_check.check_pyopenssl_version((9999,), fp=fp)
|
2015-09-10 10:32:38 +00:00
|
|
|
assert "outdated" in fp.getvalue()
|
2015-05-31 01:12:01 +00:00
|
|
|
assert sexit.called
|
2015-09-10 10:32:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
@mock.patch("sys.exit")
|
|
|
|
@mock.patch("OpenSSL.__version__")
|
|
|
|
def test_unparseable_pyopenssl_version(version, sexit):
|
|
|
|
version.split.return_value = ["foo", "bar"]
|
2015-09-15 17:12:15 +00:00
|
|
|
fp = StringIO()
|
2015-09-10 10:32:38 +00:00
|
|
|
version_check.check_pyopenssl_version(fp=fp)
|
|
|
|
assert "Cannot parse" in fp.getvalue()
|
|
|
|
assert not sexit.called
|