-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(submissions): avoid adding XML declaration when rewriting submiss…
…ion XML and creating asset snapshot (#5439) ### 📣 Summary The clean_duplicated_submissions command has been updated to save XML files without the declaration. ### 📖 Description This update modifies the behavior of the clean_duplicated_submissions command to save XML files without including the declaration. This change ensures cleaner XML outputs by removing unnecessary declaration headers, making it easier to work with the files programmatically.
- Loading branch information
1 parent
aa3bd43
commit 4d59d72
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
kobo/apps/openrosa/apps/logger/tests/test_set_meta_function.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from django.test import TestCase | ||
from kobo.apps.openrosa.apps.logger.xform_instance_parser import set_meta | ||
|
||
|
||
class TestSetMetaFunction(TestCase): | ||
def test_set_meta_updates_xml_correctly(self): | ||
""" | ||
Test that the set_meta() does not add an XML declaration | ||
""" | ||
xml_input = """ | ||
<data> | ||
<meta> | ||
<instanceID>uuid:original-id</instanceID> | ||
</meta> | ||
<question1>Answer1</question1> | ||
</data> | ||
""" | ||
updated_xml = set_meta( | ||
xml_input, 'instanceID', 'uuid:new-id' | ||
) | ||
|
||
# Ensure XML declaration is not added | ||
self.assertNotIn("<?xml version='1.0' ?>", updated_xml) | ||
|
||
# Ensure the instanceID is updated | ||
self.assertIn('<instanceID>uuid:new-id</instanceID>', updated_xml) | ||
|
||
def test_set_meta_raises_error_for_missing_node(self): | ||
xml_input = """ | ||
<data> | ||
<meta> | ||
<otherID>uuid:other-id</otherID> | ||
</meta> | ||
<question1>Answer1</question1> | ||
</data> | ||
""" | ||
with self.assertRaises(ValueError) as context: | ||
set_meta(xml_input, 'instanceID', 'uuid:new-id') | ||
|
||
self.assertEqual(str(context.exception), 'instanceID node not found') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters