diff --git a/kobo/apps/openrosa/apps/api/tests/fixtures/users.json b/kobo/apps/openrosa/apps/api/tests/fixtures/users.json
deleted file mode 100644
index 72ad40c86a..0000000000
--- a/kobo/apps/openrosa/apps/api/tests/fixtures/users.json
+++ /dev/null
@@ -1,18 +0,0 @@
-[
- {
- "model": "auth.user",
- "pk": 2,
- "fields": {
- "username": "bob",
- "password": "pbkdf2_sha256$260000$T1eA0O4Ub6c6FAaCsb0fqU$6vX4qMw1VV9tMXFf1d9pL/5z5/2T1MQYYn7vB3p+I2Y=",
- "email": "bob@columbia.edu",
- "first_name": "bob",
- "last_name": "bob",
- "is_active": true,
- "is_staff": false,
- "is_superuser": false,
- "last_login": null,
- "date_joined": "2015-02-12T19:52:14.406Z"
- }
- }
-]
diff --git a/kobo/apps/openrosa/apps/api/tests/viewsets/test_xform_submission_api.py b/kobo/apps/openrosa/apps/api/tests/viewsets/test_xform_submission_api.py
index b2a2104851..73aaf5fcf3 100644
--- a/kobo/apps/openrosa/apps/api/tests/viewsets/test_xform_submission_api.py
+++ b/kobo/apps/openrosa/apps/api/tests/viewsets/test_xform_submission_api.py
@@ -484,6 +484,74 @@ def test_submission_blocking_flag(self):
response = self.view(request, username=username)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
+ def test_submission_customizable_confirmation_message(self):
+ s = 'transport_with_custom_attribute'
+ media_file = '1335783522563.jpg'
+ xml_files = [
+ 'transport_with_custom_attribute_01',
+ 'transport_with_custom_attribute_02',
+ 'transport_with_no_custom_attribute'
+ ]
+
+ path = os.path.join(
+ self.main_directory,
+ 'fixtures',
+ 'transportation',
+ 'instances',
+ s,
+ media_file,
+ )
+ with open(path, 'rb') as f:
+ f = InMemoryUploadedFile(
+ f,
+ 'media_file',
+ media_file,
+ 'image/jpg',
+ os.path.getsize(path),
+ None,
+ )
+ for xml_file in xml_files:
+ submission_path = os.path.join(
+ self.main_directory,
+ 'fixtures',
+ 'transportation',
+ 'instances',
+ s,
+ xml_file + '.xml',
+ )
+ with open(submission_path) as sf:
+ data = {'xml_submission_file': sf, 'media_file': f}
+ request = self.factory.post('/submission', data)
+ response = self.view(request)
+ self.assertEqual(response.status_code, 401)
+
+ # rewind the file and redo the request since they were
+ # consumed
+ sf.seek(0)
+ f.seek(0)
+ request = self.factory.post('/submission', data)
+ auth = DigestAuth('bob', 'bobbob')
+ request.META.update(auth(request.META, response))
+ response = self.view(request, username=self.user.username)
+ if xml_file == 'transport_with_custom_attribute_01':
+ self.assertContains(
+ response, 'Custom submit message', status_code=201
+ )
+ elif xml_file == 'transport_with_custom_attribute_02':
+ self.assertContains(
+ response, 'Successful submission.', status_code=201
+ )
+ elif xml_file == (
+ 'transport_with_custom_attribute_and_different_root'
+ ):
+ self.assertContains(
+ response, 'Custom submit message', status_code=201
+ )
+ else:
+ self.assertContains(
+ response, 'Successful submission.', status_code=201
+ )
+
class ConcurrentSubmissionTestCase(RequestMixin, LiveServerTestCase):
"""
@@ -492,10 +560,11 @@ class ConcurrentSubmissionTestCase(RequestMixin, LiveServerTestCase):
Otherwise, DB is populated only on the first request but still empty on
subsequent ones.
"""
- fixtures = ['kobo/apps/openrosa/apps/api/tests/fixtures/users']
def setUp(self):
- self.user = User.objects.get(username='bob')
+ self.user = User.objects.create_user(
+ username='bob', password='bob', email='bob@columbia.edu'
+ )
self.token, _ = Token.objects.get_or_create(user=self.user)
UserProfile.objects.get_or_create(user=self.user)
@@ -587,72 +656,3 @@ def submit_data(identifier, survey_, username_, live_server_url, token_):
headers=headers
)
return response.status_code
-=======
- def test_submission_customizable_confirmation_message(self):
- s = 'transport_with_custom_attribute'
- media_file = '1335783522563.jpg'
- xml_files = [
- 'transport_with_custom_attribute_01',
- 'transport_with_custom_attribute_02',
- 'transport_with_no_custom_attribute'
- ]
-
- path = os.path.join(
- self.main_directory,
- 'fixtures',
- 'transportation',
- 'instances',
- s,
- media_file,
- )
- with open(path, 'rb') as f:
- f = InMemoryUploadedFile(
- f,
- 'media_file',
- media_file,
- 'image/jpg',
- os.path.getsize(path),
- None,
- )
- for xml_file in xml_files:
- submission_path = os.path.join(
- self.main_directory,
- 'fixtures',
- 'transportation',
- 'instances',
- s,
- xml_file + '.xml',
- )
- with open(submission_path) as sf:
- data = {'xml_submission_file': sf, 'media_file': f}
- request = self.factory.post('/submission', data)
- response = self.view(request)
- self.assertEqual(response.status_code, 401)
-
- # rewind the file and redo the request since they were
- # consumed
- sf.seek(0)
- f.seek(0)
- request = self.factory.post('/submission', data)
- auth = DigestAuth('bob', 'bobbob')
- request.META.update(auth(request.META, response))
- response = self.view(request, username=self.user.username)
- if xml_file == 'transport_with_custom_attribute_01':
- self.assertContains(
- response, 'Custom submit message', status_code=201
- )
- elif xml_file == 'transport_with_custom_attribute_02':
- self.assertContains(
- response, 'Successful submission.', status_code=201
- )
- elif xml_file == (
- 'transport_with_custom_attribute_and_different_root'
- ):
- self.assertContains(
- response, 'Custom submit message', status_code=201
- )
- else:
- self.assertContains(
- response, 'Successful submission.', status_code=201
- )
->>>>>>> @{-1}
diff --git a/kobo/apps/openrosa/apps/logger/migrations/0038_add_root_uuid_field_to_instance.py b/kobo/apps/openrosa/apps/logger/migrations/0041_add_root_uuid_field_to_instance.py
similarity index 83%
rename from kobo/apps/openrosa/apps/logger/migrations/0038_add_root_uuid_field_to_instance.py
rename to kobo/apps/openrosa/apps/logger/migrations/0041_add_root_uuid_field_to_instance.py
index 3e91ddae75..c1ae495d60 100644
--- a/kobo/apps/openrosa/apps/logger/migrations/0038_add_root_uuid_field_to_instance.py
+++ b/kobo/apps/openrosa/apps/logger/migrations/0041_add_root_uuid_field_to_instance.py
@@ -1,4 +1,4 @@
-# Generated by Django 4.2.15 on 2024-09-29 18:31
+# Generated by Django 4.2.15 on 2025-01-07 16:10
from django.conf import settings
from django.db import migrations, models
@@ -8,7 +8,7 @@ class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
- ('logger', '0037_remove_xform_has_kpi_hooks_and_instance_posted_to_kpi'),
+ ('logger', '0040_increase_file_fields_max_length'),
]
operations = [
diff --git a/kobo/apps/openrosa/apps/main/tests/fixtures/transportation/instances/transport_with_custom_attribute/transport_with_no_custom_attribute.xml b/kobo/apps/openrosa/apps/main/tests/fixtures/transportation/instances/transport_with_custom_attribute/transport_with_no_custom_attribute.xml
index 31727e3135..cf325fdc2c 100644
--- a/kobo/apps/openrosa/apps/main/tests/fixtures/transportation/instances/transport_with_custom_attribute/transport_with_no_custom_attribute.xml
+++ b/kobo/apps/openrosa/apps/main/tests/fixtures/transportation/instances/transport_with_custom_attribute/transport_with_no_custom_attribute.xml
@@ -1 +1 @@
-uuid:7g0a1508-c3b7-4c99-be00-9b237c26bcfb
+uuid:8g0a1508-c3b7-4c99-be00-9b237c26aaa
diff --git a/kobo/apps/openrosa/libs/utils/logger_tools.py b/kobo/apps/openrosa/libs/utils/logger_tools.py
index cee1a81da2..cf22874ff0 100644
--- a/kobo/apps/openrosa/libs/utils/logger_tools.py
+++ b/kobo/apps/openrosa/libs/utils/logger_tools.py
@@ -827,6 +827,7 @@ def get_soft_deleted_attachments(instance: Instance) -> list[Attachment]:
return soft_deleted_attachments
+
def _get_instance(
request: 'rest_framework.request.Request',
xml: str,