right now `direct_get_suffix_hashes` is only being used in probe tests so it's not a big deal - but if it's going to get used anywhere else with out surprise side effects this is bad.
Something like this might work for a test
diff --git a/test/unit/common/test_direct_client.py b/test/unit/common/test_direct_client.py
index 664a622..d543f0e 100644
--- a/test/unit/common/test_direct_client.py
+++ b/test/unit/common/test_direct_client.py
@@ -19,6 +19,7 @@ import os
from contextlib import contextmanager
from hashlib import md5
import time
+import pickle
import mock
import six
@@ -97,7 +98,8 @@ def mocked_http_conn(*args, **kwargs):
class TestDirectClient(unittest.TestCase):
self.account = u'\u062a account'
@@ -732,5 +734,17 @@ class TestDirectClient(unittest.TestCase):
for line in error_lines: self.assertIn('Kaboom!', line)
+ def test_direct_get_suffix_hashes(self):
+ data = {'a83': 'c130a2c17ed45102aada0f4eee69494ff'}
+ body = pickle.dumps(data)
+
+ with mocked_http_conn(200, {}, body) as conn:
+ resp_data = direct_client.direct_get_suffix_hashes(
+ self.node, self.part, ['a83'])
+ self.assertEqual(conn.method, 'REPLICATE')
+ self.assertEqual(conn.path, '/sda/0/a83')
+ self.assertEqual(conn.host, '1.2.3.4')
+ self.assertEqual(data, resp_data)
+
if __name__ == '__main__': unittest.main()
But I feel like that host should be 2.3.4.5, might check port too - are validate the path with multiple hashes
right now `direct_ get_suffix_ hashes` is only being used in probe tests so it's not a big deal - but if it's going to get used anywhere else with out surprise side effects this is bad.
Something like this might work for a test
diff --git a/test/ unit/common/ test_direct_ client. py b/test/ unit/common/ test_direct_ client. py unit/common/ test_direct_ client. py unit/common/ test_direct_ client. py
index 664a622..d543f0e 100644
--- a/test/
+++ b/test/
@@ -19,6 +19,7 @@ import os
from contextlib import contextmanager
from hashlib import md5
import time
+import pickle
import mock http_conn( *args, **kwargs): t(unittest. TestCase) :
import six
@@ -97,7 +98,8 @@ def mocked_
class TestDirectClien
def setUp(self):
self. part = '0'
- self.node = {'ip': '1.2.3.4', 'port': '6000', 'device': 'sda'}
+ self.node = {'ip': '1.2.3.4', 'port': '6000', 'device': 'sda',
+ 'replication_ip': '2.3.4.5', 'replication_port': '7000'}
@@ -732,5 +734,17 @@ class TestDirectClien
for line in error_lines:
+ def test_direct_ get_suffix_ hashes( self): 02aada0f4eee694 94ff'} http_conn( 200, {}, body) as conn: client. direct_ get_suffix_ hashes( l(conn. method, 'REPLICATE') l(conn. path, '/sda/0/a83') l(conn. host, '1.2.3.4') l(data, resp_data)
unittest. main()
+ data = {'a83': 'c130a2c17ed451
+ body = pickle.dumps(data)
+
+ with mocked_
+ resp_data = direct_
+ self.node, self.part, ['a83'])
+ self.assertEqua
+ self.assertEqua
+ self.assertEqua
+ self.assertEqua
+
if __name__ == '__main__':
But I feel like that host should be 2.3.4.5, might check port too - are validate the path with multiple hashes