mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
Merge pull request #962 from ryanpetrello/fix-7843
fix a unicode handling bug
This commit is contained in:
commit
9431b0b6ff
@ -8,6 +8,7 @@ import re
|
||||
import copy
|
||||
from urlparse import urljoin
|
||||
import os.path
|
||||
import six
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
@ -1447,7 +1448,7 @@ class InventorySource(UnifiedJobTemplate, InventorySourceOptions):
|
||||
if '_eager_fields' not in kwargs:
|
||||
kwargs['_eager_fields'] = {}
|
||||
if 'name' not in kwargs['_eager_fields']:
|
||||
name = '{} - {}'.format(self.inventory.name, self.name)
|
||||
name = six.text_type('{} - {}').format(self.inventory.name, self.name)
|
||||
name_field = self._meta.get_field('name')
|
||||
if len(name) > name_field.max_length:
|
||||
name = name[:name_field.max_length]
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pytest
|
||||
import mock
|
||||
import six
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
@ -156,6 +159,14 @@ def test_inventory_update_name(inventory, inventory_source):
|
||||
assert iu.name == inventory.name + ' - ' + inventory_source.name
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_inventory_name_with_unicode(inventory, inventory_source):
|
||||
inventory.name = six.u('オオオ')
|
||||
inventory.save()
|
||||
iu = inventory_source.update()
|
||||
assert iu.name.startswith(inventory.name)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_inventory_update_excessively_long_name(inventory, inventory_source):
|
||||
inventory.name = 'a' * 400 # field max length 512
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user