def test_set_issue_extended_field_value_from_model_obj(self):
    self.client.force_authenticate(user=get_user_model().objects.get(username='app_owner_user'))
    url = reverse('issueextfields-list', kwargs={'task_id': 1})
    self.client.post(url, {'name': '广场'})
    self.client.post(url, {'name': '手机型号', 'isOptional': True, 'default': 'iPhone', 'type': 'string'})
    response = self.client.post(reverse('issues-list'), {'priority': '紧急', 'appId': 1, 'taskId': 1, 'statusId': 1, 'title': 'aaaa', 'detail': 'bbbb', 'extFields': {'广场': '通州万达', '手机型号': '华为'}}, format='json')
    issue_id = response.data['data']['id']
    issue_obj = Issue.objects.get(id=issue_id)
    self.assertTrue(issue_obj.set_ext_field_value('广场', '瞎写的广场'))
    self.assertEqual('瞎写的广场', issue_obj.get_ext_field_value('广场'))
    self.assertEqual('华为', issue_obj.get_ext_field_value('手机型号'))
    self.assertTrue(issue_obj.set_ext_field_value('手机型号', '瞎写的手机型号'))
    self.assertEqual('瞎写的手机型号', issue_obj.get_ext_field_value('手机型号'))
    self.assertFalse(issue_obj.set_ext_field_value('瞎写的字段', 'aaa'))
def test_set_issue_extended_field_value_from_model_obj(self):
    self.client.force_authenticate(user=get_user_model().objects.get(username='app_owner_user'))
    url = reverse('issueextfields-list', kwargs={'task_id': 1})
    self.client.post(url, {'name': '广场'})
    self.client.post(url, {'name': '手机型号', 'isOptional': True, 'default': 'iPhone', 'type': 'string'})
    response = self.client.post(reverse('issues-list'), {'priority': '紧急', 'appId': 1, 'taskId': 1, 'statusId': 1, 'title': 'aaaa', 'detail': 'bbbb', 'extFields': {'广场': '通州万达', '手机型号': '华为'}}, format='json')
    issue_id = response.data['data']['id']
    issue_obj = Issue.objects.get(id=issue_id)
    self.assertTrue(issue_obj.set_ext_field_value('广场', '瞎写的广场'))
    self.assertEqual('瞎写的广场', issue_obj.get_ext_field_value('广场'))
    self.assertEqual('华为', issue_obj.get_ext_field_value('手机型号'))
    self.assertTrue(issue_obj.set_ext_field_value('手机型号', '瞎写的手机型号'))
    self.assertEqual('瞎写的手机型号', issue_obj.get_ext_field_value('手机型号'))
    self.assertFalse(issue_obj.set_ext_field_value('瞎写的字段', 'aaa'))