File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -68,3 +68,29 @@ def test_client_select():
6868 data = supabase .table ("countries" ).select ("*" ).execute ()
6969 # Assert we pulled real data.
7070 assert len (data .get ("data" , [])) > 0
71+
72+
73+ def test_client_insert ():
74+ """Ensure we can select data from a table."""
75+ from supabase_py import create_client , Client
76+
77+ url : str = os .environ .get ("SUPABASE_TEST_URL" )
78+ key : str = os .environ .get ("SUPABASE_TEST_KEY" )
79+ supabase : Client = create_client (url , key )
80+ data = supabase .table ("countries" ).select ("*" ).execute ()
81+ # Assert we pulled real data.
82+ previous_length : int = len (data .get ("data" , []))
83+ new_row = {
84+ "name" : "test name" ,
85+ "iso2" : "test iso2" ,
86+ "iso3" : "test iso3" ,
87+ "local_name" : "test local name" ,
88+ "continent" : None ,
89+ }
90+ result = supabase .table ("countries" ).insert (new_row ).execute ()
91+ data = supabase .table ("countries" ).select ("*" ).execute ()
92+ current_length : int = len (data .get ("data" , []))
93+ # Ensure we've added a row remotely.
94+ assert current_length == previous_length + 1
95+ # Check returned result for insert was valid.
96+ assert result .get ("status_code" , 400 ) == 201
You can’t perform that action at this time.
0 commit comments