def test_response_with_unknown_fields(self, request): experiment_json = { "experiment_id": 1, "name": "My experiment", "artifact_location": "foo", "OMG_WHAT_IS_THIS_FIELD": "Hooly cow", } response = mock.MagicMock response.status_code = 200 experiments = {"experiments": [experiment_json]} response.text = json.dumps(experiments) request.return_value = response store = RestStore(lambda: MlflowHostCreds('https://hello')) experiments = store.list_experiments() assert len(experiments) == 1 assert experiments[0].name == 'My experiment'
def test_successful_http_request(self, request): def mock_request(**kwargs): # Filter out None arguments kwargs = dict( (k, v) for k, v in six.iteritems(kwargs) if v is not None) assert kwargs == { 'method': 'GET', 'url': 'https://hello/api/2.0/preview/mlflow/experiments/list', } response = mock.MagicMock response.status_code = 200 response.text = '{"experiments": [{"name": "Exp!"}]}' return response request.side_effect = mock_request store = RestStore({'hostname': 'https://hello'}) experiments = store.list_experiments() assert experiments[0].name == "Exp!"
def test_successful_http_request(self, request): def mock_request(**kwargs): # Filter out None arguments kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v is not None) assert kwargs == { 'method': 'GET', 'params': {'view_type': 'ACTIVE_ONLY'}, 'url': 'https://hello/api/2.0/mlflow/experiments/list', 'headers': _DEFAULT_HEADERS, 'verify': True, } response = mock.MagicMock response.status_code = 200 response.text = '{"experiments": [{"name": "Exp!", "lifecycle_stage": "active"}]}' return response request.side_effect = mock_request store = RestStore(lambda: MlflowHostCreds('https://hello')) experiments = store.list_experiments() assert experiments[0].name == "Exp!"