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
4abe6902
Commit
4abe6902
authored
4 years ago
by
Holger
Browse files
Options
Downloads
Patches
Plain Diff
Improve unit test for comments
parent
c10e10ed
No related branches found
No related tags found
2 merge requests
!5
Taken current version of master branch in the https://github.com/holgern/beem
,
!4
Original changes pushed to master at https://github.com/holgern/beem
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beem/comment.py
+2
-0
2 additions, 0 deletions
beem/comment.py
tests/beem/test_comment.py
+21
-21
21 additions, 21 deletions
tests/beem/test_comment.py
with
23 additions
and
21 deletions
beem/comment.py
+
2
−
0
View file @
4abe6902
...
@@ -126,6 +126,7 @@ class Comment(BlockchainObject):
...
@@ -126,6 +126,7 @@ class Comment(BlockchainObject):
parse_int
=
[
parse_int
=
[
"
author_reputation
"
,
"
author_reputation
"
,
"
net_rshares
"
,
]
]
for
p
in
parse_int
:
for
p
in
parse_int
:
if
p
in
comment
and
isinstance
(
comment
.
get
(
p
),
string_types
):
if
p
in
comment
and
isinstance
(
comment
.
get
(
p
),
string_types
):
...
@@ -210,6 +211,7 @@ class Comment(BlockchainObject):
...
@@ -210,6 +211,7 @@ class Comment(BlockchainObject):
output
[
p
]
=
output
[
p
].
json
()
output
[
p
]
=
output
[
p
].
json
()
parse_int
=
[
parse_int
=
[
"
author_reputation
"
,
"
author_reputation
"
,
"
net_rshares
"
,
]
]
for
p
in
parse_int
:
for
p
in
parse_int
:
if
p
in
output
and
isinstance
(
output
[
p
],
integer_types
):
if
p
in
output
and
isinstance
(
output
[
p
],
integer_types
):
...
...
This diff is collapsed.
Click to expand it.
tests/beem/test_comment.py
+
21
−
21
View file @
4abe6902
...
@@ -6,11 +6,11 @@ from builtins import super, str
...
@@ -6,11 +6,11 @@ from builtins import super, str
import
unittest
import
unittest
from
parameterized
import
parameterized
from
parameterized
import
parameterized
from
pprint
import
pprint
from
pprint
import
pprint
from
beem
import
Steem
,
exceptions
from
beem
import
Hive
,
exceptions
from
beem.comment
import
Comment
,
RecentReplies
,
RecentByPath
,
RankedPosts
from
beem.comment
import
Comment
,
RecentReplies
,
RecentByPath
,
RankedPosts
from
beem.vote
import
Vote
from
beem.vote
import
Vote
from
beem.account
import
Account
from
beem.account
import
Account
from
beem.instance
import
set_shared_
steem
_instance
from
beem.instance
import
set_shared_
blockchain
_instance
from
beem.utils
import
resolve_authorperm
from
beem.utils
import
resolve_authorperm
from
beem.nodelist
import
NodeList
from
beem.nodelist
import
NodeList
...
@@ -21,10 +21,10 @@ class Testcases(unittest.TestCase):
...
@@ -21,10 +21,10 @@ class Testcases(unittest.TestCase):
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
nodelist
=
NodeList
()
nodelist
=
NodeList
()
nodelist
.
update_nodes
(
steem
_instance
=
Steem
(
node
=
nodelist
.
get_hive_nodes
(),
num_retries
=
10
))
nodelist
.
update_nodes
(
blockchain
_instance
=
Hive
(
node
=
nodelist
.
get_hive_nodes
(),
num_retries
=
10
))
node_list
=
nodelist
.
get_hive_nodes
()
node_list
=
nodelist
.
get_hive_nodes
()
cls
.
bts
=
Steem
(
cls
.
bts
=
Hive
(
node
=
node_list
,
node
=
node_list
,
use_condenser
=
True
,
use_condenser
=
True
,
nobroadcast
=
True
,
nobroadcast
=
True
,
...
@@ -33,8 +33,8 @@ class Testcases(unittest.TestCase):
...
@@ -33,8 +33,8 @@ class Testcases(unittest.TestCase):
num_retries
=
10
num_retries
=
10
)
)
acc
=
Account
(
"
fullnodeupdate
"
,
steem
_instance
=
cls
.
bts
)
acc
=
Account
(
"
fullnodeupdate
"
,
blockchain
_instance
=
cls
.
bts
)
comment
=
Comment
(
acc
.
get_blog_entries
(
limit
=
5
)[
0
],
steem
_instance
=
cls
.
bts
)
comment
=
Comment
(
acc
.
get_blog_entries
(
limit
=
5
)[
0
],
blockchain
_instance
=
cls
.
bts
)
cls
.
authorperm
=
comment
.
authorperm
cls
.
authorperm
=
comment
.
authorperm
[
author
,
permlink
]
=
resolve_authorperm
(
cls
.
authorperm
)
[
author
,
permlink
]
=
resolve_authorperm
(
cls
.
authorperm
)
cls
.
author
=
author
cls
.
author
=
author
...
@@ -43,7 +43,7 @@ class Testcases(unittest.TestCase):
...
@@ -43,7 +43,7 @@ class Testcases(unittest.TestCase):
cls
.
title
=
comment
.
title
cls
.
title
=
comment
.
title
# from getpass import getpass
# from getpass import getpass
# self.bts.wallet.unlock(getpass())
# self.bts.wallet.unlock(getpass())
# set_shared_
steem
_instance(cls.bts)
# set_shared_
blockchain
_instance(cls.bts)
# cls.bts.set_default_account("test")
# cls.bts.set_default_account("test")
def
test_comment
(
self
):
def
test_comment
(
self
):
...
@@ -51,11 +51,11 @@ class Testcases(unittest.TestCase):
...
@@ -51,11 +51,11 @@ class Testcases(unittest.TestCase):
with
self
.
assertRaises
(
with
self
.
assertRaises
(
exceptions
.
ContentDoesNotExistsException
exceptions
.
ContentDoesNotExistsException
):
):
Comment
(
"
@abcdef/abcdef
"
,
steem
_instance
=
bts
)
Comment
(
"
@abcdef/abcdef
"
,
blockchain
_instance
=
bts
)
title
=
''
title
=
''
cnt
=
0
cnt
=
0
while
title
==
''
and
cnt
<
5
:
while
title
==
''
and
cnt
<
5
:
c
=
Comment
(
self
.
authorperm
,
steem
_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
blockchain
_instance
=
bts
)
title
=
c
.
title
title
=
c
.
title
cnt
+=
1
cnt
+=
1
if
title
==
''
:
if
title
==
''
:
...
@@ -89,7 +89,7 @@ class Testcases(unittest.TestCase):
...
@@ -89,7 +89,7 @@ class Testcases(unittest.TestCase):
title
=
''
title
=
''
cnt
=
0
cnt
=
0
while
title
==
''
and
cnt
<
5
:
while
title
==
''
and
cnt
<
5
:
c
=
Comment
({
'
author
'
:
self
.
author
,
'
permlink
'
:
self
.
permlink
},
steem
_instance
=
bts
)
c
=
Comment
({
'
author
'
:
self
.
author
,
'
permlink
'
:
self
.
permlink
},
blockchain
_instance
=
bts
)
c
.
refresh
()
c
.
refresh
()
title
=
c
.
title
title
=
c
.
title
cnt
+=
1
cnt
+=
1
...
@@ -108,7 +108,7 @@ class Testcases(unittest.TestCase):
...
@@ -108,7 +108,7 @@ class Testcases(unittest.TestCase):
def
test_vote
(
self
):
def
test_vote
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
c
=
Comment
(
self
.
authorperm
,
steem
_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
blockchain
_instance
=
bts
)
bts
.
txbuffer
.
clear
()
bts
.
txbuffer
.
clear
()
tx
=
c
.
vote
(
100
,
account
=
"
test
"
)
tx
=
c
.
vote
(
100
,
account
=
"
test
"
)
self
.
assertEqual
(
self
.
assertEqual
(
...
@@ -145,10 +145,10 @@ class Testcases(unittest.TestCase):
...
@@ -145,10 +145,10 @@ class Testcases(unittest.TestCase):
else
:
else
:
content
=
bts
.
rpc
.
get_content
(
self
.
author
,
self
.
permlink
)
content
=
bts
.
rpc
.
get_content
(
self
.
author
,
self
.
permlink
)
c
=
Comment
(
self
.
authorperm
,
steem
_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
blockchain
_instance
=
bts
)
keys
=
list
(
content
.
keys
())
keys
=
list
(
content
.
keys
())
json_content
=
c
.
json
()
json_content
=
c
.
json
()
exclude_list
=
[
"
json_metadata
"
,
"
reputation
"
,
"
active_votes
"
]
exclude_list
=
[
"
json_metadata
"
,
"
reputation
"
,
"
active_votes
"
,
"
net_rshares
"
]
for
k
in
keys
:
for
k
in
keys
:
if
k
not
in
exclude_list
:
if
k
not
in
exclude_list
:
if
isinstance
(
content
[
k
],
dict
)
and
isinstance
(
json_content
[
k
],
list
):
if
isinstance
(
content
[
k
],
dict
)
and
isinstance
(
json_content
[
k
],
list
):
...
@@ -161,7 +161,7 @@ class Testcases(unittest.TestCase):
...
@@ -161,7 +161,7 @@ class Testcases(unittest.TestCase):
def
test_resteem
(
self
):
def
test_resteem
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
bts
.
txbuffer
.
clear
()
bts
.
txbuffer
.
clear
()
c
=
Comment
(
self
.
authorperm
,
steem
_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
blockchain
_instance
=
bts
)
tx
=
c
.
resteem
(
account
=
"
test
"
)
tx
=
c
.
resteem
(
account
=
"
test
"
)
self
.
assertEqual
(
self
.
assertEqual
(
(
tx
[
"
operations
"
][
0
][
0
]),
(
tx
[
"
operations
"
][
0
][
0
]),
...
@@ -171,7 +171,7 @@ class Testcases(unittest.TestCase):
...
@@ -171,7 +171,7 @@ class Testcases(unittest.TestCase):
def
test_reply
(
self
):
def
test_reply
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
bts
.
txbuffer
.
clear
()
bts
.
txbuffer
.
clear
()
c
=
Comment
(
self
.
authorperm
,
steem
_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
blockchain
_instance
=
bts
)
tx
=
c
.
reply
(
body
=
"
Good post!
"
,
author
=
"
test
"
)
tx
=
c
.
reply
(
body
=
"
Good post!
"
,
author
=
"
test
"
)
self
.
assertEqual
(
self
.
assertEqual
(
(
tx
[
"
operations
"
][
0
][
0
]),
(
tx
[
"
operations
"
][
0
][
0
]),
...
@@ -185,7 +185,7 @@ class Testcases(unittest.TestCase):
...
@@ -185,7 +185,7 @@ class Testcases(unittest.TestCase):
def
test_delete
(
self
):
def
test_delete
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
bts
.
txbuffer
.
clear
()
bts
.
txbuffer
.
clear
()
c
=
Comment
(
self
.
authorperm
,
steem
_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
blockchain
_instance
=
bts
)
tx
=
c
.
delete
(
account
=
"
test
"
)
tx
=
c
.
delete
(
account
=
"
test
"
)
self
.
assertEqual
(
self
.
assertEqual
(
(
tx
[
"
operations
"
][
0
][
0
]),
(
tx
[
"
operations
"
][
0
][
0
]),
...
@@ -199,7 +199,7 @@ class Testcases(unittest.TestCase):
...
@@ -199,7 +199,7 @@ class Testcases(unittest.TestCase):
def
test_edit
(
self
):
def
test_edit
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
bts
.
txbuffer
.
clear
()
bts
.
txbuffer
.
clear
()
c
=
Comment
(
self
.
authorperm
,
steem
_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
blockchain
_instance
=
bts
)
c
.
edit
(
c
.
body
,
replace
=
False
)
c
.
edit
(
c
.
body
,
replace
=
False
)
body
=
c
.
body
+
"
test
"
body
=
c
.
body
+
"
test
"
tx
=
c
.
edit
(
body
,
replace
=
False
)
tx
=
c
.
edit
(
body
,
replace
=
False
)
...
@@ -215,7 +215,7 @@ class Testcases(unittest.TestCase):
...
@@ -215,7 +215,7 @@ class Testcases(unittest.TestCase):
def
test_edit_replace
(
self
):
def
test_edit_replace
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
bts
.
txbuffer
.
clear
()
bts
.
txbuffer
.
clear
()
c
=
Comment
(
self
.
authorperm
,
steem
_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
blockchain
_instance
=
bts
)
body
=
c
.
body
+
"
test
"
body
=
c
.
body
+
"
test
"
tx
=
c
.
edit
(
body
,
meta
=
c
[
"
json_metadata
"
],
replace
=
True
)
tx
=
c
.
edit
(
body
,
meta
=
c
[
"
json_metadata
"
],
replace
=
True
)
self
.
assertEqual
(
self
.
assertEqual
(
...
@@ -230,16 +230,16 @@ class Testcases(unittest.TestCase):
...
@@ -230,16 +230,16 @@ class Testcases(unittest.TestCase):
def
test_recent_replies
(
self
):
def
test_recent_replies
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
r
=
RecentReplies
(
"
fullnodeupdate
"
,
skip_own
=
True
,
steem
_instance
=
bts
)
r
=
RecentReplies
(
"
fullnodeupdate
"
,
skip_own
=
True
,
blockchain
_instance
=
bts
)
self
.
assertTrue
(
len
(
r
)
>=
0
)
self
.
assertTrue
(
len
(
r
)
>=
0
)
def
test_recent_by_path
(
self
):
def
test_recent_by_path
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
r
=
RecentByPath
(
path
=
"
trending
"
,
steem
_instance
=
bts
)
r
=
RecentByPath
(
path
=
"
trending
"
,
blockchain
_instance
=
bts
)
self
.
assertTrue
(
len
(
r
)
>=
0
)
self
.
assertTrue
(
len
(
r
)
>=
0
)
def
test_ranked_posts
(
self
):
def
test_ranked_posts
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
r
=
RankedPosts
(
sort
=
"
trending
"
,
steem
_instance
=
bts
)
r
=
RankedPosts
(
sort
=
"
trending
"
,
blockchain
_instance
=
bts
)
self
.
assertTrue
(
len
(
r
)
>
0
)
self
.
assertTrue
(
len
(
r
)
>
0
)
self
.
assertTrue
(
r
[
0
]
is
not
None
)
self
.
assertTrue
(
r
[
0
]
is
not
None
)
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