From 18c904ebf84527de2fcca1600241e7e9c44680e9 Mon Sep 17 00:00:00 2001 From: FrankApiyo Date: Thu, 25 Jul 2024 15:57:36 +0300 Subject: [PATCH] Fix failing tests --- onadata/apps/api/models/organization_profile.py | 4 ++++ onadata/apps/api/tests/viewsets/test_abstract_viewset.py | 1 + .../tests/viewsets/test_organization_profile_viewset.py | 7 ++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/onadata/apps/api/models/organization_profile.py b/onadata/apps/api/models/organization_profile.py index cd6625bebf..3a7e115304 100644 --- a/onadata/apps/api/models/organization_profile.py +++ b/onadata/apps/api/models/organization_profile.py @@ -183,6 +183,10 @@ def __str__(self): def save(self, *args, **kwargs): # pylint: disable=arguments-differ super().save(*args, **kwargs) + @property + def email(self): + return self.user.email + def remove_user_from_organization(self, user): """Removes a user from all teams/groups in the organization. diff --git a/onadata/apps/api/tests/viewsets/test_abstract_viewset.py b/onadata/apps/api/tests/viewsets/test_abstract_viewset.py index 81ac952be4..fb836d8aaf 100644 --- a/onadata/apps/api/tests/viewsets/test_abstract_viewset.py +++ b/onadata/apps/api/tests/viewsets/test_abstract_viewset.py @@ -201,6 +201,7 @@ def _org_create(self, org_data=None): response = view(request) self.assertEqual(response.status_code, 200) data = { + "email": "mail@mail-server.org", "org": "denoinc", "name": "Dennis", "city": "Denoville", diff --git a/onadata/apps/api/tests/viewsets/test_organization_profile_viewset.py b/onadata/apps/api/tests/viewsets/test_organization_profile_viewset.py index a8e27e2c57..1fac73fe9d 100644 --- a/onadata/apps/api/tests/viewsets/test_organization_profile_viewset.py +++ b/onadata/apps/api/tests/viewsets/test_organization_profile_viewset.py @@ -214,16 +214,16 @@ def test_orgs_get_anon(self): self.assertTrue(isinstance(user["user"], text)) def test_orgs_create(self): - org_email = "mail@mail-server.org" - self._org_create(org_data = {"email": org_email}) + self._org_create() self.assertTrue(self.organization.user.is_active) - self.assertEqual(self.organization.user.email, org_email) + self.assertEqual(self.organization.user.email, "mail@mail-server.org") def test_orgs_create_without_name(self): data = { "org": "denoinc", "city": "Denoville", "country": "US", + "email": "user@mail.org", "home_page": "deno.com", "twitter": "denoinc", "description": "", @@ -563,6 +563,7 @@ def test_orgs_create_with_mixed_case(self): "home_page": "deno.com", "twitter": "denoinc", "description": "", + "email": "user@mail.com", "address": "", "phonenumber": "", "require_auth": False,