diff --git a/pyxform/xls2json.py b/pyxform/xls2json.py index 75c2528b..1ae15bb1 100644 --- a/pyxform/xls2json.py +++ b/pyxform/xls2json.py @@ -1310,7 +1310,13 @@ def workbook_to_json( if row.get("default"): new_dict["default"] = process_image_default(row["default"]) - parameters_generic.validate(parameters=parameters, allowed=("max-pixels","app",)) + parameters_generic.validate( + parameters=parameters, + allowed=( + "max-pixels", + "app", + ), + ) if "max-pixels" in parameters.keys(): try: int(parameters["max-pixels"]) @@ -1326,13 +1332,13 @@ def workbook_to_json( ) if "app" in parameters.keys(): - android_package_regex_pattern = "^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$" + android_package_regex_pattern = ( + "^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$" + ) app_package_name = str(parameters["app"]) if re.fullmatch(android_package_regex_pattern, app_package_name): new_dict["control"] = new_dict.get("control", {}) - new_dict["control"].update( - {"intent": app_package_name} - ) + new_dict["control"].update({"intent": app_package_name}) else: raise PyXFormError("Invalid Android package name format") diff --git a/tests/test_image_app_parameter.py b/tests/test_image_app_parameter.py index 7b57b5e7..e5813c23 100644 --- a/tests/test_image_app_parameter.py +++ b/tests/test_image_app_parameter.py @@ -6,14 +6,13 @@ class ImageAppParameterTest(PyxformTestCase): - def test_valid_android_package_name(self): self.assertPyxformXform( name="data", md=""" | survey | | | | | | | type | name | label | parameters | - | | image | my_image | Image | app=com.jeyluta.timestampcamerafree | + | | image | my_image | Image | app=com.jeyluta.timestampcamerafree | """, xml__xpath_match=[ "/h:html/h:body/x:upload[@intent='com.jeyluta.timestampcamerafree' and @mediatype='image/*' and @ref='/data/my_image']" @@ -27,9 +26,7 @@ def test_invalid_android_package_name(self): md=""" | survey | | | | | | | type | name | label | parameters | - | | image | my_image | Image | app=something | + | | image | my_image | Image | app=something | """, - error__contains=[ - "Invalid Android package name format" - ], - ) \ No newline at end of file + error__contains=["Invalid Android package name format"], + )