def test_playbook_apply_commit(self): self.mock_request().get.side_effect = self._mock_manager pbb = PlayBookInstanceBuilder(self.conn, 'automation-coredump-pb', 'HbEZ-instance', 'Core') pbb.apply(commit=True) self.assertEqual(self.mock_request().mock_calls[9][0], 'post') self.assertEqual(self.mock_request().mock_calls[9][1][0], 'https://1.1.1.1:8080/api/v1/configuration')
def test_playbook_instance_builder_with_no_variable(self): self.mock_request().get.side_effect = self._mock_manager pbb = PlayBookInstanceBuilder(self.conn, 'automation-coredump-pb', 'HbEZ-instance', 'Core') pbb.apply() self.assertEqual(self.mock_request().mock_calls[5][0], 'put') self.assertEqual(self.mock_request().mock_calls[5][1][0], 'https://1.1.1.1:8080/api/v1/device-group/Core')
def test_playbook_schema_setter(self): self.mock_request().get.side_effect = self._mock_manager pbb = PlayBookInstanceBuilder( self.conn, 'forwarding-table-summary', 'HbEZ-instance', 'Core') with self.assertRaises(RuntimeError): pbb.playbook_schema = 30
def test_playbook_instance_builder_with_non_existing_device(self): self.mock_request().get.side_effect = self._mock_manager pbb = PlayBookInstanceBuilder(self.conn, 'forwarding-table-summary', 'HbEZ-instance', 'Core') routesummary_fib_summary = pbb.rule_variables[ "protocol.routesummary/check-fib-summary"] routesummary_fib_summary.route_count_threshold = 200 routesummary_fib_summary.route_address_family = 'abc' self.assertRaises(RuntimeError, pbb.apply, device_ids=['fake'])
def test_playbook_apply_commit(self): self.mock_request().get.side_effect = self._mock_manager with patch('jnpr.healthbot.healthbot.HealthBotClient.config_url', new_callable=PropertyMock) as mock_cnf: mock_cnf.return_value = "https://1.1.1.1:8080/api/v1" pbb = PlayBookInstanceBuilder(self.conn, 'automation-coredump-pb', 'HbEZ-instance', 'Core') pbb.apply(commit=True) self.assertEqual(self.mock_request().mock_calls[9][0], 'post') self.assertEqual(self.mock_request().mock_calls[9][1][0], 'https://1.1.1.1:8080/api/v1/configuration')
def test_playbook_instance_builder_with_variable_per_device(self): self.mock_request().get.side_effect = self._mock_manager pbb = PlayBookInstanceBuilder(self.conn, 'forwarding-table-summary', 'HbEZ-instance', 'Core') routesummary_fib_summary = pbb.rule_variables[ "protocol.routesummary/check-fib-summary"] routesummary_fib_summary.route_count_threshold = 200 routesummary_fib_summary.route_address_family = 'abc' pbb.apply(device_ids=['vmx']) self.assertEqual(self.mock_request().mock_calls[7][0], 'put') self.assertEqual(self.mock_request().mock_calls[7][1][0], 'https://1.1.1.1:8080/api/v1/device/vmx')
def test_playbook_instance_builder_delete(self): self.mock_request().get.side_effect = self._mock_manager pbb = PlayBookInstanceBuilder( self.conn, 'automation-coredump-pb', 'HbEZ-instance', 'Core') pbb.delete() self.assertEqual(self.mock_request().mock_calls[6][0], 'put') self.assertEqual( self.mock_request().mock_calls[6][1][0], 'https://1.1.1.1:8080/api/v2/config/device/vmx') self.assertEqual( self.mock_request().mock_calls[10][1][0], 'https://1.1.1.1:8080/api/v2/config/device-group/Core')
def test_clear(self): self.mock_request().get.side_effect = self._mock_manager pbb = PlayBookInstanceBuilder(self.conn, 'forwarding-table-summary', 'HbEZ-instance', 'Core') routesummary_fib_summary = pbb.rule_variables[ "protocol.routesummary/check-fib-summary"] routesummary_fib_summary.route_count_threshold = 200 routesummary_fib_summary.route_address_family = 'abc' pbb.clear() routesummary_fib_summary = pbb.rule_variables[ "protocol.routesummary/check-fib-summary"] self.assertEqual(routesummary_fib_summary.route_count_threshold, '10000')
def test_playbook_instance_builder_with_no_device_group(self): from jnpr.healthbot.exception import NotFoundError self.mock_request().get.side_effect = self._mock_manager pbb = PlayBookInstanceBuilder( self.conn, 'automation-coredump-pb', 'xyz', 'real') self.assertRaises(NotFoundError, pbb.apply)