@@ -636,7 +636,7 @@ def print_results(results):
636636 )
637637
638638
639- def print_errors (errors ):
639+ def print_errors (errors ): # pragma: no cover
640640 if errors :
641641 console .confirm (
642642 'Are you sure you want to display errors?' ,
@@ -886,7 +886,7 @@ def update_general_information(
886886 )
887887 .first ()
888888 )
889- body = {}
889+ body = {'context' : {} }
890890 updated = 0
891891 errors_on_update = 0
892892 for n in range (2 , sheet .max_row + 1 ):
@@ -901,31 +901,24 @@ def update_general_information(
901901 h .value == 'Product ID'
902902 and stream .get ('context' , {}).get ('product' , {}).get ('id' , None ) != v .value
903903 ):
904- if 'context' in body :
905- body ['context' ].update ({'product' : {'id' : v .value }})
906- else :
907- body ['context' ] = {'product' : {'id' : v .value }}
904+ body ['context' ]['product' ] = {'id' : v .value }
908905 updated += 1
909906 elif (
910907 h .value == 'Partner ID'
911908 and stream .get ('context' , {}).get ('account' , {}).get ('id' , None ) != v .value
912909 ):
913- if 'context' in body :
914- body ['context' ].update ({'account' : {'id' : v .value }})
915- else :
916- body ['context' ] = {'account' : {'id' : v .value }}
910+ body ['context' ]['account' ] = {'id' : v .value }
917911 updated += 1
918912 elif (
919913 h .value == 'Marketplace ID'
920914 and stream .get ('context' , {}).get ('marketplace' , {}).get ('id' , None ) != v .value
921915 ):
922- if 'context' in body :
923- body ['context' ].update ({'marketplace' : {'id' : v .value }})
924- else :
925- body ['context' ] = {'marketplace' : {'id' : v .value }}
916+ body ['context' ]['marketplace' ] = {'id' : v .value }
926917 updated += 1
927918
928919 if updated :
920+ if not body ['context' ]:
921+ del body ['context' ]
929922 try :
930923 client .ns (collection ).streams [stream_id ].update (
931924 json = body ,
@@ -959,7 +952,7 @@ def update_transformations(
959952 origin_trf = None
960953 try :
961954 origin_trf = client .ns (collection ).streams [stream_id ].transformations [id .value ].get ()
962- except ClientError as e :
955+ except ClientError :
963956 errors .append (
964957 f'The transformation { id .value } cannot be updated because it does not exist.'
965958 )
@@ -968,22 +961,22 @@ def update_transformations(
968961
969962 try :
970963 to_update = {}
971- if origin_trf ['settings' ] != settings .value :
972- to_update ['settings' ] = settings .value
964+ if origin_trf ['settings' ] != json . loads ( settings .value ) :
965+ to_update ['settings' ] = json . loads ( settings .value )
973966 if descr .value and (
974967 'description' not in origin_trf or origin_trf ['description' ] != descr .value
975968 ):
976969 to_update ['description' ] = descr .value
977- if origin_trf ['position' ] != position .value :
978- to_update ['position' ] = position .value
970+ if int ( origin_trf ['position' ]) != position .value :
971+ to_update ['position' ] = int ( position .value )
979972
980973 if to_update :
981974 client .ns (collection ).streams [stream_id ].transformations [id .value ].update (
982975 json = to_update ,
983976 )
984977 updated += 1
985978 progress .update (task , advance = 1 )
986- except ClientError as e :
979+ except ClientError :
987980 errors .append (f'Error updating the transformation { id .value } with data { to_update } .' )
988981
989982 try :
@@ -995,7 +988,7 @@ def update_transformations(
995988 client .ns (collection ).streams [stream_id ].transformations [cid ].delete ()
996989 deleted += 1
997990 except ClientError as e :
998- errors .append (f'Error deleting the transformation { id . value } .' )
991+ errors .append (f'Error deleting the transformation { e } .' )
999992
1000993 results .append (('Transformations' , sheet .max_row - 1 , 0 , updated , deleted , 0 , len (errors )))
1001994
0 commit comments