Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
beem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
beem
Commits
52203d95
Commit
52203d95
authored
7 years ago
by
Holger Nahrstaedt
Browse files
Options
Downloads
Patches
Plain Diff
_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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beem/comment.py
+13
-12
13 additions, 12 deletions
beem/comment.py
tests/beem/test_comment.py
+14
-4
14 additions, 4 deletions
tests/beem/test_comment.py
with
27 additions
and
16 deletions
beem/comment.py
+
13
−
12
View file @
52203d95
...
...
@@ -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
):
...
...
This diff is collapsed.
Click to expand it.
tests/beem/test_comment.py
+
14
−
4
View file @
52203d95
...
...
@@ -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
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment