Skip to content

Commit

Permalink
Replace pyxform_version with generated_by per reviewer feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
yanokwa committed Dec 20, 2019
1 parent 3ce8cda commit 5bf9228
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pyxform/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
COMPACT_TAG = "compact_tag"

VERSION = "version"
PYXFORM_VERSION = "pyxform_version"
GENERATED_BY = "generated_by"
PUBLIC_KEY = "public_key"
SUBMISSION_URL = "submission_url"
AUTO_SEND = "auto_send"
Expand Down
6 changes: 3 additions & 3 deletions pyxform/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class Survey(Section):
"public_key": unicode,
"instance_xmlns": unicode,
"version": unicode,
"pyxform_version": unicode,
"generated_by": unicode,
"choices": dict,
"style": unicode,
"attribute": dict,
Expand Down Expand Up @@ -476,8 +476,8 @@ def xml_instance(self, **kwargs):
if self.version:
result.setAttribute("version", self.version)

if self.pyxform_version:
result.setAttribute("odk:pyxform-version", self.pyxform_version)
if self.generated_by:
result.setAttribute("odk:generated-by", self.generated_by)

if self.prefix:
result.setAttribute("odk:prefix", self.prefix)
Expand Down
10 changes: 5 additions & 5 deletions pyxform/tests/builder_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_specify_other(self):
],
}
actual_dict = survey.to_json_dict()
actual_dict.pop("pyxform_version", None)
actual_dict.pop("generated_by", None)
self.maxDiff = None
self.assertEqual(actual_dict, expected_dict)

Expand Down Expand Up @@ -202,7 +202,7 @@ def test_select_one_question_with_identical_choice_name(self):
],
}
actual_dict = survey.to_json_dict()
actual_dict.pop("pyxform_version", None)
actual_dict.pop("generated_by", None)
self.maxDiff = None
self.assertEqual(actual_dict, expected_dict)

Expand Down Expand Up @@ -317,7 +317,7 @@ def test_loop(self):
],
}
actual_dict = survey.to_json_dict()
actual_dict.pop("pyxform_version", None)
actual_dict.pop("generated_by", None)
self.maxDiff = None
self.assertEqual(actual_dict, expected_dict)

Expand Down Expand Up @@ -456,7 +456,7 @@ def test_sms_columns(self):
"type": "survey",
}
actual_dict = survey.to_json_dict()
actual_dict.pop("pyxform_version", None)
actual_dict.pop("generated_by", None)
self.assertEqual(actual_dict, expected_dict)

def test_style_column(self):
Expand Down Expand Up @@ -497,7 +497,7 @@ def test_style_column(self):
"type": "survey",
}
actual_dict = survey.to_json_dict()
actual_dict.pop("pyxform_version", None)
actual_dict.pop("generated_by", None)
self.assertEqual(actual_dict, expected_dict)

STRIP_NS_FROM_TAG_RE = re.compile(r"\{.+\}")
Expand Down
2 changes: 1 addition & 1 deletion pyxform/tests/group_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_json(self):
},
],
}
x_results.pop("pyxform_version", None)
x_results.pop("generated_by", None)
self.maxDiff = None
self.assertEqual(x_results, expected_dict)

Expand Down
2 changes: 1 addition & 1 deletion pyxform/tests/loop_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ def test_loop(self):
],
}
actual_dict = survey.to_json_dict()
actual_dict.pop("pyxform_version", None)
actual_dict.pop("generated_by", None)
self.assertEquals(actual_dict, expected_dict)
2 changes: 1 addition & 1 deletion pyxform/tests/settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_survey_reader(self):
],
}
actual_dict = survey_reader.to_json_dict()
actual_dict.pop("pyxform_version", None)
actual_dict.pop("generated_by", None)
self.assertEqual(actual_dict, expected_dict)

def test_settings(self):
Expand Down
2 changes: 1 addition & 1 deletion pyxform/tests/tests_by_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def runTest(self):
path_to_excel_file, default_name=root_filename
)
survey = pyxform.create_survey_element_from_dict(json_survey)
survey.pyxform_version = ""
survey.generated_by = ""
survey.print_xform_to_file(path_to_output_xform)

# Compare with the expected output:
Expand Down
12 changes: 6 additions & 6 deletions pyxform/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def assertXFormEqual(self, xform1, xform2):
xform1 = ETree.fromstring(xform1.encode("utf-8"))
xform2 = ETree.fromstring(xform2.encode("utf-8"))

# Remove the odk:pyxform-version attribute from the primary instance child
self.remove_pyxform_version_attribute(xform1)
self.remove_pyxform_version_attribute(xform2)
# Remove the odk:generated-by attribute from the primary instance child
self.remove_generated_by_attribute(xform1)
self.remove_generated_by_attribute(xform2)

# Sort tags under <model> section in each form
self.sort_model(xform1)
Expand Down Expand Up @@ -97,14 +97,14 @@ def elem_get_tag(elem):
key = elem_get_tag
elems[:] = sorted(elems, key=key)

def remove_pyxform_version_attribute(self, xform):
def remove_generated_by_attribute(self, xform):
xforms_ns = "{http://www.w3.org/2002/xforms}"
odk_ns = "{http://www.opendatakit.org/xforms}"
primary_instance = xform.find(".//" + xforms_ns + "instance")

# Remove the pyxform-version attribute
# Remove the generated-by attribute
if primary_instance is not None:
primary_instance[0].attrib.pop(odk_ns + "pyxform-version", None)
primary_instance[0].attrib.pop(odk_ns + "generated-by", None)

def sort_model(self, xform):
ns = "{http://www.w3.org/2002/xforms}"
Expand Down
4 changes: 2 additions & 2 deletions pyxform/tests/xls2json_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_simple_yes_or_no_question(self):
with codecs.open(output_path, "rb", encoding="utf-8") as actual_file:
expected_json = json.load(expected_file)
actual_json = json.load(actual_file)
actual_json.pop("pyxform_version", None)
actual_json.pop("generated_by", None)
self.assertEqual(expected_json, actual_json)

def test_hidden(self):
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_table(self):
with codecs.open(output_path, "rb", encoding="utf-8") as actual_file:
expected_json = json.load(expected_file)
actual_json = json.load(actual_file)
actual_json.pop("pyxform_version", None)
actual_json.pop("generated_by", None)
self.assertEqual(expected_json, actual_json)

def test_choice_filter_choice_fields(self):
Expand Down
4 changes: 2 additions & 2 deletions pyxform/tests_v1/pyxform_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ def assertPyxformXform(self, **kwargs):
else:
survey = kwargs.get("survey")

# Remove the pyxform-version attribute
# Remove the generated-by attribute
if survey:
survey.pyxform_version = ""
survey.generated_by = ""

xml = survey._to_pretty_xml()
root = ETree.fromstring(xml.encode("utf-8"))
Expand Down
2 changes: 1 addition & 1 deletion pyxform/xls2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def workbook_to_json(
# problems for formhub.
# constants.VERSION : datetime.datetime.now().strftime("%Y%m%d%H"),
constants.CHILDREN: [],
constants.PYXFORM_VERSION: get_git_describe_tags(),
constants.GENERATED_BY: "pyxform " + get_git_describe_tags(),
}
# Here the default settings are overridden by those in the settings sheet
json_dict.update(settings)
Expand Down

0 comments on commit 5bf9228

Please sign in to comment.