commit 92ce2cb0351a0f19f37c8f7b822dcb8cc3965f8f Author: Arturo Filastò arturo@filasto.net Date: Sun Jun 25 19:01:07 2017 +0200
Update test_onion unittests --- ooni/tests/test_onion.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/ooni/tests/test_onion.py b/ooni/tests/test_onion.py index 0807ca02..20023211 100644 --- a/ooni/tests/test_onion.py +++ b/ooni/tests/test_onion.py @@ -49,21 +49,26 @@ class TestOnion(unittest.TestCase): self.assertEqual(onion.bridge_line(transport, '/log.txt'), exp_line)
- with patch.dict(onion.obfsproxy_details, - {'version': onion.OBFSProxyVersion('0.1.12')}): + def mock_get_details(value): + def mocked_get_details(): + return value + return mocked_get_details + + with patch('ooni.utils.onion.get_obfsproxy_details', + mock_get_details({'version': onion.OBFSProxyVersion('0.1.12')})): self.assertRaises(onion.OutdatedObfsproxy, onion.bridge_line, 'obfs2', '/log.txt')
- with patch.dict(onion.tor_details, - {'version': onion.TorVersion('0.2.4.20')}): + with patch('ooni.utils.onion.get_tor_details', + mock_get_details({'version': onion.TorVersion('0.2.4.20')})): onion.bridge_line('fte', '/log.txt') self.assertRaises(onion.OutdatedTor, onion.bridge_line, 'scramblesuit', '/log.txt') self.assertRaises(onion.OutdatedTor, onion.bridge_line, 'obfs4', '/log.txt')
- with patch.dict(onion.tor_details, - {'version': onion.TorVersion('0.2.3.20')}): + with patch('ooni.utils.onion.get_tor_details', + mock_get_details({'version': onion.TorVersion('0.2.3.20')})): self.assertRaises(onion.OutdatedTor, onion.bridge_line, 'fte', '/log.txt')