Skip to content

Commit

Permalink
[explorer/nodewatch] task: update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyLaw committed Mar 30, 2023
1 parent 3442a05 commit 1832550
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions explorer/nodewatch/tests/test_RoutesFacade.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_can_reload_all(self):
self.assertEqual(True, result)
self.assertEqual(facade.last_reload_time, facade.last_refresh_time)

self.assertEqual(6, len(facade.repository.node_descriptors))
self.assertEqual(8, len(facade.repository.node_descriptors))
self.assertEqual(4, len(facade.repository.harvester_descriptors))
self.assertEqual(4, len(facade.repository.voter_descriptors))

Expand All @@ -243,7 +243,7 @@ def test_can_skip_reload_when_noop(self):
self.assertEqual([True, False, False], [result1, result2, result3])
self.assertEqual(facade.last_reload_time, facade.last_refresh_time)

self.assertEqual(6, len(facade.repository.node_descriptors))
self.assertEqual(8, len(facade.repository.node_descriptors))
self.assertEqual(4, len(facade.repository.harvester_descriptors))
self.assertEqual(4, len(facade.repository.voter_descriptors))

Expand Down Expand Up @@ -293,9 +293,9 @@ def test_can_render_nodes_html(self):
self.assertEqual(4, len(context))
self.assertEqual('Symbol Nodes', context['title'])
self.assertEqual(
['Allnodes250', 'Apple', 'Shin-Kuma-Node', 'ibone74', 'jaguar', 'symbol.ooo maxUnlockedAccounts:100'],
['Allnodes250', 'Apple', 'Shin-Kuma-Node', 'ibone74', 'jaguar', 'symbol.ooo maxUnlockedAccounts:100', 'xym pool', 'yasmine farm'],
_get_names(context['descriptors']))
self.assertEqual([104] * 6, _get_network_bytes(context['descriptors']))
self.assertEqual([104] * 8, _get_network_bytes(context['descriptors']))
self.assertIsNotNone(context['version_to_css_class'])
self.assertEqual('<symbol_explorer>', context['explorer_endpoint'])

Expand Down Expand Up @@ -328,7 +328,7 @@ def test_can_render_summary_html(self):
# Assert:
self.assertEqual('symbol_summary.html', template_name)
self.assertEqual(5, len(context))
self.assertEqual(4, len(json.loads(context['height_chart_json'])['data'])) # { height, finalized_height } x { 1.0.3.5, 1.0.3.4 }
self.assertEqual(6, len(json.loads(context['height_chart_json'])['data'])) # { height, finalized_height } x { 1.0.3.5, 1.0.3.4 }
self.assertEqual(4, len(json.loads(context['voting_power_chart_json'])['data'])) # 1.0.3.5, 1.0.3.4, 1.0.3.3, ''
self.assertEqual(4, len(json.loads(context['harvesting_power_chart_json'])['data'])) # 1.0.3.5, 1.0.3.4, 1.0.3.3, ''
self.assertEqual(4, len(json.loads(context['harvesting_count_chart_json'])['data'])) # 1.0.3.5, 1.0.3.4, 1.0.3.3, ''
Expand Down Expand Up @@ -364,12 +364,12 @@ def test_can_generate_nodes_json(self):
node_descriptors = facade.json_nodes(role=1)

# Assert: spot check names and roles
self.assertEqual(5, len(node_descriptors))
self.assertEqual(7, len(node_descriptors))
self.assertEqual(
['Apple', 'Shin-Kuma-Node', 'ibone74', 'jaguar', 'symbol.ooo maxUnlockedAccounts:100'],
['Apple', 'Shin-Kuma-Node', 'ibone74', 'jaguar', 'symbol.ooo maxUnlockedAccounts:100', 'xym pool', 'yasmine farm'],
list(map(lambda descriptor: descriptor['name'], node_descriptors)))
self.assertEqual(
[7, 3, 3, 5, 3],
[7, 3, 3, 5, 3, 3, 3],
list(map(lambda descriptor: descriptor['roles'], node_descriptors)))

def test_can_generate_nodes_json_filtered(self):
Expand All @@ -381,12 +381,12 @@ def test_can_generate_nodes_json_filtered(self):
node_descriptors = facade.json_nodes(role=2)

# Assert: spot check names and roles
self.assertEqual(5, len(node_descriptors))
self.assertEqual(7, len(node_descriptors))
self.assertEqual(
['Allnodes250', 'Apple', 'Shin-Kuma-Node', 'ibone74', 'symbol.ooo maxUnlockedAccounts:100'],
['Allnodes250', 'Apple', 'Shin-Kuma-Node', 'ibone74', 'symbol.ooo maxUnlockedAccounts:100', 'xym pool', 'yasmine farm'],
list(map(lambda descriptor: descriptor['name'], node_descriptors)))
self.assertEqual(
[2, 7, 3, 3, 3],
[2, 7, 3, 3, 3, 3, 3],
list(map(lambda descriptor: descriptor['roles'], node_descriptors)))

def test_can_generate_nodes_json_filtered_exact_match(self):
Expand Down Expand Up @@ -415,7 +415,7 @@ def test_can_generate_height_chart_json(self):
chart_json = json.loads(facade.json_height_chart())

# Assert: { height, finalized_height } x { 1.0.3.4, 1.0.3.5 }
self.assertEqual(4, len(chart_json['data']))
self.assertEqual(6, len(chart_json['data']))

def test_can_generate_height_chart_with_metadata_json(self):
# Arrange:
Expand All @@ -428,7 +428,7 @@ def test_can_generate_height_chart_with_metadata_json(self):

# Assert: { height, finalized_height } x { 1.0.3.4, 1.0.3.5 }
self.assertEqual(2, len(chart_with_metadata_json))
self.assertEqual(4, len(chart_json['data']))
self.assertEqual(6, len(chart_json['data']))
self.assertTrue(re.match(r'\d\d:\d\d', chart_with_metadata_json['lastRefreshTime']))

def test_can_retrieve_estimated_network_height_json(self):
Expand Down

0 comments on commit 1832550

Please sign in to comment.