def _fields(cls): # type: () -> Dict[str, ConjureFieldDefinition] return { 'items': ConjureFieldDefinition('items', ListType(str)), 'double_items': ConjureFieldDefinition('doubleItems', ListType(float)) }
def get_branches_deprecated(self, auth_header, dataset_rid): # type: (str, str) -> List[str] """ Gets all branches of this dataset. """ _headers = { 'Accept': 'application/json', 'Authorization': auth_header, } # type: Dict[str, Any] _params = { } # type: Dict[str, Any] _path_params = { 'datasetRid': dataset_rid, } # type: Dict[str, Any] _json = None # type: Any _path = '/catalog/datasets/{datasetRid}/branchesDeprecated' _path = _path.format(**_path_params) _response = self._request( # type: ignore 'GET', self._uri + _path, params=_params, headers=_headers, json=_json) _decoder = ConjureDecoder() return _decoder.decode(_response.json(), ListType(str))
def get_branches(self, auth_header, dataset_rid, message=None, page_size=None): # type: (str, str, Optional[str], Optional[int]) -> List[str] _headers = { 'Accept': 'application/json', 'Authorization': auth_header, 'Special-Message': message, } # type: Dict[str, Any] _params = { 'pageSize': page_size, } # type: Dict[str, Any] _path_params = { 'datasetRid': dataset_rid, } # type: Dict[str, Any] _json = None # type: Any _path = '/catalog/datasets/{datasetRid}/branches' _path = _path.format(**_path_params) _response = self._request( # type: ignore 'GET', self._uri + _path, params=_params, headers=_headers, json=_json) _decoder = ConjureDecoder() return _decoder.decode(_response.json(), ListType(str))
def _fields(cls): # type: () -> Dict[str, ConjureFieldDefinition] return { 'string': ConjureFieldDefinition('string', str), 'integer': ConjureFieldDefinition('integer', int), 'double_value': ConjureFieldDefinition('doubleValue', float), 'optional_item': ConjureFieldDefinition('optionalItem', OptionalType(str)), 'items': ConjureFieldDefinition('items', ListType(str)), 'set': ConjureFieldDefinition('set', ListType(str)), 'map': ConjureFieldDefinition('map', DictType(str, str)), 'alias': ConjureFieldDefinition('alias', StringAliasExample) }
def _options(cls): # type: () -> Dict[str, ConjureFieldDefinition] return { 'string_example': ConjureFieldDefinition('stringExample', StringExample), 'set': ConjureFieldDefinition('set', ListType(str)), 'this_field_is_an_integer': ConjureFieldDefinition('thisFieldIsAnInteger', int), 'also_an_integer': ConjureFieldDefinition('alsoAnInteger', int), 'if_': ConjureFieldDefinition('if', int), 'new': ConjureFieldDefinition('new', int), 'interface': ConjureFieldDefinition('interface', int) }
def test_list_does_not_decode_from_json_string(): with pytest.raises(Exception): ConjureDecoder().read_from_string("\"hello\"", ListType(int))
def test_list_from_json_object_fails(): with pytest.raises(Exception): ConjureDecoder().read_from_string("{}", ListType(int))
def test_list_with_no_items_decodes(): decoded = ConjureDecoder().read_from_string("[]", ListType(int)) assert type(decoded) is list
def test_list_with_one_badly_typed_item_fails(): with pytest.raises(Exception): ConjureDecoder().read_from_string("""[1,"two",3]""", ListType(int))
def test_list_with_well_typed_items_decodes(): decoded = ConjureDecoder().read_from_string("[1,2,3]", ListType(int)) assert type(decoded) is list assert type(decoded[0]) is int