Skip to content

Commit

Permalink
Merge branch 'release/0.1.25'
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed May 25, 2018
2 parents 57aed88 + 1daade4 commit a02e687
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 23 deletions.
7 changes: 7 additions & 0 deletions docs/peerplays.cli.rpc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
peerplays\.cli\.rpc module
==========================

.. automodule:: peerplays.cli.rpc
:members:
:undoc-members:
:show-inheritance:
13 changes: 2 additions & 11 deletions peerplays/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ class Account(BlockchainObject):

type_id = 2

def __init__(
self,
*args,
**kwargs
):
def __init__(self, *args, **kwargs):
self.full = kwargs.pop("full", False)
super().__init__(*args, **kwargs)

Expand Down Expand Up @@ -186,12 +182,7 @@ class AccountUpdate(dict, BlockchainInstance):
"""

def __init__(
self,
data,
*args,
**kwargs
):
def __init__(self, data, *args, **kwargs):
BlockchainInstance.__init__(self, *args, **kwargs)
if isinstance(data, dict):
super(AccountUpdate, self).__init__(data)
Expand Down
30 changes: 30 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
[metadata]
description-file = README.md

[aliases]
test=pytest

[coverage:run]
#source=bitshares*
omit=
tests/*
.tox/*
.eggs/*

[coverage:report]
include=peerplays*
ignore_errors=True
show_missing=True

[flake8]
ignore = E501,F401
exclude =
# No need to traverse our git directory
.git,
# There's no value in checking cache directories
__pycache__,
# The conf file is mostly autogenerated, ignore it
docs/conf.py,
# The old directory contains Flake8 2.0
old,
# This contains our built documentation
build,
# This contains builds of flake8 that we don't want to check
dist
max-complexity = 10
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
ascii = codecs.lookup('ascii')
codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs'))

VERSION = '0.1.24'
VERSION = '0.1.25'

setup(
name='peerplays',
Expand Down
68 changes: 61 additions & 7 deletions tests/test_peerplays.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,64 @@
import string
import unittest
import random

from pprint import pprint

from peerplays import PeerPlays
from peerplaysbase.operationids import getOperationNameForId
from peerplays.amount import Amount
from peerplaysbase.account import PrivateKey
from peerplays.instance import set_shared_peerplays_instance
from peerplays.blockchainobject import BlockchainObject, ObjectCache

from peerplaysbase.account import PrivateKey
from peerplaysbase.operationids import getOperationNameForId

wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
core_unit = "PPY"

account_id = '1.2.7'
_objects = [{
'active': {'account_auths': [],
'address_auths': [],
'key_auths': [[str(PrivateKey(wif).pubkey),
1]],
'weight_threshold': 1},
'active_special_authority': [0, {}],
'blacklisted_accounts': [],
'blacklisting_accounts': [],
'cashback_vb': '1.13.0',
'id': '1.2.7',
'lifetime_referrer': '1.2.7',
'lifetime_referrer_fee_percentage': 8000,
'membership_expiration_date': '1969-12-31T23:59:59',
'name': 'init0',
'network_fee_percentage': 2000,
'options': {'extensions': [],
'memo_key': str(PrivateKey(wif).pubkey),
'num_committee': 0,
'num_witness': 0,
'votes': [],
'voting_account': '1.2.5'},
'owner': {'account_auths': [],
'address_auths': [],
'key_auths': [[str(PrivateKey(wif).pubkey),
1]],
'weight_threshold': 1},
'owner_special_authority': [0, {}],
'referrer': '1.2.7',
'referrer_rewards_percentage': 0,
'registrar': '1.2.7',
'statistics': '2.6.7',
'top_n_control_flags': 0,
'whitelisted_accounts': [],
'whitelisting_accounts': []
}, {
'committee_member_account': '1.2.7',
'id': '1.5.0',
'total_votes': 0,
'url': '',
'vote_id': '0:11'}
]


class Testcases(unittest.TestCase):

Expand All @@ -20,12 +68,18 @@ def __init__(self, *args, **kwargs):

self.ppy = PeerPlays(
nobroadcast=True,
wif=[wif]
wif={"active": wif}
)
# from getpass import getpass
# self.ppy.wallet.unlock(getpass())
set_shared_peerplays_instance(self.ppy)
self.ppy.set_default_account("init0")
self.mock()

def mock(self):
# Inject test data into cache
_cache = ObjectCache(default_expiration=60 * 60 * 1, no_overwrite=True)
for i in _objects:
_cache[i["id"]] = i
BlockchainObject._cache = _cache

def test_connect(self):
self.ppy.connect()
Expand Down Expand Up @@ -208,7 +262,7 @@ def test_update_memo_key(self):

def test_approvewitness(self):
ppy = self.ppy
tx = ppy.approvewitness("init0")
tx = ppy.approvewitness("1.6.1")
self.assertEqual(
getOperationNameForId(tx["operations"][0][0]),
"account_update"
Expand All @@ -220,7 +274,7 @@ def test_approvewitness(self):

def test_approvecommittee(self):
ppy = self.ppy
tx = ppy.approvecommittee("init0")
tx = ppy.approvecommittee("1.5.0")
self.assertEqual(
getOperationNameForId(tx["operations"][0][0]),
"account_update"
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ skip_missing_interpreters = true
[testenv]
deps=-rrequirements-test.txt
commands=
coverage run -a --omit="*/cli/*" setup.py test
coverage report --show-missing
coverage html -i
coverage run -a setup.py test
coverage report
coverage html

[testenv:lint]
deps=
flake8
commands=
flake8 --ignore=E501,F401 peerplays*/
flake8 peerplays*

[testenv:docs]
basepython=
Expand Down

0 comments on commit a02e687

Please sign in to comment.