From 5af48705d09d29a24aa11c0747a04beb92f0fec1 Mon Sep 17 00:00:00 2001
From: holgern <holgernahrstaedt@gmx.de>
Date: Wed, 10 Jul 2019 17:49:32 +0200
Subject: [PATCH] Fix unit tests

---
 beem/comment.py             | 4 ++++
 tests/beem/test_comment.py  | 5 +++--
 tests/beem/test_nodelist.py | 2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/beem/comment.py b/beem/comment.py
index 570dc893..51f88c62 100644
--- a/beem/comment.py
+++ b/beem/comment.py
@@ -599,6 +599,8 @@ class Comment(BlockchainObject):
             :param str voter: (optional) Voting account
 
         """
+        if weight < 0:
+            raise ValueError("Weight must be >= 0.")
         last_payout = self.get('last_payout', None)
         if last_payout is not None:
             if formatToTimeStamp(last_payout) > 0:
@@ -613,6 +615,8 @@ class Comment(BlockchainObject):
             :param str voter: (optional) Voting account
 
         """
+        if weight < 0:
+            raise ValueError("Weight must be >= 0.")        
         last_payout = self.get('last_payout', None)
         if last_payout is not None:
             if formatToTimeStamp(last_payout) > 0:
diff --git a/tests/beem/test_comment.py b/tests/beem/test_comment.py
index 4fad9f72..35043b80 100644
--- a/tests/beem/test_comment.py
+++ b/tests/beem/test_comment.py
@@ -134,12 +134,13 @@ class Testcases(unittest.TestCase):
         tx = c.upvote(weight=99.9, voter="test")
         op = tx["operations"][0][1]
         self.assertEqual(op["weight"], 9990)
+        
         c.steem.txbuffer.clear()
-        tx = c.downvote(weight=-150, voter="test")
+        tx = c.downvote(weight=150, voter="test")
         op = tx["operations"][0][1]
         self.assertEqual(op["weight"], -10000)
         c.steem.txbuffer.clear()
-        tx = c.downvote(weight=-99.9, voter="test")
+        tx = c.downvote(weight=99.9, voter="test")
         op = tx["operations"][0][1]
         self.assertEqual(op["weight"], -9990)
 
diff --git a/tests/beem/test_nodelist.py b/tests/beem/test_nodelist.py
index e888f062..bac38449 100644
--- a/tests/beem/test_nodelist.py
+++ b/tests/beem/test_nodelist.py
@@ -24,7 +24,7 @@ class Testcases(unittest.TestCase):
     def test_get_nodes(self):
         nodelist = NodeList()
         all_nodes = nodelist.get_nodes(exclude_limited=False, dev=True, testnet=True, testnetdev=True)
-        self.assertEqual(len(nodelist) - 15, len(all_nodes))
+        self.assertEqual(len(nodelist) - 22, len(all_nodes))
         https_nodes = nodelist.get_nodes(wss=False)
         self.assertEqual(https_nodes[0][:5], 'https')
 
-- 
GitLab