-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
blockchain_integration/pi_network/PiFusion/tests/test_node_selection.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import unittest | ||
from pi_fusion_dashboard.node_selection import NodeSelection | ||
|
||
class TestNodeSelection(unittest.TestCase): | ||
def setUp(self): | ||
self.node_selection = NodeSelection() | ||
|
||
def test_get_nodes(self): | ||
nodes = self.node_selection.get_nodes() | ||
self.assertIsInstance(nodes, list) | ||
self.assertGreater(len(nodes), 0) | ||
|
||
def test_get_node_by_id(self): | ||
node_id = 1 | ||
node = self.node_selection.get_node_by_id(node_id) | ||
self.assertIsInstance(node, dict) | ||
self.assertEqual(node['id'], node_id) | ||
|
||
def test_get_node_by_name(self): | ||
node_name = 'Node 1' | ||
node = self.node_selection.get_node_by_name(node_name) | ||
self.assertIsInstance(node, dict) | ||
self.assertEqual(node['name'], node_name) | ||
|
||
def test_filter_nodes_by_reputation(self): | ||
reputation_threshold = 0.5 | ||
filtered_nodes = self.node_selection.filter_nodes_by_reputation(reputation_threshold) | ||
self.assertIsInstance(filtered_nodes, list) | ||
for node in filtered_nodes: | ||
self.assertGreaterEqual(node['reputation'], reputation_threshold) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |