-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from open-formulieren/fix/3435-add-model-str-m…
…ethod Add string method to the token exchange config method
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
token_exchange/migrations/0002_tokenexchangeconfiguration_label.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Generated by Django 3.2.21 on 2023-11-08 15:02 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("token_exchange", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="tokenexchangeconfiguration", | ||
name="label", | ||
field=models.CharField( | ||
blank=True, | ||
help_text="The label of this token exchange configuration", | ||
max_length=250, | ||
verbose_name="label", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from django.test import TestCase | ||
|
||
from .factories import TokenExchangeConfigurationFactory | ||
|
||
|
||
class TokenExchangeConfigurationTests(TestCase): | ||
def test_string_method_with_service_label(self): | ||
config = TokenExchangeConfigurationFactory.create(service__label="A label") | ||
|
||
self.assertEqual("A label", str(config)) | ||
|
||
def test_string_method_withou_service_label(self): | ||
config = TokenExchangeConfigurationFactory.create() | ||
|
||
self.assertEqual( | ||
f"TokenExchangeConfiguration object ({config.pk})", str(config) | ||
) | ||
|
||
def test_save_does_not_overwrite_label(self): | ||
config = TokenExchangeConfigurationFactory.create( | ||
label="A config label", service__label="A service label" | ||
) | ||
|
||
self.assertEqual("A config label", str(config)) |