def test_success(self): deployment_state = strip_margin("""|{ | "eventType": "deploymentStarted", | "deploymentId": "abc-def", | "bundleName": "cassandra", | "compatibleVersion": "v1" |} |""") http_method = self.respond_with(text=deployment_state) args = { 'dcos_mode': False, 'scheme': 'http', 'host': '127.0.0.1', 'port': '9005', 'base_path': '/', 'api_version': '1', 'conductr_auth': self.conductr_auth, 'server_verification_file': self.server_verification_file } input_args = MagicMock(**args) with patch('requests.get', http_method): result = bundle_deploy.get_deployment_state('abc-def', input_args) self.assertEqual(json.loads(deployment_state), result) http_method.assert_called_with( 'http://127.0.0.1:9005/deployments/abc-def', auth=self.conductr_auth, verify=self.server_verification_file, headers={'Host': '127.0.0.1'})
def test_return_none_if_404(self): http_method = self.respond_with(status_code=404) args = { 'dcos_mode': False, 'scheme': 'http', 'ip': '127.0.0.1', 'port': '9005', 'base_path': '/', 'api_version': '1', 'conductr_auth': self.conductr_auth, 'server_verification_file': self.server_verification_file } input_args = MagicMock(**args) with patch('requests.get', http_method): result = bundle_deploy.get_deployment_state('abc-def', input_args) self.assertIsNone(result) http_method.assert_called_with( 'http://127.0.0.1:9005/deployments/abc-def', auth=self.conductr_auth, verify=self.server_verification_file, headers={'Host': '127.0.0.1'})