Skip to content
GitLab
Explore
Sign in
Register
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
ffb208de
Commit
ffb208de
authored
6 years ago
by
Holger Nahrstaedt
Browse files
Options
Downloads
Patches
Plain Diff
Improve unit tests
parent
ccda07cc
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/beem/test_cli.py
+14
-14
14 additions, 14 deletions
tests/beem/test_cli.py
tests/beem/test_comment.py
+28
-23
28 additions, 23 deletions
tests/beem/test_comment.py
tests/beem/test_market.py
+1
-1
1 addition, 1 deletion
tests/beem/test_market.py
with
43 additions
and
38 deletions
tests/beem/test_cli.py
+
14
−
14
View file @
ffb208de
...
@@ -31,26 +31,26 @@ class Testcases(unittest.TestCase):
...
@@ -31,26 +31,26 @@ class Testcases(unittest.TestCase):
stm
.
config
.
refreshBackup
()
stm
.
config
.
refreshBackup
()
runner
=
CliRunner
()
runner
=
CliRunner
()
result
=
runner
.
invoke
(
cli
,
[
'
-o
'
,
'
set
'
,
'
default_vote_weight
'
,
'
100
'
])
result
=
runner
.
invoke
(
cli
,
[
'
-o
'
,
'
set
'
,
'
default_vote_weight
'
,
'
100
'
])
if
result
!=
0
:
if
result
.
exit_code
!=
0
:
raise
AssertionError
(
"
setup failed!
"
)
raise
AssertionError
(
str
(
result
)
)
result
=
runner
.
invoke
(
cli
,
[
'
-o
'
,
'
set
'
,
'
default_account
'
,
'
beem
'
])
result
=
runner
.
invoke
(
cli
,
[
'
-o
'
,
'
set
'
,
'
default_account
'
,
'
beem
'
])
if
result
!=
0
:
if
result
.
exit_code
!=
0
:
raise
AssertionError
(
"
setup failed!
"
)
raise
AssertionError
(
str
(
result
))
result
=
runner
.
invoke
(
cli
,
[
'
-o
'
,
'
set
'
,
'
nodes
'
,
'
wss://testnet.steem.vc
'
])
result
=
runner
.
invoke
(
cli
,
[
'
-o
'
,
'
set
'
,
'
nodes
'
,
'
wss://testnet.steem.vc
'
])
if
result
!=
0
:
if
result
.
exit_code
!=
0
:
raise
AssertionError
(
"
setup failed!
"
)
raise
AssertionError
(
str
(
result
))
result
=
runner
.
invoke
(
cli
,
[
'
createwallet
'
],
input
=
"
y
\n
test
\n
test
\n
"
)
result
=
runner
.
invoke
(
cli
,
[
'
createwallet
'
],
input
=
"
y
\n
test
\n
test
\n
"
)
if
result
!=
0
:
if
result
.
exit_code
!=
0
:
raise
AssertionError
(
"
setup failed!
"
)
raise
AssertionError
(
str
(
result
))
result
=
runner
.
invoke
(
cli
,
[
'
addkey
'
],
input
=
"
test
\n
"
+
wif
+
"
\n
"
)
result
=
runner
.
invoke
(
cli
,
[
'
addkey
'
],
input
=
"
test
\n
"
+
wif
+
"
\n
"
)
if
result
!=
0
:
if
result
.
exit_code
!=
0
:
raise
AssertionError
(
"
setup failed!
"
)
raise
AssertionError
(
str
(
result
))
result
=
runner
.
invoke
(
cli
,
[
'
addkey
'
],
input
=
"
test
\n
"
+
posting_key
+
"
\n
"
)
result
=
runner
.
invoke
(
cli
,
[
'
addkey
'
],
input
=
"
test
\n
"
+
posting_key
+
"
\n
"
)
if
result
!=
0
:
if
result
.
exit_code
!=
0
:
raise
AssertionError
(
"
setup failed!
"
)
raise
AssertionError
(
str
(
result
))
result
=
runner
.
invoke
(
cli
,
[
'
addkey
'
],
input
=
"
test
\n
"
+
memo_key
+
"
\n
"
)
result
=
runner
.
invoke
(
cli
,
[
'
addkey
'
],
input
=
"
test
\n
"
+
memo_key
+
"
\n
"
)
if
result
!=
0
:
if
result
.
exit_code
!=
0
:
raise
AssertionError
(
"
setup failed!
"
)
raise
AssertionError
(
str
(
result
))
@classmethod
@classmethod
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
...
...
This diff is collapsed.
Click to expand it.
tests/beem/test_comment.py
+
28
−
23
View file @
ffb208de
...
@@ -10,7 +10,7 @@ from beem import Steem, exceptions
...
@@ -10,7 +10,7 @@ from beem import Steem, exceptions
from
beem.comment
import
Comment
,
RecentReplies
,
RecentByPath
from
beem.comment
import
Comment
,
RecentReplies
,
RecentByPath
from
beem.vote
import
Vote
from
beem.vote
import
Vote
from
beem.instance
import
set_shared_steem_instance
from
beem.instance
import
set_shared_steem_instance
from
beem.utils
import
get_node_list
from
beem.utils
import
get_node_list
,
resolve_authorperm
wif
=
"
5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
"
wif
=
"
5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
"
...
@@ -30,7 +30,12 @@ class Testcases(unittest.TestCase):
...
@@ -30,7 +30,12 @@ class Testcases(unittest.TestCase):
keys
=
{
"
active
"
:
wif
},
keys
=
{
"
active
"
:
wif
},
num_retries
=
10
num_retries
=
10
)
)
cls
.
authorperm
=
"
@gtg/witness-gtg-log
"
cls
.
authorperm
=
"
@gtg/ffdhu-gtg-witness-log
"
[
author
,
permlink
]
=
resolve_authorperm
(
cls
.
authorperm
)
cls
.
author
=
author
cls
.
permlink
=
permlink
cls
.
category
=
'
witness-category
'
cls
.
title
=
'
gtg witness log
'
# 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_steem_instance
(
cls
.
bts
)
...
@@ -38,7 +43,7 @@ class Testcases(unittest.TestCase):
...
@@ -38,7 +43,7 @@ class Testcases(unittest.TestCase):
cnt
=
0
cnt
=
0
title
=
''
title
=
''
while
cnt
<
5
and
title
==
''
:
while
cnt
<
5
and
title
==
''
:
c
=
Comment
(
"
@gtg/witness-gtg-log
"
,
steem_instance
=
cls
.
bts
)
c
=
Comment
(
cls
.
authorperm
,
steem_instance
=
cls
.
bts
)
title
=
c
[
"
title
"
]
title
=
c
[
"
title
"
]
cls
.
bts
.
rpc
.
next
()
cls
.
bts
.
rpc
.
next
()
...
@@ -55,16 +60,16 @@ class Testcases(unittest.TestCase):
...
@@ -55,16 +60,16 @@ class Testcases(unittest.TestCase):
exceptions
.
ContentDoesNotExistsException
exceptions
.
ContentDoesNotExistsException
):
):
Comment
(
"
@abcdef/abcdef
"
,
steem_instance
=
bts
)
Comment
(
"
@abcdef/abcdef
"
,
steem_instance
=
bts
)
c
=
Comment
(
"
@gtg/witness-gtg-log
"
,
steem_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
steem_instance
=
bts
)
self
.
assertTrue
(
isinstance
(
c
.
id
,
int
))
self
.
assertTrue
(
isinstance
(
c
.
id
,
int
))
self
.
assertTrue
(
c
.
id
>
0
)
self
.
assertTrue
(
c
.
id
>
0
)
self
.
assertEqual
(
c
.
author
,
"
gtg
"
)
self
.
assertEqual
(
c
.
author
,
self
.
author
)
self
.
assertEqual
(
c
.
permlink
,
"
witness-gtg-log
"
)
self
.
assertEqual
(
c
.
permlink
,
self
.
permlink
)
self
.
assertEqual
(
c
.
authorperm
,
"
@gtg/witness-gtg-log
"
)
self
.
assertEqual
(
c
.
authorperm
,
self
.
authorperm
)
self
.
assertEqual
(
c
.
category
,
'
witness-
category
'
)
self
.
assertEqual
(
c
.
category
,
self
.
category
)
self
.
assertEqual
(
c
.
parent_author
,
''
)
self
.
assertEqual
(
c
.
parent_author
,
''
)
self
.
assertEqual
(
c
.
parent_permlink
,
'
witness-
category
'
)
self
.
assertEqual
(
c
.
parent_permlink
,
self
.
category
)
self
.
assertEqual
(
c
.
title
,
'
witness gtg log
'
)
self
.
assertEqual
(
c
.
title
,
self
.
title
)
self
.
assertTrue
(
len
(
c
.
body
)
>
0
)
self
.
assertTrue
(
len
(
c
.
body
)
>
0
)
for
key
in
[
'
tags
'
,
'
users
'
,
'
image
'
,
'
links
'
,
'
app
'
,
'
format
'
]:
for
key
in
[
'
tags
'
,
'
users
'
,
'
image
'
,
'
links
'
,
'
app
'
,
'
format
'
]:
self
.
assertIn
(
key
,
list
(
c
.
json_metadata
.
keys
()))
self
.
assertIn
(
key
,
list
(
c
.
json_metadata
.
keys
()))
...
@@ -86,7 +91,7 @@ class Testcases(unittest.TestCase):
...
@@ -86,7 +91,7 @@ class Testcases(unittest.TestCase):
bts
=
self
.
bts
bts
=
self
.
bts
else
:
else
:
bts
=
self
.
appbase
bts
=
self
.
appbase
c
=
Comment
(
"
@gtg/witness-gtg-log
"
,
steem_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
steem_instance
=
bts
)
tx
=
c
.
vote
(
100
,
account
=
"
test
"
)
tx
=
c
.
vote
(
100
,
account
=
"
test
"
)
self
.
assertEqual
(
self
.
assertEqual
(
(
tx
[
"
operations
"
][
0
][
0
]),
(
tx
[
"
operations
"
][
0
][
0
]),
...
@@ -111,12 +116,12 @@ class Testcases(unittest.TestCase):
...
@@ -111,12 +116,12 @@ class Testcases(unittest.TestCase):
def
test_export
(
self
,
node_param
):
def
test_export
(
self
,
node_param
):
if
node_param
==
"
non_appbase
"
:
if
node_param
==
"
non_appbase
"
:
bts
=
self
.
bts
bts
=
self
.
bts
content
=
bts
.
rpc
.
get_content
(
"
gtg
"
,
"
witness-gtg-log
"
)
content
=
bts
.
rpc
.
get_content
(
self
.
author
,
self
.
permlink
)
else
:
else
:
bts
=
self
.
appbase
bts
=
self
.
appbase
content
=
bts
.
rpc
.
get_discussion
({
'
author
'
:
'
gtg
'
,
'
permlink
'
:
'
witness-gtg-log
'
},
api
=
"
tags
"
)
content
=
bts
.
rpc
.
get_discussion
({
'
author
'
:
self
.
author
,
'
permlink
'
:
self
.
permlink
},
api
=
"
tags
"
)
c
=
Comment
(
"
@gtg/witness-gtg-log
"
,
steem_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
steem_instance
=
bts
)
keys
=
list
(
content
.
keys
())
keys
=
list
(
content
.
keys
())
json_content
=
c
.
json
()
json_content
=
c
.
json
()
...
@@ -126,7 +131,7 @@ class Testcases(unittest.TestCase):
...
@@ -126,7 +131,7 @@ class Testcases(unittest.TestCase):
def
test_resteem
(
self
):
def
test_resteem
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
c
=
Comment
(
"
@gtg/witness-gtg-log
"
,
steem_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
steem_instance
=
bts
)
tx
=
c
.
resteem
(
account
=
"
test
"
)
tx
=
c
.
resteem
(
account
=
"
test
"
)
self
.
assertEqual
(
self
.
assertEqual
(
(
tx
[
"
operations
"
][
0
][
0
]),
(
tx
[
"
operations
"
][
0
][
0
]),
...
@@ -135,7 +140,7 @@ class Testcases(unittest.TestCase):
...
@@ -135,7 +140,7 @@ class Testcases(unittest.TestCase):
def
test_reply
(
self
):
def
test_reply
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
c
=
Comment
(
"
@gtg/witness-gtg-log
"
,
steem_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
steem_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
]),
...
@@ -148,7 +153,7 @@ class Testcases(unittest.TestCase):
...
@@ -148,7 +153,7 @@ class Testcases(unittest.TestCase):
def
test_delete
(
self
):
def
test_delete
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
c
=
Comment
(
"
@gtg/witness-gtg-log
"
,
steem_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
steem_instance
=
bts
)
tx
=
c
.
delete
(
account
=
"
test
"
)
tx
=
c
.
delete
(
account
=
"
test
"
)
self
.
assertEqual
(
self
.
assertEqual
(
(
tx
[
"
operations
"
][
0
][
0
]),
(
tx
[
"
operations
"
][
0
][
0
]),
...
@@ -156,12 +161,12 @@ class Testcases(unittest.TestCase):
...
@@ -156,12 +161,12 @@ class Testcases(unittest.TestCase):
)
)
op
=
tx
[
"
operations
"
][
0
][
1
]
op
=
tx
[
"
operations
"
][
0
][
1
]
self
.
assertIn
(
self
.
assertIn
(
"
gtg
"
,
self
.
author
,
op
[
"
author
"
])
op
[
"
author
"
])
def
test_edit
(
self
):
def
test_edit
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
c
=
Comment
(
"
@gtg/witness-gtg-log
"
,
steem_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
steem_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
)
...
@@ -171,12 +176,12 @@ class Testcases(unittest.TestCase):
...
@@ -171,12 +176,12 @@ class Testcases(unittest.TestCase):
)
)
op
=
tx
[
"
operations
"
][
0
][
1
]
op
=
tx
[
"
operations
"
][
0
][
1
]
self
.
assertIn
(
self
.
assertIn
(
"
gtg
"
,
self
.
author
,
op
[
"
author
"
])
op
[
"
author
"
])
def
test_edit_replace
(
self
):
def
test_edit_replace
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
c
=
Comment
(
"
@gtg/witness-gtg-log
"
,
steem_instance
=
bts
)
c
=
Comment
(
self
.
authorperm
,
steem_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
(
...
@@ -185,13 +190,13 @@ class Testcases(unittest.TestCase):
...
@@ -185,13 +190,13 @@ class Testcases(unittest.TestCase):
)
)
op
=
tx
[
"
operations
"
][
0
][
1
]
op
=
tx
[
"
operations
"
][
0
][
1
]
self
.
assertIn
(
self
.
assertIn
(
"
gtg
"
,
self
.
author
,
op
[
"
author
"
])
op
[
"
author
"
])
self
.
assertEqual
(
body
,
op
[
"
body
"
])
self
.
assertEqual
(
body
,
op
[
"
body
"
])
def
test_recent_replies
(
self
):
def
test_recent_replies
(
self
):
bts
=
self
.
bts
bts
=
self
.
bts
r
=
RecentReplies
(
"
gtg
"
,
skip_own
=
True
,
steem_instance
=
bts
)
r
=
RecentReplies
(
self
.
author
,
skip_own
=
True
,
steem_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.
tests/beem/test_market.py
+
1
−
1
View file @
ffb208de
...
@@ -134,7 +134,7 @@ class Testcases(unittest.TestCase):
...
@@ -134,7 +134,7 @@ class Testcases(unittest.TestCase):
trades_raw
=
m
.
trades
(
limit
=
10
,
raw_data
=
True
)
trades_raw
=
m
.
trades
(
limit
=
10
,
raw_data
=
True
)
trades_history
=
m
.
trade_history
(
limit
=
10
)
trades_history
=
m
.
trade_history
(
limit
=
10
)
self
.
assertEqual
(
len
(
trades
),
10
)
self
.
assertEqual
(
len
(
trades
),
10
)
self
.
assert
Equal
(
len
(
trades_history
)
,
1
0
)
self
.
assert
True
(
len
(
trades_history
)
>
0
)
self
.
assertEqual
(
len
(
trades_raw
),
10
)
self
.
assertEqual
(
len
(
trades_raw
),
10
)
@parameterized.expand
([
@parameterized.expand
([
...
...
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