Skip to content
Snippets Groups Projects
Commit 52203d95 authored by Holger Nahrstaedt's avatar Holger Nahrstaedt
Browse files

_metadata_to_dict added to comment

test_comment
* preselect working node
parent ca67f885
No related branches found
No related tags found
No related merge requests found
......@@ -72,9 +72,7 @@ class Comment(BlockchainObject):
self[p] = Amount(self.get(p, "0.000 SBD"), steem_instance=self.steem)
# turn json_metadata into python dict
meta_str = self.get("json_metadata", "{}")
if isinstance(meta_str, (string_types, bytes_types, bytearray)):
self['json_metadata'] = json.loads(meta_str)
self.__metadata_to_dict()
self["tags"] = []
self['community'] = ''
if isinstance(self['json_metadata'], dict):
......@@ -83,6 +81,17 @@ class Comment(BlockchainObject):
if 'community' in self['json_metadata']:
self['community'] = self['json_metadata']['community']
def _metadata_to_dict(self):
"""turn json_metadata into python dict"""
meta_str = self.get("json_metadata", "{}")
if isinstance(meta_str, (string_types, bytes_types, bytearray)):
try:
self['json_metadata'] = json.loads(meta_str)
except:
self['json_metadata'] = {}
else:
self['json_metadata'] = {}
def refresh(self):
if self.identifier == "":
return
......@@ -119,15 +128,7 @@ class Comment(BlockchainObject):
if p in self and isinstance(self.get(p), string_types):
self[p] = Amount(self.get(p, "0.000 SBD"), steem_instance=self.steem)
# turn json_metadata into python dict
meta_str = self.get("json_metadata", "{}")
if isinstance(meta_str, (string_types, bytes_types, bytearray)):
try:
self['json_metadata'] = json.loads(meta_str)
except:
self['json_metadata'] = {}
else:
self['json_metadata'] = {}
self._metadata_to_dict()
self["tags"] = []
self['community'] = ''
if isinstance(self['json_metadata'], dict):
......
......@@ -32,10 +32,23 @@ class Testcases(unittest.TestCase):
keys={"active": wif},
num_retries=10
)
self.authorperm = "@gtg/witness-gtg-log"
# from getpass import getpass
# self.bts.wallet.unlock(getpass())
set_shared_steem_instance(self.bts)
self.bts.set_default_account("test")
cnt = 0
title = ''
while cnt < 5 and title == '':
c = Comment("@gtg/witness-gtg-log", steem_instance=self.bts)
title = c["title"]
self.bts.rpc.next()
cnt = 0
title = ''
while cnt < 5 and title == '':
c = Comment("@gtg/witness-gtg-log", steem_instance=self.appbase)
title = c["title"]
self.appbase.rpc.next()
@parameterized.expand([
("non_appbase"),
......@@ -50,10 +63,7 @@ class Testcases(unittest.TestCase):
exceptions.ContentDoesNotExistsException
):
Comment("@abcdef/abcdef", steem_instance=bts)
try:
c = Comment("@gtg/witness-gtg-log", steem_instance=bts)
except exceptions.ContentDoesNotExistsException:
c = Comment("@gtg/witness-gtg-log", steem_instance=bts)
c = Comment("@gtg/witness-gtg-log", steem_instance=bts)
self.assertTrue(isinstance(c.id, int))
self.assertTrue(c.id > 0)
self.assertEqual(c.author, "gtg")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment