Skip to content

Commit

Permalink
fix: pass tests with (required) not None continuation_token
Browse files Browse the repository at this point in the history
  • Loading branch information
booniepepper committed Jan 3, 2024
1 parent f76a76d commit 5ace65c
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 36 deletions.
4 changes: 2 additions & 2 deletions openfga_sdk/models/read_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def continuation_token(self, continuation_token):
:param continuation_token: The continuation_token of this ReadResponse. # noqa: E501
:type continuation_token: str
"""
# if self.local_vars_configuration.client_side_validation and continuation_token is None: # noqa: E501
# raise ValueError("Invalid value for `continuation_token`, must not be `None`") # noqa: E501
if self.local_vars_configuration.client_side_validation and continuation_token is None: # noqa: E501
raise ValueError("Invalid value for `continuation_token`, must not be `None`") # noqa: E501

self._continuation_token = continuation_token

Expand Down
20 changes: 10 additions & 10 deletions openfga_sdk/models/tuple_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def user(self, user):
:param user: The user of this TupleKey. # noqa: E501
:type user: str
"""
# if self.local_vars_configuration.client_side_validation and user is None: # noqa: E501
# raise ValueError("Invalid value for `user`, must not be `None`") # noqa: E501
# if (self.local_vars_configuration.client_side_validation and
# user is not None and len(user) > 512):
# raise ValueError("Invalid value for `user`, length must be less than or equal to `512`") # noqa: E501
if self.local_vars_configuration.client_side_validation and user is None: # noqa: E501
raise ValueError("Invalid value for `user`, must not be `None`") # noqa: E501
if (self.local_vars_configuration.client_side_validation and
user is not None and len(user) > 512):
raise ValueError("Invalid value for `user`, length must be less than or equal to `512`") # noqa: E501

self._user = user

Expand All @@ -113,11 +113,11 @@ def relation(self, relation):
:param relation: The relation of this TupleKey. # noqa: E501
:type relation: str
"""
# if self.local_vars_configuration.client_side_validation and relation is None: # noqa: E501
# raise ValueError("Invalid value for `relation`, must not be `None`") # noqa: E501
# if (self.local_vars_configuration.client_side_validation and
# relation is not None and len(relation) > 50):
# raise ValueError("Invalid value for `relation`, length must be less than or equal to `50`") # noqa: E501
if self.local_vars_configuration.client_side_validation and relation is None: # noqa: E501
raise ValueError("Invalid value for `relation`, must not be `None`") # noqa: E501
if (self.local_vars_configuration.client_side_validation and
relation is not None and len(relation) > 50):
raise ValueError("Invalid value for `relation`, length must be less than or equal to `50`") # noqa: E501

self._relation = relation

Expand Down
3 changes: 2 additions & 1 deletion openfga_sdk/sync/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from openfga_sdk.models.list_objects_request import ListObjectsRequest
from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse
from openfga_sdk.models.read_request import ReadRequest
from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey
from openfga_sdk.models.tuple_key import TupleKey
from openfga_sdk.models.write_assertions_request import WriteAssertionsRequest
from openfga_sdk.models.write_authorization_model_request import WriteAuthorizationModelRequest
Expand Down Expand Up @@ -331,7 +332,7 @@ def read_changes(self, body: ClientReadChangesRequest, options: dict[str, str] =
)
return api_response

def read(self, body: TupleKey, options: dict[str, str] = None):
def read(self, body: ReadRequestTupleKey, options: dict[str, str] = None):
"""
Read changes for specified type
:param body - the tuples we want to read
Expand Down
19 changes: 11 additions & 8 deletions test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,8 @@ async def test_read(self, mock_request):
},
"timestamp": "2021-10-06T15:32:11.128Z"
}
]
],
"continuation_token": ""
}
'''
mock_request.return_value = mock_response(response_body, 200)
Expand All @@ -661,7 +662,7 @@ async def test_read(self, mock_request):
key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="reader", object="document:2021-budget")
timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00")
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)])
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='')
self.assertEqual(api_response, expected_data)
mock_request.assert_called_once_with(
'POST',
Expand Down Expand Up @@ -692,15 +693,16 @@ async def test_read_empty_options(self, mock_request):
},
"timestamp": "2021-10-06T15:32:11.128Z"
}
]
],
"continuation_token": ""
}
'''
mock_request.return_value = mock_response(response_body, 200)
configuration = self.configuration
configuration.store_id = store_id
# Enter a context with an instance of the API client
async with OpenFgaClient(configuration) as api_client:
body = TupleKey(
body = ReadRequestTupleKey(
object="document:2021-budget",
relation="reader",
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Expand All @@ -713,7 +715,7 @@ async def test_read_empty_options(self, mock_request):
key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="reader", object="document:2021-budget")
timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00")
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)])
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='')
self.assertEqual(api_response, expected_data)
mock_request.assert_called_once_with(
'POST',
Expand Down Expand Up @@ -744,15 +746,16 @@ async def test_read_empty_body(self, mock_request):
},
"timestamp": "2021-10-06T15:32:11.128Z"
}
]
],
"continuation_token": ""
}
'''
mock_request.return_value = mock_response(response_body, 200)
configuration = self.configuration
configuration.store_id = store_id
# Enter a context with an instance of the API client
async with OpenFgaClient(configuration) as api_client:
body = TupleKey()
body = ReadRequestTupleKey()
api_response = await api_client.read(
body=body,
options={}
Expand All @@ -761,7 +764,7 @@ async def test_read_empty_body(self, mock_request):
key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="reader", object="document:2021-budget")
timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00")
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)])
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='')
self.assertEqual(api_response, expected_data)
mock_request.assert_called_once_with(
'POST',
Expand Down
22 changes: 13 additions & 9 deletions test/test_client_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse
from openfga_sdk.models.read_authorization_models_response import ReadAuthorizationModelsResponse
from openfga_sdk.models.read_changes_response import ReadChangesResponse
from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey
from openfga_sdk.models.read_response import ReadResponse
from openfga_sdk.models.store import Store
from openfga_sdk.models.tuple import Tuple
Expand Down Expand Up @@ -638,15 +639,16 @@ def test_read(self, mock_request):
},
"timestamp": "2021-10-06T15:32:11.128Z"
}
]
],
"continuation_token": ""
}
'''
mock_request.return_value = mock_response(response_body, 200)
configuration = self.configuration
configuration.store_id = store_id
# Enter a context with an instance of the API client
with OpenFgaClient(configuration) as api_client:
body = TupleKey(
body = ReadRequestTupleKey(
object="document:2021-budget",
relation="reader",
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Expand All @@ -660,7 +662,7 @@ def test_read(self, mock_request):
key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="reader", object="document:2021-budget")
timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00")
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)])
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='')
self.assertEqual(api_response, expected_data)
mock_request.assert_called_once_with(
'POST',
Expand Down Expand Up @@ -691,15 +693,16 @@ def test_read_empty_options(self, mock_request):
},
"timestamp": "2021-10-06T15:32:11.128Z"
}
]
],
"continuation_token": ""
}
'''
mock_request.return_value = mock_response(response_body, 200)
configuration = self.configuration
configuration.store_id = store_id
# Enter a context with an instance of the API client
with OpenFgaClient(configuration) as api_client:
body = TupleKey(
body = ReadRequestTupleKey(
object="document:2021-budget",
relation="reader",
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Expand All @@ -712,7 +715,7 @@ def test_read_empty_options(self, mock_request):
key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="reader", object="document:2021-budget")
timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00")
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)])
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='')
self.assertEqual(api_response, expected_data)
mock_request.assert_called_once_with(
'POST',
Expand Down Expand Up @@ -743,15 +746,16 @@ def test_read_empty_body(self, mock_request):
},
"timestamp": "2021-10-06T15:32:11.128Z"
}
]
],
"continuation_token": ""
}
'''
mock_request.return_value = mock_response(response_body, 200)
configuration = self.configuration
configuration.store_id = store_id
# Enter a context with an instance of the API client
with OpenFgaClient(configuration) as api_client:
body = TupleKey()
body = ReadRequestTupleKey()
api_response = api_client.read(
body=body,
options={}
Expand All @@ -760,7 +764,7 @@ def test_read_empty_body(self, mock_request):
key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="reader", object="document:2021-budget")
timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00")
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)])
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='')
self.assertEqual(api_response, expected_data)
mock_request.assert_called_once_with(
'POST',
Expand Down
8 changes: 5 additions & 3 deletions test/test_open_fga_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse
from openfga_sdk.models.read_changes_response import ReadChangesResponse
from openfga_sdk.models.read_request import ReadRequest
from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey
from openfga_sdk.models.read_response import ReadResponse
from openfga_sdk.models.store import Store
from openfga_sdk.models.tuple import Tuple
Expand Down Expand Up @@ -411,7 +412,8 @@ async def test_read(self, mock_request):
},
"timestamp": "2021-10-06T15:32:11.128Z"
}
]
],
"continuation_token": ""
}
'''
mock_request.return_value = mock_response(response_body, 200)
Expand All @@ -420,7 +422,7 @@ async def test_read(self, mock_request):
async with openfga_sdk.ApiClient(configuration) as api_client:
api_instance = open_fga_api.OpenFgaApi(api_client)
body = ReadRequest(
tuple_key=TupleKey(
tuple_key=ReadRequestTupleKey(
object="document:2021-budget",
relation="reader",
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Expand All @@ -435,7 +437,7 @@ async def test_read(self, mock_request):
key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="reader", object="document:2021-budget")
timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00")
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)])
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='')
self.assertEqual(api_response, expected_data)
mock_request.assert_called_once_with(
'POST',
Expand Down
8 changes: 5 additions & 3 deletions test/test_open_fga_api_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse
from openfga_sdk.models.read_changes_response import ReadChangesResponse
from openfga_sdk.models.read_request import ReadRequest
from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey
from openfga_sdk.models.read_response import ReadResponse
from openfga_sdk.models.store import Store
from openfga_sdk.models.tuple import Tuple
Expand Down Expand Up @@ -412,7 +413,8 @@ async def test_read(self, mock_request):
},
"timestamp": "2021-10-06T15:32:11.128Z"
}
]
],
"continuation_token": ""
}
'''
mock_request.return_value = mock_response(response_body, 200)
Expand All @@ -421,7 +423,7 @@ async def test_read(self, mock_request):
with ApiClient(configuration) as api_client:
api_instance = open_fga_api.OpenFgaApi(api_client)
body = ReadRequest(
tuple_key=TupleKey(
tuple_key=ReadRequestTupleKey(
object="document:2021-budget",
relation="reader",
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Expand All @@ -436,7 +438,7 @@ async def test_read(self, mock_request):
key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation="reader", object="document:2021-budget")
timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00")
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)])
expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='')
self.assertEqual(api_response, expected_data)
mock_request.assert_called_once_with(
'POST',
Expand Down

0 comments on commit 5ace65c

Please sign in to comment.