@@ -192,3 +192,65 @@ def test_rest_create_csv_network_already_exists(
192192 )
193193 assert r .status_code == 400
194194 assert r .json () == 'Network already exists'
195+
196+
197+ @pytest .mark .django_db
198+ def test_create_csv_network_missing_joins (workspace , table_factory ):
199+ edge_table : Table = table_factory (workspace = workspace )
200+ table1 : Table = table_factory (workspace = workspace )
201+ table2 : Table = table_factory (workspace = workspace )
202+
203+ # Create small network
204+ table1 .put_rows (
205+ [
206+ {'id' : 1 , 'foo' : 'bar' },
207+ # This wont match to anything
208+ {'id' : 8 , 'foo' : 'baz' },
209+ ]
210+ )
211+ table2 .put_rows (
212+ [
213+ {'id' : 2 , 'bar' : 'baz' },
214+ # This wont match to anything
215+ {'id' : 40 , 'bar' : 'bat' },
216+ ]
217+ )
218+ edge_table .put_rows (
219+ [
220+ {'a' : 1 , 'b' : 2 , 'c' : 3 },
221+ # This wont match to anything
222+ {'a' : 100 , 'b' : 101 , 'c' : 3 },
223+ ]
224+ )
225+
226+ serializer = CSVNetworkCreateSerializer (
227+ data = {
228+ 'name' : 'test' ,
229+ 'edge' : {
230+ 'table' : {
231+ 'name' : edge_table .name ,
232+ 'excluded' : ['c' ],
233+ },
234+ 'source' : {
235+ 'local' : 'a' ,
236+ 'foreign' : 'id' ,
237+ },
238+ 'target' : {
239+ 'local' : 'b' ,
240+ 'foreign' : 'id' ,
241+ },
242+ },
243+ 'source_table' : {
244+ 'name' : table1 .name ,
245+ 'excluded' : ['test' ],
246+ },
247+ 'target_table' : {
248+ 'name' : table2 .name ,
249+ 'excluded' : [],
250+ },
251+ }
252+ )
253+ serializer .is_valid (raise_exception = True )
254+
255+ # Ensure no exceptions raised
256+ create_csv_network (workspace , serializer )
0 commit comments