From 154de1ccfc03acb139456e07e71918b9d6732136 Mon Sep 17 00:00:00 2001 From: Holger Nahrstaedt <holger@nahrstaedt.de> Date: Sat, 3 Mar 2018 15:22:03 +0100 Subject: [PATCH] Code impromements part 3 --- .travis.yml | 8 +------- beem/block.py | 4 ---- beem/steem.py | 6 ++++-- requirements-test.txt | 16 ---------------- tests/test_block.py | 2 -- tests/test_discussions.py | 39 +++++++++++++++++++++++++++++++++++++++ tox.ini | 1 + 7 files changed, 45 insertions(+), 31 deletions(-) delete mode 100644 requirements-test.txt create mode 100644 tests/test_discussions.py diff --git a/.travis.yml b/.travis.yml index 88629ca6..2bad890a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,13 +8,7 @@ matrix: - os: linux python: 3.6 env: - - PYFLAKES=1 - - PEP8=1 - before_install: - - pip install pep8==1.6.2 - - pip install flake8 - script: - - flake8 + - TOXENV=pylint - os: linux python: 2.7 env: diff --git a/beem/block.py b/beem/block.py index 14c0db42..02c65199 100644 --- a/beem/block.py +++ b/beem/block.py @@ -45,10 +45,6 @@ class Block(BlockchainObject): """ return parse_time(self['timestamp']) - def change_block_number(self, number): - self.identifier = number - self.refresh() - def ops(self): ops = [] for tx in self["transactions"]: diff --git a/beem/steem.py b/beem/steem.py index 18a90dd8..1c3ad1d4 100644 --- a/beem/steem.py +++ b/beem/steem.py @@ -454,7 +454,8 @@ class Steem(object): # Append to the append_to and return append_to = kwargs["append_to"] parent = append_to.get_parent() - assert isinstance(append_to, (TransactionBuilder)) + if not isinstance(append_to, (TransactionBuilder)): + raise AssertionError() append_to.appendOps(ops) # Add the signer to the buffer so we sign the tx properly parent.appendSigner(account, permission) @@ -677,7 +678,8 @@ class Steem(object): delegation_fee_steem = Amount(delegation_fee_steem, steem_instance=self) else: delegation_fee_steem = Amount(delegation_fee_steem, "STEEM", steem_instance=self) - assert delegation_fee_steem["symbol"] == "STEEM" + if not delegation_fee_steem["symbol"] == "STEEM": + raise AssertionError() " Generate new keys from password" from beembase.account import PasswordKey diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index 5f2e41be..00000000 --- a/requirements-test.txt +++ /dev/null @@ -1,16 +0,0 @@ -future -pycryptodomex>=3.4.6 -ecdsa -requests -websocket-client -pytz -scrypt>=0.8.0 -Events>=0.2.2 -pyyaml -pytest -pytest-mock -coverage -mock -appdirs -Click -prettytable diff --git a/tests/test_block.py b/tests/test_block.py index 038c7b59..19aa9f3e 100644 --- a/tests/test_block.py +++ b/tests/test_block.py @@ -39,8 +39,6 @@ class Testcases(unittest.TestCase): block2 = Block(2, steem_instance=bts) self.assertTrue(block2.time() > block.time()) - block2.change_block_number(3) - self.assertEqual(block2.identifier, 3) def test_block_ops(self): bts = self.bts diff --git a/tests/test_discussions.py b/tests/test_discussions.py new file mode 100644 index 00000000..8fc06510 --- /dev/null +++ b/tests/test_discussions.py @@ -0,0 +1,39 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +from builtins import super +import unittest +from pprint import pprint +from beem import Steem +from beem.discussions import Query, Discussions_by_trending +from datetime import datetime +from beem.instance import set_shared_steem_instance + +wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" +nodes = ["wss://steemd.pevo.science", "wss://gtg.steem.house:8090", "wss://rpc.steemliberator.com", "wss://rpc.buildteam.io", + "wss://rpc.steemviz.com", "wss://seed.bitcoiner.me", "wss://node.steem.ws", "wss://steemd.steemgigs.org", "wss://steemd.steemit.com", + "wss://steemd.minnowsupportproject.org"] + + +class Testcases(unittest.TestCase): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + self.bts = Steem( + node=nodes, + nobroadcast=True, + keys={"active": wif}, + ) + # from getpass import getpass + # self.bts.wallet.unlock(getpass()) + set_shared_steem_instance(self.bts) + self.bts.set_default_account("test") + + def test_trending(self): + bts = self.bts + query = Query() + query["limit"] = 10 + d = Discussions_by_trending(query, steem_instance=bts) + self.assertEqual(len(d), 10) diff --git a/tox.ini b/tox.ini index 5d7a2d64..7ce302ad 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,7 @@ skip_missing_interpreters = true deps = mock>=2.0.0 pytest + pytest-mock coverage commands = coverage run --parallel-mode -m pytest {posargs} -- GitLab