From 22e62b4f651f726423855ef5300708b703cd4ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Wed, 18 Feb 2015 12:08:50 +0100 Subject: [PATCH] US #55: Custom fields - Change 'values' field in CustomAttributesValues models to 'attributes_values' --- taiga/export_import/serializers.py | 10 +++--- taiga/export_import/service.py | 2 +- ...svalues_userstorycustomattributesvalues.py | 6 ++-- ...0003_triggers_on_delete_customattribute.py | 3 +- taiga/projects/custom_attributes/models.py | 2 +- .../projects/custom_attributes/serializers.py | 8 ++--- taiga/projects/history/freeze_impl.py | 12 +++---- .../management/commands/sample_data.py | 15 ++++---- tests/factories.py | 6 ++-- .../test_issues_custom_attributes_resource.py | 6 ++-- .../test_custom_attributes_issues.py | 35 +++++++++---------- .../test_custom_attributes_tasks.py | 35 +++++++++---------- .../test_custom_attributes_user_stories.py | 35 +++++++++---------- tests/integration/test_importer_api.py | 6 ++-- 14 files changed, 91 insertions(+), 90 deletions(-) diff --git a/taiga/export_import/serializers.py b/taiga/export_import/serializers.py index 69f84b14..4027556d 100644 --- a/taiga/export_import/serializers.py +++ b/taiga/export_import/serializers.py @@ -350,7 +350,7 @@ class CustomAttributesValuesExportSerializerMixin: return ret try: - values = obj.custom_attributes_values.values + values = obj.custom_attributes_values.attributes_values custom_attributes = self.custom_attribute_queryset(obj.project).values('id', 'name') return _use_name_instead_id_as_key_in_custom_attributes_values(custom_attributes, values) @@ -359,15 +359,15 @@ class CustomAttributesValuesExportSerializerMixin: class BaseCustomAttributesValuesExportSerializer: - values = JsonField(source="values", label="values", required=True) + attributes_values = JsonField(source="attributes_values",required=True) _custom_attribute_model = None _container_field = None - def validate_values(self, attrs, source): + def validate_attributes_values(self, attrs, source): # values must be a dict - data_values = attrs.get("values", None) + data_values = attrs.get("attributes_values", None) if self.object: - data_values = (data_values or self.object.values) + data_values = (data_values or self.object.attributes_values) if type(data_values) is not dict: raise ValidationError(_("Invalid content. It must be {\"key\": \"value\",...}")) diff --git a/taiga/export_import/service.py b/taiga/export_import/service.py index 55ac48c8..9c6b52c4 100644 --- a/taiga/export_import/service.py +++ b/taiga/export_import/service.py @@ -111,7 +111,7 @@ def store_custom_attributes(project, data, field, serializer): def store_custom_attributes_values(obj, data_values, obj_field, serializer_class): data = { obj_field: obj.id, - "values": data_values, + "attributes_values": data_values, } serializer = serializer_class(data=data) diff --git a/taiga/projects/custom_attributes/migrations/0002_issuecustomattributesvalues_taskcustomattributesvalues_userstorycustomattributesvalues.py b/taiga/projects/custom_attributes/migrations/0002_issuecustomattributesvalues_taskcustomattributesvalues_userstorycustomattributesvalues.py index 4c7d2461..dd9ed428 100644 --- a/taiga/projects/custom_attributes/migrations/0002_issuecustomattributesvalues_taskcustomattributesvalues_userstorycustomattributesvalues.py +++ b/taiga/projects/custom_attributes/migrations/0002_issuecustomattributesvalues_taskcustomattributesvalues_userstorycustomattributesvalues.py @@ -20,7 +20,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)), ('version', models.IntegerField(default=1, verbose_name='version')), - ('values', django_pgjson.fields.JsonField(default={}, verbose_name='values')), + ('attributes_values', django_pgjson.fields.JsonField(default={}, verbose_name='attributes values')), ('issue', models.OneToOneField(related_name='custom_attributes_values', to='issues.Issue', verbose_name='issue')), ], options={ @@ -36,7 +36,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)), ('version', models.IntegerField(default=1, verbose_name='version')), - ('values', django_pgjson.fields.JsonField(default={}, verbose_name='values')), + ('attributes_values', django_pgjson.fields.JsonField(default={}, verbose_name='attributes values')), ('task', models.OneToOneField(related_name='custom_attributes_values', to='tasks.Task', verbose_name='task')), ], options={ @@ -52,7 +52,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)), ('version', models.IntegerField(default=1, verbose_name='version')), - ('values', django_pgjson.fields.JsonField(default={}, verbose_name='values')), + ('attributes_values', django_pgjson.fields.JsonField(default={}, verbose_name='attributes values')), ('user_story', models.OneToOneField(related_name='custom_attributes_values', to='userstories.UserStory', verbose_name='user story')), ], options={ diff --git a/taiga/projects/custom_attributes/migrations/0003_triggers_on_delete_customattribute.py b/taiga/projects/custom_attributes/migrations/0003_triggers_on_delete_customattribute.py index a733bceb..fc237167 100644 --- a/taiga/projects/custom_attributes/migrations/0003_triggers_on_delete_customattribute.py +++ b/taiga/projects/custom_attributes/migrations/0003_triggers_on_delete_customattribute.py @@ -42,7 +42,8 @@ class Migration(migrations.Migration): tablename := TG_ARGV[0]::text; EXECUTE 'UPDATE ' || quote_ident(tablename) || ' - SET values = json_object_delete_keys(values, ' || quote_literal(key) || ')'; + SET attributes_values = json_object_delete_keys(attributes_values, ' || + quote_literal(key) || ')'; RETURN NULL; END; $clean_key_in_custom_attributes_values$ diff --git a/taiga/projects/custom_attributes/models.py b/taiga/projects/custom_attributes/models.py index 287498d4..2fc0cf5c 100644 --- a/taiga/projects/custom_attributes/models.py +++ b/taiga/projects/custom_attributes/models.py @@ -78,7 +78,7 @@ class IssueCustomAttribute(AbstractCustomAttribute): ####################################################### class AbstractCustomAttributesValues(OCCModelMixin, models.Model): - values = JsonField(null=False, blank=False, default={}, verbose_name=_("values")) + attributes_values = JsonField(null=False, blank=False, default={}, verbose_name=_("attributes_values")) class Meta: abstract = True diff --git a/taiga/projects/custom_attributes/serializers.py b/taiga/projects/custom_attributes/serializers.py index 40a25ccc..b295af16 100644 --- a/taiga/projects/custom_attributes/serializers.py +++ b/taiga/projects/custom_attributes/serializers.py @@ -76,15 +76,15 @@ class IssueCustomAttributeSerializer(BaseCustomAttributeSerializer): class BaseCustomAttributesValuesSerializer: - values = JsonField(source="values", label="values", required=True) + attributes_values = JsonField(source="attributes_values", label="attributes values", required=True) _custom_attribute_model = None _container_field = None - def validate_values(self, attrs, source): + def validate_attributes_values(self, attrs, source): # values must be a dict - data_values = attrs.get("values", None) + data_values = attrs.get("attributes_values", None) if self.object: - data_values = (data_values or self.object.values) + data_values = (data_values or self.object.attributes_values) if type(data_values) is not dict: raise ValidationError(_("Invalid content. It must be {\"key\": \"value\",...}")) diff --git a/taiga/projects/history/freeze_impl.py b/taiga/projects/history/freeze_impl.py index 1e67df09..54c9eefb 100644 --- a/taiga/projects/history/freeze_impl.py +++ b/taiga/projects/history/freeze_impl.py @@ -188,37 +188,37 @@ def extract_attachments(obj) -> list: @as_tuple def extract_user_story_custom_attributes(obj) -> list: with suppress(ObjectDoesNotExist): - custom_attributes_values = obj.custom_attributes_values.values + custom_attributes_values = obj.custom_attributes_values.attributes_values for attr in obj.project.userstorycustomattributes.all(): with suppress(KeyError): value = custom_attributes_values[str(attr.id)] yield {"id": attr.id, "name": attr.name, - "values": value} + "value": value} @as_tuple def extract_task_custom_attributes(obj) -> list: with suppress(ObjectDoesNotExist): - custom_attributes_values = obj.custom_attributes_values.values + custom_attributes_values = obj.custom_attributes_values.attributes_values for attr in obj.project.taskcustomattributes.all(): with suppress(KeyError): value = custom_attributes_values[str(attr.id)] yield {"id": attr.id, "name": attr.name, - "values": value} + "value": value} @as_tuple def extract_issue_custom_attributes(obj) -> list: with suppress(ObjectDoesNotExist): - custom_attributes_values = obj.custom_attributes_values.values + custom_attributes_values = obj.custom_attributes_values.attributes_values for attr in obj.project.issuecustomattributes.all(): with suppress(KeyError): value = custom_attributes_values[str(attr.id)] yield {"id": attr.id, "name": attr.name, - "values": value} + "value": value} def project_freezer(project) -> dict: diff --git a/taiga/projects/management/commands/sample_data.py b/taiga/projects/management/commands/sample_data.py index c8139797..1e5331a0 100644 --- a/taiga/projects/management/commands/sample_data.py +++ b/taiga/projects/management/commands/sample_data.py @@ -270,10 +270,11 @@ class Command(BaseCommand): project=project)), tags=self.sd.words(1, 10).split(" ")) - custom_attributes_values = {str(ca.id): self.sd.paragraph() for ca in project.issuecustomattributes.all() if self.sd.boolean()} + custom_attributes_values = {str(ca.id): self.sd.paragraph() for ca in project.issuecustomattributes.all() + if self.sd.boolean()} if custom_attributes_values: IssueCustomAttributesValues.objects.create(issue=bug, - values=custom_attributes_values) + attributes_values=custom_attributes_values) for i in range(self.sd.int(*NUM_ATTACHMENTS)): attachment = self.create_attachment(bug, i+1) @@ -318,10 +319,11 @@ class Command(BaseCommand): task.save() - custom_attributes_values = {str(ca.id): self.sd.paragraph() for ca in project.taskcustomattributes.all() if self.sd.boolean()} + custom_attributes_values = {str(ca.id): self.sd.paragraph() for ca in project.taskcustomattributes.all() + if self.sd.boolean()} if custom_attributes_values: TaskCustomAttributesValues.objects.create(task=task, - values=custom_attributes_values) + attributes_values=custom_attributes_values) for i in range(self.sd.int(*NUM_ATTACHMENTS)): attachment = self.create_attachment(task, i+1) @@ -360,10 +362,11 @@ class Command(BaseCommand): role_points.save() - custom_attributes_values = {str(ca.id): self.sd.paragraph() for ca in project.userstorycustomattributes.all() if self.sd.boolean()} + custom_attributes_values = {str(ca.id): self.sd.paragraph() for ca in project.userstorycustomattributes.all() + if self.sd.boolean()} if custom_attributes_values: UserStoryCustomAttributesValues.objects.create(user_story=us, - values=custom_attributes_values) + attributes_values=custom_attributes_values) for i in range(self.sd.int(*NUM_ATTACHMENTS)): diff --git a/tests/factories.py b/tests/factories.py index e8f70e7d..4e9b9d0c 100644 --- a/tests/factories.py +++ b/tests/factories.py @@ -389,7 +389,7 @@ class UserStoryCustomAttributesValuesFactory(Factory): model = "custom_attributes.UserStoryCustomAttributesValues" strategy = factory.CREATE_STRATEGY - values = {} + attributes_values = {} user_story = factory.SubFactory("tests.factories.UserStoryFactory") @@ -398,7 +398,7 @@ class TaskCustomAttributesValuesFactory(Factory): model = "custom_attributes.TaskCustomAttributesValues" strategy = factory.CREATE_STRATEGY - values = {} + attributes_values = {} task = factory.SubFactory("tests.factories.TaskFactory") @@ -407,7 +407,7 @@ class IssueCustomAttributesValuesFactory(Factory): model = "custom_attributes.IssueCustomAttributesValues" strategy = factory.CREATE_STRATEGY - values = {} + attributes_values = {} issue = factory.SubFactory("tests.factories.IssueFactory") diff --git a/tests/integration/resources_permissions/test_issues_custom_attributes_resource.py b/tests/integration/resources_permissions/test_issues_custom_attributes_resource.py index 39caad51..2af987ad 100644 --- a/tests/integration/resources_permissions/test_issues_custom_attributes_resource.py +++ b/tests/integration/resources_permissions/test_issues_custom_attributes_resource.py @@ -102,15 +102,15 @@ def data(): #m.public_issue_cav = f.IssueCustomAttributesValuesFactory(project=m.public_project, # issue=f.IssueFactory(project=m.public_project, # owner=m.project_owner), - # values={str(m.public_issue_ca.id):"test"}) + # attributes_values={str(m.public_issue_ca.id):"test"}) #m.private_issue_cav1 = f.IssueCustomAttributesValuesFactory(project=m.private_project1, # issue=f.IssueFactory(project=m.private_project1, # owner=m.project_owner), - # values={str(m.private_issue_ca1.id):"test"}) + # attributes_values={str(m.private_issue_ca1.id):"test"}) #m.private_issue_cav2 = f.IssueCustomAttributesValuesFactory(project=m.private_project2, # issue=f.IssueFactory(project=m.private_project2, # owner=m.project_owner), - # values={str(m.private_issue_ca2.id):"test"}) + # attributes_values={str(m.private_issue_ca2.id):"test"}) return m diff --git a/tests/integration/test_custom_attributes_issues.py b/tests/integration/test_custom_attributes_issues.py index 40f22725..568f82c9 100644 --- a/tests/integration/test_custom_attributes_issues.py +++ b/tests/integration/test_custom_attributes_issues.py @@ -107,7 +107,7 @@ def test_issue_custom_attributes_values_create(client): url = reverse("issue-custom-attributes-values-list") data = { "issue": issue.id, - "values": { + "attributes_values": { ct1_id: "test_1", ct2_id: "test_2" }, @@ -117,9 +117,9 @@ def test_issue_custom_attributes_values_create(client): client.login(member.user) response = client.json.post(url, json.dumps(data)) assert response.status_code == 201 - assert json.loads(response.data["values"]) == data["values"] + assert json.loads(response.data["attributes_values"]) == data["attributes_values"] issue = issue.__class__.objects.get(id=issue.id) - assert issue.custom_attributes_values.values == data["values"] + assert issue.custom_attributes_values.attributes_values == data["attributes_values"] def test_issue_custom_attributes_values_create_with_error_invalid_key(client): @@ -135,7 +135,7 @@ def test_issue_custom_attributes_values_create_with_error_invalid_key(client): url = reverse("issue-custom-attributes-values-list") data = { "issue": issue.id, - "values": { + "attributes_values": { ct1_id: "test_1", "123456": "test_2" }, @@ -160,7 +160,7 @@ def test_issue_custom_attributes_values_update(client): custom_attrs_val = f.IssueCustomAttributesValuesFactory( issue=issue, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, @@ -168,7 +168,7 @@ def test_issue_custom_attributes_values_update(client): url = reverse("issue-custom-attributes-values-detail", args=[issue.id]) data = { - "values": { + "attributes_values": { ct1_id: "test_1_updated", ct2_id: "test_2_updated" }, @@ -179,9 +179,9 @@ def test_issue_custom_attributes_values_update(client): client.login(member.user) response = client.json.patch(url, json.dumps(data)) assert response.status_code == 200 - assert json.loads(response.data["values"]) == data["values"] + assert json.loads(response.data["attributes_values"]) == data["attributes_values"] issue = issue.__class__.objects.get(id=issue.id) - assert issue.custom_attributes_values.values == data["values"] + assert issue.custom_attributes_values.attributes_values == data["attributes_values"] def test_issue_custom_attributes_values_update_with_error_invalid_key(client): @@ -197,7 +197,7 @@ def test_issue_custom_attributes_values_update_with_error_invalid_key(client): custom_attrs_val = f.IssueCustomAttributesValuesFactory( issue=issue, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, @@ -205,7 +205,7 @@ def test_issue_custom_attributes_values_update_with_error_invalid_key(client): url = reverse("issue-custom-attributes-values-detail", args=[issue.id]) data = { - "values": { + "attributes_values": { ct1_id: "test_1_updated", "123456": "test_2_updated" }, @@ -231,7 +231,7 @@ def test_issue_custom_attributes_values_delete(client): url = reverse("issue-custom-attributes-values-detail", args=[issue.id]) custom_attrs_val = f.IssueCustomAttributesValuesFactory( issue=issue, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, @@ -258,7 +258,7 @@ def test_issue_custom_attributes_values_delete_us(client): url = reverse("issues-detail", args=[issue.id]) custom_attrs_val = f.IssueCustomAttributesValuesFactory( issue=issue, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, @@ -287,19 +287,18 @@ def test_trigger_update_issuecustomvalues_afeter_remove_issuecustomattribute(): ct2_id = "{}".format(custom_attr_2.id) custom_attrs_val = f.IssueCustomAttributesValuesFactory( - project=issue.project, issue=issue, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, ) - assert ct1_id in custom_attrs_val.values.keys() - assert ct2_id in custom_attrs_val.values.keys() + assert ct1_id in custom_attrs_val.attributes_values.keys() + assert ct2_id in custom_attrs_val.attributes_values.keys() custom_attr_2.delete() custom_attrs_val = custom_attrs_val.__class__.objects.get(id=custom_attrs_val.id) - assert ct1_id in custom_attrs_val.values.keys() - assert ct2_id not in custom_attrs_val.values.keys() + assert ct1_id in custom_attrs_val.attributes_values.keys() + assert ct2_id not in custom_attrs_val.attributes_values.keys() diff --git a/tests/integration/test_custom_attributes_tasks.py b/tests/integration/test_custom_attributes_tasks.py index 6740427d..33ebce5d 100644 --- a/tests/integration/test_custom_attributes_tasks.py +++ b/tests/integration/test_custom_attributes_tasks.py @@ -107,7 +107,7 @@ def test_task_custom_attributes_values_create(client): url = reverse("task-custom-attributes-values-list") data = { "task": task.id, - "values": { + "attributes_values": { ct1_id: "test_1", ct2_id: "test_2" }, @@ -116,9 +116,9 @@ def test_task_custom_attributes_values_create(client): client.login(member.user) response = client.json.post(url, json.dumps(data)) assert response.status_code == 201 - assert json.loads(response.data["values"]) == data["values"] + assert json.loads(response.data["attributes_values"]) == data["attributes_values"] task = task.__class__.objects.get(id=task.id) - assert task.custom_attributes_values.values == data["values"] + assert task.custom_attributes_values.attributes_values == data["attributes_values"] def test_task_custom_attributes_values_create_with_error_invalid_key(client): @@ -134,7 +134,7 @@ def test_task_custom_attributes_values_create_with_error_invalid_key(client): url = reverse("task-custom-attributes-values-list") data = { "task": task.id, - "values": { + "attributes_values": { ct1_id: "test_1", "123456": "test_2" }, @@ -158,7 +158,7 @@ def test_task_custom_attributes_values_update(client): custom_attrs_val = f.TaskCustomAttributesValuesFactory( task=task, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, @@ -166,7 +166,7 @@ def test_task_custom_attributes_values_update(client): url = reverse("task-custom-attributes-values-detail", args=[task.id]) data = { - "values": { + "attributes_values": { ct1_id: "test_1_updated", ct2_id: "test_2_updated" }, @@ -176,9 +176,9 @@ def test_task_custom_attributes_values_update(client): client.login(member.user) response = client.json.patch(url, json.dumps(data)) assert response.status_code == 200 - assert json.loads(response.data["values"]) == data["values"] + assert json.loads(response.data["attributes_values"]) == data["attributes_values"] task = task.__class__.objects.get(id=task.id) - assert task.custom_attributes_values.values == data["values"] + assert task.custom_attributes_values.attributes_values == data["attributes_values"] def test_task_custom_attributes_values_update_with_error_invalid_key(client): @@ -194,14 +194,14 @@ def test_task_custom_attributes_values_update_with_error_invalid_key(client): custom_attrs_val = f.TaskCustomAttributesValuesFactory( task=task, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, ) url = reverse("task-custom-attributes-values-detail", args=[task.id]) data = { - "values": { + "attributes_values": { ct1_id: "test_1_updated", "123456": "test_2_updated" }, @@ -228,7 +228,7 @@ def test_task_custom_attributes_values_delete(client): url = reverse("task-custom-attributes-values-detail", args=[task.id]) custom_attrs_val = f.TaskCustomAttributesValuesFactory( task=task, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, @@ -255,7 +255,7 @@ def test_task_custom_attributes_values_delete_us(client): url = reverse("tasks-detail", args=[task.id]) custom_attrs_val = f.TaskCustomAttributesValuesFactory( task=task, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, @@ -284,19 +284,18 @@ def test_trigger_update_userstorycustomvalues_afeter_remove_userstorycustomattri ct2_id = "{}".format(custom_attr_2.id) custom_attrs_val = f.UserStoryCustomAttributesValuesFactory( - project=user_story.project, user_story=user_story, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, ) - assert ct1_id in custom_attrs_val.values.keys() - assert ct2_id in custom_attrs_val.values.keys() + assert ct1_id in custom_attrs_val.attributes_values.keys() + assert ct2_id in custom_attrs_val.attributes_values.keys() custom_attr_2.delete() custom_attrs_val = custom_attrs_val.__class__.objects.get(id=custom_attrs_val.id) - assert ct1_id in custom_attrs_val.values.keys() - assert ct2_id not in custom_attrs_val.values.keys() + assert ct1_id in custom_attrs_val.attributes_values.keys() + assert ct2_id not in custom_attrs_val.attributes_values.keys() diff --git a/tests/integration/test_custom_attributes_user_stories.py b/tests/integration/test_custom_attributes_user_stories.py index b0ad7e9b..f6f355ff 100644 --- a/tests/integration/test_custom_attributes_user_stories.py +++ b/tests/integration/test_custom_attributes_user_stories.py @@ -107,7 +107,7 @@ def test_userstory_custom_attributes_values_create(client): url = reverse("userstory-custom-attributes-values-list") data = { "user_story": user_story.id, - "values": { + "attributes_values": { ct1_id: "test_1", ct2_id: "test_2" }, @@ -116,9 +116,9 @@ def test_userstory_custom_attributes_values_create(client): client.login(member.user) response = client.json.post(url, json.dumps(data)) assert response.status_code == 201 - assert json.loads(response.data["values"]) == data["values"] + assert json.loads(response.data["attributes_values"]) == data["attributes_values"] user_story = user_story.__class__.objects.get(id=user_story.id) - assert user_story.custom_attributes_values.values == data["values"] + assert user_story.custom_attributes_values.attributes_values == data["attributes_values"] def test_userstory_custom_attributes_values_create_with_error_invalid_key(client): @@ -134,7 +134,7 @@ def test_userstory_custom_attributes_values_create_with_error_invalid_key(client url = reverse("userstory-custom-attributes-values-list") data = { "user_story": user_story.id, - "values": { + "attributes_values": { ct1_id: "test_1", "123456": "test_2" }, @@ -158,7 +158,7 @@ def test_userstory_custom_attributes_values_update(client): custom_attrs_val = f.UserStoryCustomAttributesValuesFactory( user_story=user_story, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, @@ -166,7 +166,7 @@ def test_userstory_custom_attributes_values_update(client): url = reverse("userstory-custom-attributes-values-detail", args=[user_story.id]) data = { - "values": { + "attributes_values": { ct1_id: "test_1_updated", ct2_id: "test_2_updated" }, @@ -176,9 +176,9 @@ def test_userstory_custom_attributes_values_update(client): client.login(member.user) response = client.json.patch(url, json.dumps(data)) assert response.status_code == 200 - assert json.loads(response.data["values"]) == data["values"] + assert json.loads(response.data["attributes_values"]) == data["attributes_values"] user_story = user_story.__class__.objects.get(id=user_story.id) - assert user_story.custom_attributes_values.values == data["values"] + assert user_story.custom_attributes_values.attributes_values == data["attributes_values"] def test_userstory_custom_attributes_values_update_with_error_invalid_key(client): @@ -194,7 +194,7 @@ def test_userstory_custom_attributes_values_update_with_error_invalid_key(client custom_attrs_val = f.UserStoryCustomAttributesValuesFactory( user_story=user_story, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, @@ -202,7 +202,7 @@ def test_userstory_custom_attributes_values_update_with_error_invalid_key(client url = reverse("userstory-custom-attributes-values-detail", args=[user_story.id]) data = { - "values": { + "attributes_values": { ct1_id: "test_1_updated", "123456": "test_2_updated" }, @@ -228,7 +228,7 @@ def test_userstory_custom_attributes_values_delete(client): url = reverse("userstory-custom-attributes-values-detail", args=[user_story.id]) custom_attrs_val = f.UserStoryCustomAttributesValuesFactory( user_story=user_story, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, @@ -255,7 +255,7 @@ def test_userstory_custom_attributes_values_delete_us(client): url = reverse("userstories-detail", args=[user_story.id]) custom_attrs_val = f.UserStoryCustomAttributesValuesFactory( user_story=user_story, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, @@ -284,19 +284,18 @@ def test_trigger_update_userstorycustomvalues_afeter_remove_userstorycustomattri ct2_id = "{}".format(custom_attr_2.id) custom_attrs_val = f.UserStoryCustomAttributesValuesFactory( - project=user_story.project, user_story=user_story, - values= { + attributes_values= { ct1_id: "test_1", ct2_id: "test_2" }, ) - assert ct1_id in custom_attrs_val.values.keys() - assert ct2_id in custom_attrs_val.values.keys() + assert ct1_id in custom_attrs_val.attributes_values.keys() + assert ct2_id in custom_attrs_val.attributes_values.keys() custom_attr_2.delete() custom_attrs_val = custom_attrs_val.__class__.objects.get(id=custom_attrs_val.id) - assert ct1_id in custom_attrs_val.values.keys() - assert ct2_id not in custom_attrs_val.values.keys() + assert ct1_id in custom_attrs_val.attributes_values.keys() + assert ct2_id not in custom_attrs_val.attributes_values.keys() diff --git a/tests/integration/test_importer_api.py b/tests/integration/test_importer_api.py index 5c654394..9cbb64c0 100644 --- a/tests/integration/test_importer_api.py +++ b/tests/integration/test_importer_api.py @@ -279,7 +279,7 @@ def test_valid_user_story_import_with_custom_attributes_values(client): assert response.status_code == 201 custom_attributes_values = apps.get_model("custom_attributes.UserStoryCustomAttributesValues").objects.get( user_story__subject=response.data["subject"]) - assert custom_attributes_values.values == {str(custom_attr.id): "test_value"} + assert custom_attributes_values.attributes_values == {str(custom_attr.id): "test_value"} def test_valid_issue_import_without_extra_data(client): @@ -329,7 +329,7 @@ def test_valid_issue_import_with_custom_attributes_values(client): assert response.status_code == 201 custom_attributes_values = apps.get_model("custom_attributes.IssueCustomAttributesValues").objects.get( issue__subject=response.data["subject"]) - assert custom_attributes_values.values == {str(custom_attr.id): "test_value"} + assert custom_attributes_values.attributes_values == {str(custom_attr.id): "test_value"} def test_valid_issue_import_with_extra_data(client): @@ -610,7 +610,7 @@ def test_valid_task_import_with_custom_attributes_values(client): assert response.status_code == 201 custom_attributes_values = apps.get_model("custom_attributes.TaskCustomAttributesValues").objects.get( task__subject=response.data["subject"]) - assert custom_attributes_values.values == {str(custom_attr.id): "test_value"} + assert custom_attributes_values.attributes_values == {str(custom_attr.id): "test_value"} def test_valid_task_import_with_extra_data(client):