Browse Source

Incorporate review

Brendan Abolivier 4 years ago
parent
commit
f9f851f449
6 changed files with 8 additions and 16 deletions
  1. 1 4
      sydent/http/httpclient.py
  2. 0 4
      sydent/replication/peer.py
  3. 2 2
      sydent/sydent.py
  4. 1 3
      tests/test_replication.py
  5. 1 3
      tests/test_start.py
  6. 3 0
      tests/utils.py

+ 1 - 4
sydent/http/httpclient.py

@@ -52,10 +52,7 @@ class HTTPClient(object):
         body = yield readBody(response)
         try:
             # json.loads doesn't allow bytes in Python 3.5
-            if isinstance(body, bytes):
-                body = body.decode("UTF-8")
-
-            json_body = json.loads(body)
+            json_body = json.loads(body.decode("UTF-8"))
         except Exception as e:
             logger.exception("Error parsing JSON from %s", uri)
             raise

+ 0 - 4
sydent/replication/peer.py

@@ -241,10 +241,6 @@ class RemotePeer(Peer):
         :param updateDeferred: The deferred to call the error callback of.
         :type updateDeferred: twisted.internet.defer.Deferred
         """
-        # json.loads doesn't allow bytes in Python 3.5
-        if isinstance(body, bytes):
-            body = body.decode("UTF-8")
-
         errObj = json.loads(body)
         e = RemotePeerError()
         e.errorDict = errObj

+ 2 - 2
sydent/sydent.py

@@ -134,7 +134,7 @@ CONFIG_DEFAULTS = {
 class Sydent:
     def __init__(self, cfg, reactor=twisted.internet.reactor):
         self.reactor = reactor
-        self.config_file = getConfigFilePath()
+        self.config_file = get_config_file_path()
 
         self.cfg = cfg
 
@@ -361,7 +361,7 @@ def get_config_file_path():
 
 
 if __name__ == '__main__':
-    cfg = parse_config_file(getConfigFilePath())
+    cfg = parse_config_file(get_config_file_path())
     setup_logging(cfg)
     syd = Sydent(cfg)
     syd.run()

+ 1 - 3
tests/test_replication.py

@@ -3,13 +3,11 @@ import json
 from mock import Mock
 from sydent.threepid import ThreepidAssociation
 from sydent.threepid.signer import Signer
-from tests.utils import make_request, make_sydent, setup_logging
+from tests.utils import make_request, make_sydent
 from twisted.web.client import Response
 from twisted.internet import defer
 from twisted.trial import unittest
 
-setup_logging()
-
 
 class ReplicationTestCase(unittest.TestCase):
     """Test that a Sydent can correctly replicate data with another Sydent"""

+ 1 - 3
tests/test_start.py

@@ -1,7 +1,5 @@
 from twisted.trial import unittest
-from tests.utils import make_sydent, setup_logging
-
-setup_logging()
+from tests.utils import make_sydent
 
 
 class StartupTestCase(unittest.TestCase):

+ 3 - 0
tests/utils.py

@@ -264,3 +264,6 @@ def setup_logging():
 
     log_level = os.environ.get("SYDENT_TEST_LOG_LEVEL", "ERROR")
     root_logger.setLevel(log_level)
+
+
+setup_logging()