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_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')