From 355135f386445068b39a21f591cbd3d59e64a2d1 Mon Sep 17 00:00:00 2001
From: Inso <insomniak.fr@gmail.com>
Date: Mon, 14 Sep 2015 20:08:59 +0200
Subject: [PATCH] Pass tests

---
 src/cutecoin/core/account.py                        |  2 +-
 .../gui/process_cfg_community/test_add_community.py |  5 +++--
 src/cutecoin/tests/gui/transfer/test_transfer.py    |  2 +-
 src/cutecoin/tests/mocks/bma/nice_blockchain.py     | 13 +++++++++++++
 src/cutecoin/tests/stubs/core/registry/identity.py  |  2 +-
 5 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py
index d14e03b6..3c193707 100644
--- a/src/cutecoin/core/account.py
+++ b/src/cutecoin/core/account.py
@@ -299,7 +299,7 @@ class Account(QObject):
             error = 0
             replies = yield from community.bma_access.broadcast(bma.wot.Add, {}, {'pubkey': self.pubkey,
                                               'self_': selfcert.signed_raw(),
-                                              'other': ""})
+                                              'other': {}})
         except ValueError as e:
             error += 1
             error_msg = str(e)
diff --git a/src/cutecoin/tests/gui/process_cfg_community/test_add_community.py b/src/cutecoin/tests/gui/process_cfg_community/test_add_community.py
index 784028a7..9cacc9e2 100644
--- a/src/cutecoin/tests/gui/process_cfg_community/test_add_community.py
+++ b/src/cutecoin/tests/gui/process_cfg_community/test_add_community.py
@@ -86,9 +86,10 @@ class ProcessAddCommunity(unittest.TestCase):
                 self.assertEqual(mock.get_request(i).method, 'GET')
                 self.assertEqual(mock.get_request(i).url,
                                  '/wot/lookup/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ')
+            yield from asyncio.sleep(1)
 
-            self.assertEqual(mock.get_request(6).method, 'POST')
-            self.assertEqual(mock.get_request(6).url[:8], '/wot/add')
+            self.assertEqual(mock.get_request(5).method, 'POST')
+            self.assertEqual(mock.get_request(5).url[:8], '/wot/add')
             self.assertEqual(process_community.label_error.text(), "Broadcasting identity...")
             yield from asyncio.sleep(1)
 
diff --git a/src/cutecoin/tests/gui/transfer/test_transfer.py b/src/cutecoin/tests/gui/transfer/test_transfer.py
index ab3e32b9..f3c35f4f 100644
--- a/src/cutecoin/tests/gui/transfer/test_transfer.py
+++ b/src/cutecoin/tests/gui/transfer/test_transfer.py
@@ -39,7 +39,7 @@ class TestTransferDialog(unittest.TestCase):
         self.endpoint = BMAEndpoint("", "127.0.0.1", "", 50000)
         self.node = Node(self.network_manager, "test_currency", [self.endpoint],
                          "", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk",
-                         bma.blockchain.Block.null_value, Node.ONLINE,
+                         None, Node.ONLINE,
                          time.time(), {}, "ucoin", "0.14.0", 0)
         self.network = Network.create(self.network_manager, self.node)
         self.bma_access = BmaAccess.create(self.network)
diff --git a/src/cutecoin/tests/mocks/bma/nice_blockchain.py b/src/cutecoin/tests/mocks/bma/nice_blockchain.py
index 76a77edf..c11b82d5 100644
--- a/src/cutecoin/tests/mocks/bma/nice_blockchain.py
+++ b/src/cutecoin/tests/mocks/bma/nice_blockchain.py
@@ -251,6 +251,13 @@ bma_txsources_john = {
 }
 ]}
 
+bma_with_ud = {
+    "result":
+    {
+        "blocks": []
+    }
+}
+
 
 def get_mock():
     mock = HTTPMock('127.0.0.1', 50000)
@@ -266,6 +273,12 @@ def get_mock():
                 times=FOREVER,
                 headers={'Content-Type': 'application/json'})
 
+    mock.when('GET /blockchain/with/UD')\
+            .reply(body=bytes(json.dumps(bma_with_ud), "utf-8"),
+                status=200,
+                times=FOREVER,
+                headers={'Content-Type': 'application/json'})
+
     mock.when('GET /blockchain/current')\
             .reply(body=bytes(json.dumps(bma_blockchain_current), "utf-8"),
                 status=200,
diff --git a/src/cutecoin/tests/stubs/core/registry/identity.py b/src/cutecoin/tests/stubs/core/registry/identity.py
index a6da4340..9c3faee1 100644
--- a/src/cutecoin/tests/stubs/core/registry/identity.py
+++ b/src/cutecoin/tests/stubs/core/registry/identity.py
@@ -12,7 +12,7 @@ from ucoinpy.documents.certification import SelfCertification
 from cutecoin.tools.exceptions import Error, NoPeerAvailable,\
                                         MembershipNotFoundError
 from ucoinpy.api import bma
-from cutecoin.core.net.api.bma import PROTOCOL_VERSION
+from ucoinpy.api.bma import PROTOCOL_VERSION
 from PyQt5.QtCore import QObject, pyqtSignal
 
 
-- 
GitLab