Skip to content

Commit

Permalink
Add tests for the AccoutUserArchive model
Browse files Browse the repository at this point in the history
  • Loading branch information
amstilp committed May 31, 2024
1 parent f9a9b22 commit b124c84
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions anvil_consortium_manager/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from ..adapters.default import DefaultWorkspaceAdapter
from ..models import (
Account,
AccountUserArchive,
BillingProject,
DefaultWorkspaceData,
GroupAccountMembership,
Expand Down Expand Up @@ -950,6 +951,54 @@ def test_has_workspace_access_is_not_shared_two_auth_domain_in_both(self):
self.assertFalse(account.has_workspace_access(workspace))


class AccountUserArchiveTestCase(TestCase):
"""Tests for the AccountUserArchive model."""

def test_model_saving(self):
"""Creation using the model constructor and .save() works."""
user = factories.UserFactory.create()
account = factories.AccountFactory.create()
instance = AccountUserArchive(user=user, account=account)
instance.save()
self.assertIsInstance(instance, AccountUserArchive)

def test_created_timestamp(self):
"""created timestamp is set."""
user = factories.UserFactory.create()
account = factories.AccountFactory.create()
instance = AccountUserArchive(user=user, account=account)
instance.save()
self.assertIsNotNone(instance.created)

def test_verified_email_entry(self):
"""Creation using the model constructor and .save() works."""
account = factories.AccountFactory.create(verified=True)
instance = AccountUserArchive(
user=account.user, account=account, verified_email_entry=account.verified_email_entry
)
instance.save()
self.assertIsInstance(instance, AccountUserArchive)

def test_one_account_two_users(self):
"""Multiple AccountUserArchive records for one user."""
user = factories.UserFactory.create()
account_1 = factories.AccountFactory.create()
account_2 = factories.AccountFactory.create()
instance = AccountUserArchive(user=user, account=account_1)
instance.save()
instance_2 = AccountUserArchive(user=user, account=account_2)
instance_2.save()
self.assertEqual(AccountUserArchive.objects.count(), 2)

def test_str_method(self):
"""The custom __str__ method returns a string."""
user = factories.UserFactory.create()
account = factories.AccountFactory.create()
instance = AccountUserArchive(user=user, account=account)
instance.save()
self.assertIsInstance(instance.__str__(), str)


class ManagedGroupTest(TestCase):
def test_model_saving(self):
"""Creation using the model constructor and .save() works."""
Expand Down

0 comments on commit b124c84

Please sign in to comment.