@@ -88,6 +88,18 @@ def setUp(self):
8888 # This seems to help.
8989 os .environ ["TZ" ] = "UTC"
9090
91+ @staticmethod
92+ def _filter_spdata (data : dict ) -> dict :
93+ # Storage providers are known to add "__" keys for their own use.
94+ # These should not be considered part of the general data.
95+ filtered_data = {
96+ k : v
97+ for k , v in data .items ()
98+ # if k not in [_SOPSAwareFilesystemObjectStorageProvider._STORAGE_TYPE_KEY]
99+ if not (isinstance (k , str ) and k .startswith ("__" ))
100+ }
101+ return filtered_data
102+
91103 def test_set_data_asserts_valid (self ):
92104 under_test = Credential (data = None , file_path = None )
93105 with self .assertRaises (FileBackedJsonObjectException ):
@@ -129,14 +141,14 @@ def test_load_and_failed_reload(self):
129141 # Load works when we have a valid file
130142 under_test .set_path (tdata_resource_file_path ("keys/base_test_credential.json" ))
131143 under_test .load ()
132- self .assertEqual ({"test_key" : "test_value" }, under_test .data ())
144+ self .assertEqual ({"test_key" : "test_value" }, self . _filter_spdata ( under_test .data () ))
133145
134146 # A subsequent failed load should throw, but leave the data unchanged.
135147 under_test .set_path (tdata_resource_file_path ("keys/FILE_DOES_NOT_EXIST.json" ))
136148 with self .assertRaises (FileNotFoundError ):
137149 under_test .load ()
138150
139- self .assertEqual ({"test_key" : "test_value" }, under_test .data ())
151+ self .assertEqual ({"test_key" : "test_value" }, self . _filter_spdata ( under_test .data () ))
140152
141153 def test_load_file_not_found (self ):
142154 under_test = Credential (data = None , file_path = tdata_resource_file_path ("keys/FILE_DOES_NOT_EXIST.json" ))
@@ -166,7 +178,7 @@ def test_lazy_load(self):
166178 under_test = Credential (data = None , file_path = tdata_resource_file_path ("keys/base_test_credential.json" ))
167179 self .assertIsNone (under_test .data ())
168180 under_test .lazy_load ()
169- self .assertEqual ({"test_key" : "test_value" }, under_test .data ())
181+ self .assertEqual ({"test_key" : "test_value" }, self . _filter_spdata ( under_test .data () ))
170182
171183 # if the path is invalid, it should error.
172184 under_test = Credential (data = None , file_path = tdata_resource_file_path ("keys/FILE_DOES_NOT_EXIST.json" ))
@@ -204,7 +216,7 @@ def test_lazy_reload_initial_load_behavior(self):
204216 under_test = Credential (data = None , file_path = tdata_resource_file_path ("keys/base_test_credential.json" ))
205217 self .assertIsNone (under_test .data ())
206218 under_test .lazy_reload ()
207- self .assertEqual ({"test_key" : "test_value" }, under_test .data ())
219+ self .assertEqual ({"test_key" : "test_value" }, self . _filter_spdata ( under_test .data () ))
208220
209221 # if the path is invalid, it should error.
210222 under_test = Credential (data = None , file_path = tdata_resource_file_path ("keys/FILE_DOES_NOT_EXIST.json" ))
@@ -299,7 +311,7 @@ def test_save(self):
299311 under_test .save ()
300312 test_reader = Credential (data = None , file_path = test_path )
301313 test_reader .load ()
302- self .assertEqual (test_data , test_reader .data ())
314+ self .assertEqual (test_data , self . _filter_spdata ( test_reader .data () ))
303315
304316 def test_getters_setters (self ):
305317 test_path = pathlib .Path ("/test/test_credential.json" )
0 commit comments