Skip to content

Commit

Permalink
Fix: model cleanups for the Admin (#2078)
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman authored May 3, 2024
2 parents ceb351e + 9915910 commit 7cf6349
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def __init__(self, *args, **kwargs):
# although the validator also checks for a max length of 127
# this setting enforces the length at the database column level as well
kwargs["max_length"] = 127
# similar to max_length, enforce at the field (form) validation level to not allow blanks
kwargs["blank"] = False
# the default is False, but this is more explicit
kwargs["allow_unicode"] = False
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -102,6 +100,9 @@ def supports_sign_out(self):
def client_id(self):
return get_secret_by_name(self.client_id_secret_name)

def __str__(self) -> str:
return self.client_name


class EligibilityType(models.Model):
"""A single conditional eligibility type."""
Expand Down
8 changes: 8 additions & 0 deletions tests/pytest/core/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ def test_SecretNameField_init():
assert field.description != ""


def test_SecretNameField_init_null_blank():
field = SecretNameField(blank=True, null=True)

assert field.blank is True
assert field.null is True


@pytest.mark.django_db
def test_PemData_str(model_PemData):
assert str(model_PemData) == model_PemData.label
Expand Down Expand Up @@ -89,6 +96,7 @@ def test_PemData_data_text_secret_name_and_remote__uses_remote(
def test_model_AuthProvider(model_AuthProvider):
assert not model_AuthProvider.supports_claims_verification
assert model_AuthProvider.supports_sign_out
assert str(model_AuthProvider) == model_AuthProvider.client_name


@pytest.mark.django_db
Expand Down

0 comments on commit 7cf6349

Please sign in to comment.