Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-muchiri committed Feb 6, 2024
1 parent 279d501 commit 468afd7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion onadata/libs/tests/utils/test_logger_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def setUp(self):
self.xml = (
'<?xml version="1.0" encoding="UTF-8"?>'
'<data xmlns:jr="http://openrosa.org/javarosa" xmlns:orx='
'"http://openrosa.org/xforms" id="trees_registration" version="202311070702">'
'"http://openrosa.org/xforms" id="trees_registration" version="2022110901">'
"<formhub><uuid>d156a2dce4c34751af57f21ef5c4e6cc</uuid></formhub>"
"<location>-1.286905 36.772845 0 0</location>"
"<species>purpleheart</species>"
Expand Down
16 changes: 10 additions & 6 deletions onadata/libs/utils/logger_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ def create_xform_version(xform: XForm, user: User) -> XFormVersion:
versioned_xform = XFormVersion.objects.create(
xform=xform,
xls=xform.xls,
json=xform.json
if isinstance(xform.json, str)
else json.dumps(xform.json),
json=(
xform.json
if isinstance(xform.json, str)
else json.dumps(xform.json)
),
version=xform.version,
created_by=user,
xml=xform.xml,
Expand Down Expand Up @@ -438,9 +440,11 @@ def save_attachments(xform, instance, media_files, remove_deleted_media=False):
if len(filename) > 100:
raise AttachmentNameError(filename)
media_in_submission = filename in instance.get_expected_media() or [
instance.xml.decode("utf-8").find(filename) != -1
if isinstance(instance.xml, bytes)
else instance.xml.find(filename) != -1
(
instance.xml.decode("utf-8").find(filename) != -1
if isinstance(instance.xml, bytes)
else instance.xml.find(filename) != -1
)
]
if media_in_submission:
Attachment.objects.get_or_create(
Expand Down

0 comments on commit 468afd7

Please sign in to comment.