@@ -177,7 +177,6 @@ async def test_create_store(self, mock_request):
177177 '''
178178 mock_request .return_value = mock_response (response_body , 201 )
179179 configuration = self .configuration
180- configuration .store_id = store_id
181180 async with OpenFgaClient (configuration ) as api_client :
182181 api_response = await api_client .create_store (
183182 CreateStoreRequest (name = "test-store" ),
@@ -1911,3 +1910,99 @@ async def test_write_assertions(self, mock_request):
19111910 _preload_content = ANY ,
19121911 _request_timeout = None
19131912 )
1913+
1914+ @patch .object (rest .RESTClientObject , 'request' )
1915+ async def test_set_store_id (self , mock_request ):
1916+ """Test case for write assertions
1917+
1918+ Get all stores # noqa: E501
1919+ """
1920+ mock_request .return_value = mock_response ('' , 204 )
1921+ configuration = self .configuration
1922+ configuration .store_id = store_id
1923+ async with OpenFgaClient (configuration ) as api_client :
1924+ api_client .set_store_id ("01YCP46JKYM8FJCQ37NMBYHE5Y" )
1925+ await api_client .write_assertions (
1926+ [Assertion (
1927+ tuple_key = TupleKey (object = "document:2021-budget" , relation = "reader" ,
1928+ user = "user:anne" ),
1929+ expectation = True ,
1930+ )],
1931+ options = {"authorization_model_id" : "01G5JAVJ41T49E9TT3SKVS7X1J" }
1932+ )
1933+ self .assertEqual (api_client .get_store_id (), "01YCP46JKYM8FJCQ37NMBYHE5Y" )
1934+ mock_request .assert_called_once_with (
1935+ 'PUT' ,
1936+ 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5Y/assertions/01G5JAVJ41T49E9TT3SKVS7X1J' ,
1937+ headers = ANY ,
1938+ body = {"assertions" : [{"tuple_key" : {"object" : "document:2021-budget" ,
1939+ "relation" : "reader" , "user" : "user:anne" }, "expectation" : True }]},
1940+ query_params = [],
1941+ post_params = [],
1942+ _preload_content = ANY ,
1943+ _request_timeout = None
1944+ )
1945+
1946+ @patch .object (rest .RESTClientObject , 'request' )
1947+ async def test_config_auth_model (self , mock_request ):
1948+ """Test case for write assertions
1949+
1950+ Get all stores # noqa: E501
1951+ """
1952+ mock_request .return_value = mock_response ('' , 204 )
1953+ configuration = self .configuration
1954+ configuration .store_id = store_id
1955+ configuration .authorization_model_id = "01G5JAVJ41T49E9TT3SKVS7X1J"
1956+ async with OpenFgaClient (configuration ) as api_client :
1957+ await api_client .write_assertions (
1958+ [Assertion (
1959+ tuple_key = TupleKey (object = "document:2021-budget" , relation = "reader" ,
1960+ user = "user:anne" ),
1961+ expectation = True ,
1962+ )],
1963+ options = {}
1964+ )
1965+ self .assertEqual (api_client .get_authorization_model_id (), "01G5JAVJ41T49E9TT3SKVS7X1J" )
1966+ mock_request .assert_called_once_with (
1967+ 'PUT' ,
1968+ 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J' ,
1969+ headers = ANY ,
1970+ body = {"assertions" : [{"tuple_key" : {"object" : "document:2021-budget" ,
1971+ "relation" : "reader" , "user" : "user:anne" }, "expectation" : True }]},
1972+ query_params = [],
1973+ post_params = [],
1974+ _preload_content = ANY ,
1975+ _request_timeout = None
1976+ )
1977+
1978+ @patch .object (rest .RESTClientObject , 'request' )
1979+ async def test_update_auth_model (self , mock_request ):
1980+ """Test case for write assertions
1981+
1982+ Get all stores # noqa: E501
1983+ """
1984+ mock_request .return_value = mock_response ('' , 204 )
1985+ configuration = self .configuration
1986+ configuration .store_id = store_id
1987+ configuration .authorization_model_id = "01G5JAVJ41T49E9TT3SKVS7X1J"
1988+ async with OpenFgaClient (configuration ) as api_client :
1989+ api_client .set_authorization_model_id ("01G5JAVJ41T49E9TT3SKVS7X2J" )
1990+ await api_client .write_assertions (
1991+ [Assertion (
1992+ tuple_key = TupleKey (object = "document:2021-budget" , relation = "reader" ,
1993+ user = "user:anne" ),
1994+ expectation = True ,
1995+ )],
1996+ options = {}
1997+ )
1998+ mock_request .assert_called_once_with (
1999+ 'PUT' ,
2000+ 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X2J' ,
2001+ headers = ANY ,
2002+ body = {"assertions" : [{"tuple_key" : {"object" : "document:2021-budget" ,
2003+ "relation" : "reader" , "user" : "user:anne" }, "expectation" : True }]},
2004+ query_params = [],
2005+ post_params = [],
2006+ _preload_content = ANY ,
2007+ _request_timeout = None
2008+ )
0 commit comments