Skip to content

Commit

Permalink
Ensure TextIt flow titles can be updated
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisRayM committed May 25, 2021
1 parent 1a43bcc commit a460f89
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,34 @@ def test_update(self):
"xform": self.xform.pk,
"auth_token": "sadsdfhsdf",
"flow_uuid": "sdfskhfskdjhfs",
"contacts": "ksadaskjdajsda"
"contacts": "ksadaskjdajsda",
"flow_title": "test-flow"
}

request = self.factory.put('/', data=post_data, **self.extra)
response = self.view(request, pk=rest.pk)

self.assertEquals(response.status_code, 200)
self.assertEquals(response.data['name'], "textit")
self.assertEqual(response.data['flow_title'], 'test-flow')
metadata_count = MetaData.objects.count()

# Flow title can be updated
put_data = {
'flow_title': 'new-name',
'xform': self.xform.pk,
'name': 'textit',
'service_url': 'https://textit.io',
'auth_token': 'sadsdfhsdf',
'flow_uuid': 'sdfskhfskdjhfs',
'contacts': 'ksadaskjdajsda',
}
request = self.factory.put('/', data=put_data, **self.extra)
response = self.view(request, pk=rest.pk)

self.assertEqual(response.status_code, 200, response.data)
self.assertEqual(response.data['flow_title'], 'new-name')
self.assertEqual(MetaData.objects.count(), metadata_count)

def test_update_with_errors(self):
rest = self._create_textit_service()
Expand Down
2 changes: 1 addition & 1 deletion onadata/libs/serializers/textit_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def update(self, instance, validated_data):

instance = TextItService(xform, service_url, name, auth_token,
flow_uuid, contacts, instance.pk,
flow_title=instance.flow_title)
flow_title=validated_data.get('flow_title'))
instance.save()

return instance
Expand Down

0 comments on commit a460f89

Please sign in to comment.