def test_expanded_filepath(self, mocker, mock_open, endpoint, dtmi,
                               expected_path):
        resolver.resolve(dtmi, endpoint, expanded=True)

        assert mock_open.call_count == 1
        assert mock_open.call_args == mocker.call(expected_path)
        assert mock_open.return_value.read.call_count == 1
 def test_returns_dict_non_expanded(self, mocker, mock_open, endpoint,
                                    dtmi):
     result = resolver.resolve(dtmi, endpoint)
     expected_json = json.loads(mock_open.return_value.read())
     assert isinstance(result, dict)
     assert len(result) == 1
     assert result[dtmi] == expected_json
 def test_returned_dict_non_expanded(self, mocker, mock_http_get, endpoint,
                                     dtmi):
     result = resolver.resolve(dtmi, endpoint)
     expected_json = mock_http_get.return_value.json()
     assert isinstance(result, dict)
     assert len(result) == 1
     assert result[dtmi] == expected_json
 def test_returns_dict_expanded(self, mocker, mock_open, endpoint, dtmi):
     result = resolver.resolve(dtmi, endpoint, expanded=True)
     received_json = json.loads(mock_open.return_value.read())
     assert isinstance(result, dict)
     assert len(result) == len(received_json)
     for dtdl in received_json:
         dtmi = dtdl["@id"]
         assert dtmi in result.keys()
         assert result[dtmi] == dtdl
 def test_returned_dict_expanded(self, mocker, mock_http_get, endpoint,
                                 dtmi):
     result = resolver.resolve(dtmi, endpoint, expanded=True)
     received_json = mock_http_get.return_value.json()
     assert isinstance(result, dict)
     assert len(result) == len(received_json)
     for dtdl in received_json:
         dtmi = dtdl["@id"]
         assert dtmi in result.keys()
         assert result[dtmi] == dtdl
    def test_regular_url(self, mocker, mock_http_get, endpoint, dtmi,
                         expected_url):
        resolver.resolve(dtmi, endpoint)

        assert mock_http_get.call_count == 1
        assert mock_http_get.call_args == mocker.call(expected_url)
 def test_invalid_dtmi(self, dtmi, endpoint):
     with pytest.raises(ValueError):
         resolver.resolve(dtmi, endpoint)
 def test_get_failure(self, mock_http_get, endpoint, dtmi):
     mock_http_get.return_value.status_code = 400
     with pytest.raises(resolver.ResolverError):
         resolver.resolve(dtmi, endpoint)