def test_get_all_as_table(self): result = self.cli_runner.invoke(cli, ['get', 'env']) table_format = TableFormat(table=EnvironmentTable()) ctl = get_global_controller() expected_output = table_format.convert_list( ctl.config.environments.values()) self.assert_output(result, expected_output)
def test_ping(self): result = self.cli_runner.invoke(cli, ['ping', 'env', 'default']) self.assert_no_errors(result) ctl = get_global_controller() expected_results = TestResults(tests=[ TestResult('Descriptors', error=None), TestResult('Topology', error=None), TestResult('Behaviour', error=None), TestResult('Resource Manager', error=None) ]) table_format = TableFormat(table=PingTable()) address = ctl.config.environments.get('default').tnco.address expected_output = f'Pinging CP4NA orchestration: {address}' expected_output += '\n' expected_output += table_format.convert_list(expected_results.tests) expected_output += '\nCP4NA orchestration tests passed! ✅' self.assert_output(result, expected_output)
def test_ping_with_failure(self, mock_descriptors_api): mock_error = TNCOClientError('Mock error') mock_descriptors_api.return_value.all.side_effect = mock_error ctl = get_global_controller() result = self.cli_runner.invoke(cli, ['ping', 'env', 'default']) self.assert_has_system_exit(result) ctl = get_global_controller() expected_results = TestResults(tests=[ TestResult('Descriptors', error='Mock error'), TestResult('Topology', error=None), TestResult('Behaviour', error=None), TestResult('Resource Manager', error=None) ]) table_format = TableFormat(table=PingTable()) address = ctl.config.environments.get('default').tnco.address expected_output = f'Pinging CP4NA orchestration: {address}' expected_output += '\n' expected_output += table_format.convert_list(expected_results.tests) expected_output += '\nCP4NA orchestration tests failed! ❌' self.assert_output(result, expected_output)