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 Apr 16, 2024
1 parent 73b8206 commit 32ad8b7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
19 changes: 10 additions & 9 deletions onadata/apps/api/tests/viewsets/test_briefcase_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from django_digest.test import DigestAuth
from rest_framework.test import APIRequestFactory

from onadata.apps.api.tests.viewsets import test_abstract_viewset
from onadata.apps.api.tests.viewsets.test_abstract_viewset import TestAbstractViewSet
from onadata.apps.api.viewsets.briefcase_viewset import (
BriefcaseViewset,
_query_optimization_fence,
Expand All @@ -33,18 +33,19 @@ def ordered_instances(xform):
return Instance.objects.filter(xform=xform).order_by("id")


class TestBriefcaseViewSet(test_abstract_viewset.TestAbstractViewSet):
class TestBriefcaseViewSet(TestAbstractViewSet):
"""
Test BriefcaseViewset
"""

def setUp(self):
super(test_abstract_viewset.TestAbstractViewSet, self).setUp()
super().setUp()

self.factory = APIRequestFactory()
self._login_user_and_profile()
self.login_username = "bob"
self.login_password = "bobbob"
self.maxDiff = None
self.user.set_password(self.login_password)
self.user.save()
self.form_def_path = os.path.join(
self.main_directory, "fixtures", "transportation", "transportation.xml"
)
Expand Down Expand Up @@ -395,10 +396,10 @@ def get_last_index(xform, last_index=None):
)
with codecs.open(submission_list_path, encoding="utf-8") as f:
expected_submission_list = f.read()
last_expected_submission_list = (
expected_submission_list
) = expected_submission_list.replace(
"{{resumptionCursor}}", "%s" % last_index
last_expected_submission_list = expected_submission_list = (
expected_submission_list.replace(
"{{resumptionCursor}}", "%s" % last_index
)
)
self.assertContains(response, expected_submission_list)
last_index += 2
Expand Down
4 changes: 2 additions & 2 deletions onadata/apps/api/tests/viewsets/test_xform_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5219,7 +5219,7 @@ def test_get_single_registration_form(self):
"bamboo_dataset": "",
"instances_with_geopoints": False,
"instances_with_osm": False,
"version": None,
"version": xform.version,
"has_hxl_support": False,
"last_updated_at": xform.last_updated_at.isoformat().replace("+00:00", "Z"),
"hash": xform.hash,
Expand Down Expand Up @@ -5286,7 +5286,7 @@ def test_get_list_registration_form(self):
"bamboo_dataset": "",
"instances_with_geopoints": False,
"instances_with_osm": False,
"version": None,
"version": xform.version,
"has_hxl_support": False,
"last_updated_at": xform.last_updated_at.isoformat().replace(
"+00:00", "Z"
Expand Down
6 changes: 3 additions & 3 deletions onadata/apps/main/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from tempfile import NamedTemporaryFile

from django.conf import settings
from django.contrib.auth import authenticate, get_user_model
from django.contrib.auth import get_user_model
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.db.models import signals
from django.test import RequestFactory, TransactionTestCase
Expand Down Expand Up @@ -273,7 +273,7 @@ def _make_submission(
url = f"/{url_prefix}submission"

request = self.factory.post(url, post_data)
request.user = authenticate(username=auth.username, password=auth.password)
request.user = self.user

# pylint: disable=attribute-defined-outside-init
self.response = submission(request, username=username)
Expand Down Expand Up @@ -309,7 +309,7 @@ def _make_submission_w_attachment(self, path, attachment_path):
auth = DigestAuth("bob", "bob")
self.factory = APIRequestFactory()
request = self.factory.post(url, data)
request.user = authenticate(username="bob", password="bob")
request.user = self.user
# pylint: disable=attribute-defined-outside-init
self.response = submission(request, username=self.user.username)

Expand Down

0 comments on commit 32ad8b7

Please sign in to comment.