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
05aaa03b
Commit
05aaa03b
authored
4 years ago
by
Holger
Browse files
Options
Downloads
Patches
Plain Diff
Fix parameter in unit test
parent
f24a20b6
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
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/beem/test_vote.py
+16
-15
16 additions, 15 deletions
tests/beem/test_vote.py
with
16 additions
and
15 deletions
tests/beem/test_vote.py
+
16
−
15
View file @
05aaa03b
...
...
@@ -4,11 +4,11 @@ from parameterized import parameterized
import
pytz
from
datetime
import
datetime
,
timedelta
from
pprint
import
pprint
from
beem
import
Steem
,
exceptions
from
beem
import
Steem
,
exceptions
,
Hive
from
beem.comment
import
Comment
from
beem.account
import
Account
from
beem.vote
import
Vote
,
ActiveVotes
,
AccountVotes
from
beem.instance
import
set_shared_
steem
_instance
from
beem.instance
import
set_shared_
blockchain
_instance
from
beem.utils
import
construct_authorperm
,
resolve_authorperm
,
resolve_authorpermvoter
,
construct_authorpermvoter
from
.nodes
import
get_hive_nodes
,
get_steem_nodes
...
...
@@ -18,7 +18,7 @@ wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
class
Testcases
(
unittest
.
TestCase
):
@classmethod
def
setUpClass
(
cls
):
cls
.
bts
=
Steem
(
cls
.
bts
=
Hive
(
node
=
get_hive_nodes
(),
nobroadcast
=
True
,
keys
=
{
"
active
"
:
wif
},
...
...
@@ -26,15 +26,15 @@ class Testcases(unittest.TestCase):
)
# from getpass import getpass
# self.bts.wallet.unlock(getpass())
set_shared_
steem
_instance
(
cls
.
bts
)
set_shared_
blockchain
_instance
(
cls
.
bts
)
cls
.
bts
.
set_default_account
(
"
test
"
)
acc
=
Account
(
"
fullnodeupdate
"
,
steem
_instance
=
cls
.
bts
)
acc
=
Account
(
"
fullnodeupdate
"
,
blockchain
_instance
=
cls
.
bts
)
n_votes
=
0
index
=
0
entries
=
acc
.
get_blog
(
limit
=
20
)[::
-
1
]
while
n_votes
==
0
:
comment
=
Comment
(
entries
[
index
],
steem
_instance
=
cls
.
bts
)
comment
=
Comment
(
entries
[
index
],
blockchain
_instance
=
cls
.
bts
)
votes
=
comment
.
get_votes
()
n_votes
=
len
(
votes
)
index
+=
1
...
...
@@ -50,12 +50,13 @@ class Testcases(unittest.TestCase):
def
test_vote
(
self
):
bts
=
self
.
bts
vote
=
Vote
(
self
.
authorpermvoter
,
steem_instance
=
bts
)
self
.
assertTrue
(
len
(
bts
.
get_reward_funds
(
use_stored_data
=
False
))
>
0
)
vote
=
Vote
(
self
.
authorpermvoter
,
blockchain_instance
=
bts
)
self
.
assertEqual
(
self
.
voter
,
vote
[
"
voter
"
])
self
.
assertEqual
(
self
.
author
,
vote
[
"
author
"
])
self
.
assertEqual
(
self
.
permlink
,
vote
[
"
permlink
"
])
vote
=
Vote
(
self
.
voter
,
authorperm
=
self
.
authorperm
,
steem
_instance
=
bts
)
vote
=
Vote
(
self
.
voter
,
authorperm
=
self
.
authorperm
,
blockchain
_instance
=
bts
)
self
.
assertEqual
(
self
.
voter
,
vote
[
"
voter
"
])
self
.
assertEqual
(
self
.
author
,
vote
[
"
author
"
])
self
.
assertEqual
(
self
.
permlink
,
vote
[
"
permlink
"
])
...
...
@@ -63,7 +64,7 @@ class Testcases(unittest.TestCase):
self
.
assertEqual
(
self
.
voter
,
vote_json
[
"
voter
"
])
self
.
assertEqual
(
self
.
voter
,
vote
.
voter
)
self
.
assertTrue
(
vote
.
weight
>=
0
)
self
.
assertTrue
(
vote
.
s
bd
>=
0
)
self
.
assertTrue
(
vote
.
h
bd
>=
0
)
self
.
assertTrue
(
vote
.
rshares
>=
0
)
self
.
assertTrue
(
vote
.
percent
>=
0
)
self
.
assertTrue
(
vote
.
reputation
is
not
None
)
...
...
@@ -77,7 +78,7 @@ class Testcases(unittest.TestCase):
self
.
assertEqual
(
self
.
voter
,
vote_json
[
"
voter
"
])
self
.
assertEqual
(
self
.
voter
,
vote
.
voter
)
self
.
assertTrue
(
vote
.
weight
>=
0
)
self
.
assertTrue
(
vote
.
s
bd
>=
0
)
self
.
assertTrue
(
vote
.
h
bd
>=
0
)
self
.
assertTrue
(
vote
.
rshares
>=
0
)
self
.
assertTrue
(
vote
.
percent
>=
0
)
self
.
assertTrue
(
vote
.
reputation
is
not
None
)
...
...
@@ -89,21 +90,21 @@ class Testcases(unittest.TestCase):
with
self
.
assertRaises
(
exceptions
.
VoteDoesNotExistsException
):
Vote
(
construct_authorpermvoter
(
self
.
author
,
self
.
permlink
,
"
asdfsldfjlasd
"
),
steem
_instance
=
bts
)
Vote
(
construct_authorpermvoter
(
self
.
author
,
self
.
permlink
,
"
asdfsldfjlasd
"
),
blockchain
_instance
=
bts
)
with
self
.
assertRaises
(
exceptions
.
VoteDoesNotExistsException
):
Vote
(
construct_authorpermvoter
(
self
.
author
,
"
sdlfjd
"
,
"
asdfsldfjlasd
"
),
steem
_instance
=
bts
)
Vote
(
construct_authorpermvoter
(
self
.
author
,
"
sdlfjd
"
,
"
asdfsldfjlasd
"
),
blockchain
_instance
=
bts
)
with
self
.
assertRaises
(
exceptions
.
VoteDoesNotExistsException
):
Vote
(
construct_authorpermvoter
(
"
sdalfj
"
,
"
dsfa
"
,
"
asdfsldfjlasd
"
),
steem
_instance
=
bts
)
Vote
(
construct_authorpermvoter
(
"
sdalfj
"
,
"
dsfa
"
,
"
asdfsldfjlasd
"
),
blockchain
_instance
=
bts
)
def
test_activevotes
(
self
):
bts
=
self
.
bts
votes
=
ActiveVotes
(
self
.
authorperm
,
steem
_instance
=
bts
)
votes
=
ActiveVotes
(
self
.
authorperm
,
blockchain
_instance
=
bts
)
votes
.
printAsTable
()
vote_list
=
votes
.
get_list
()
self
.
assertTrue
(
isinstance
(
vote_list
,
list
))
...
...
@@ -113,6 +114,6 @@ class Testcases(unittest.TestCase):
bts
=
self
.
bts
utc
=
pytz
.
timezone
(
'
UTC
'
)
limit_time
=
utc
.
localize
(
datetime
.
utcnow
())
-
timedelta
(
days
=
7
)
votes
=
AccountVotes
(
self
.
voter
,
start
=
limit_time
,
steem
_instance
=
bts
)
votes
=
AccountVotes
(
self
.
voter
,
start
=
limit_time
,
blockchain
_instance
=
bts
)
self
.
assertTrue
(
len
(
votes
)
>
0
)
self
.
assertTrue
(
isinstance
(
votes
[
0
],
Vote
))
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