def test_safe_load_non_strict_json_parse_error(): """ Scenario: Failed to load json when invalid json string is given. Given: - Empty json string. When: - Preparing dictionary from string. Then: - Ensure Exception is raised with proper error message. """ from GoogleCloudSCC import safe_load_non_strict_json with pytest.raises(ValueError, match=ERROR_MESSAGES['JSON_PARSE_ERROR'].format('Service Account JSON')): safe_load_non_strict_json('Invalid json')
def test_safe_load_non_strict_json_empty(): """ Scenario: Returns {}(blank) dictionary when empty json string is given. Given: - Invalid json as string. When: - Preparing dictionary from string. Then: - Ensure {}(blank) dictionary should be returned. """ from GoogleCloudSCC import safe_load_non_strict_json assert safe_load_non_strict_json('') == {}
def test_safe_load_non_strict_json(): """ Scenario: Dictionary should be prepared from json string. Given: - json as string. When: - Preparing dictionary from string. Then: - Ensure valid json should be loaded successfully. """ from GoogleCloudSCC import safe_load_non_strict_json excepted_json = json.loads(TEST_JSON, strict=False) assert safe_load_non_strict_json(TEST_JSON) == excepted_json