|
41 | 41 | ALTERNATIVE_INGREDIENT_TEST_FILE = os.path.join(FIXTURES_DIR, "cloud.jpg") |
42 | 42 |
|
43 | 43 |
|
44 | | -def load_toml_test_settings_as_json(): |
45 | | - """ |
46 | | - Load default trust configuration test settings from a |
47 | | - TOML config file and return its content as JSON-compatible dict. |
48 | | - The return value is used to load settings. |
49 | | -
|
50 | | - Returns: |
51 | | - dict: The parsed TOML content as a Python dictionary (JSON-compatible). |
52 | | -
|
53 | | - Raises: |
54 | | - FileNotFoundError: If test_settings.toml is not found. |
55 | | - toml.TomlDecodeError: If the TOML file is malformed. |
56 | | - """ |
57 | | - # Locate the file which contains default settings for tests |
58 | | - tests_dir = os.path.dirname(os.path.abspath(__file__)) |
59 | | - settings_path = os.path.join(tests_dir, 'trust_config_test_settings.toml') |
60 | | - |
61 | | - # Load the located default test settings |
62 | | - with open(settings_path, 'r') as f: |
63 | | - settings_data = toml.load(f) |
64 | | - |
65 | | - return settings_data |
66 | | - |
67 | 44 | def load_test_settings_json(): |
68 | 45 | """ |
69 | 46 | Load default trust configuration test settings from a |
@@ -175,42 +152,6 @@ def test_stream_read_get_validation_state(self): |
175 | 152 | # Needs trust configuration to be set up to validate as Trusted, otherwise manifest is Invalid |
176 | 153 | self.assertEqual(validation_state, "Invalid") |
177 | 154 |
|
178 | | - def test_stream_read_get_validation_state_with_trust_config_from_toml(self): |
179 | | - # Run in a separate thread to isolate thread-local settings |
180 | | - result = {} |
181 | | - exception = {} |
182 | | - |
183 | | - def read_with_trust_config(): |
184 | | - try: |
185 | | - # Load trust configuration from test_settings.toml |
186 | | - settings_dict = load_toml_test_settings_as_json() |
187 | | - |
188 | | - # Apply the settings (including trust configuration) |
189 | | - # Settings are thread-local, so they won't affect other tests |
190 | | - # And that is why we also run the test in its own thread, so tests are isolated |
191 | | - load_settings(settings_dict) |
192 | | - |
193 | | - with open(self.testPath, "rb") as file: |
194 | | - reader = Reader("image/jpeg", file) |
195 | | - validation_state = reader.get_validation_state() |
196 | | - result['validation_state'] = validation_state |
197 | | - except Exception as e: |
198 | | - exception['error'] = e |
199 | | - |
200 | | - # Create and start thread |
201 | | - thread = threading.Thread(target=read_with_trust_config) |
202 | | - thread.start() |
203 | | - thread.join() |
204 | | - |
205 | | - # Check for exceptions |
206 | | - if 'error' in exception: |
207 | | - raise exception['error'] |
208 | | - |
209 | | - # Assertions run in main thread |
210 | | - self.assertIsNotNone(result.get('validation_state')) |
211 | | - # With trust configuration loaded, manifest is Trusted |
212 | | - self.assertEqual(result.get('validation_state'), "Trusted") |
213 | | - |
214 | 155 | def test_stream_read_get_validation_state_with_trust_config(self): |
215 | 156 | # Run in a separate thread to isolate thread-local settings |
216 | 157 | result = {} |
|
0 commit comments