Merge branch 'develop' into hosting_i18n
This commit is contained in:
commit
88393c3da7
2 changed files with 12 additions and 1 deletions
|
@ -79,7 +79,7 @@ class VirtualMachineTemplateSerializer(serializers.Serializer):
|
|||
class VirtualMachineSerializer(serializers.Serializer):
|
||||
"""Serializer to map the virtual machine instance into JSON format."""
|
||||
|
||||
name = serializers.CharField(read_only=True)
|
||||
name = serializers.SerializerMethodField()
|
||||
cores = serializers.IntegerField(source='template.vcpu')
|
||||
disk = serializers.IntegerField(write_only=True)
|
||||
set_memory = serializers.IntegerField(write_only=True, label='Memory')
|
||||
|
@ -164,6 +164,8 @@ class VirtualMachineSerializer(serializers.Serializer):
|
|||
nic = obj.template.nics[0]
|
||||
return nic.ip6_global
|
||||
|
||||
def get_name(self, obj):
|
||||
return obj.name.strip('public-')
|
||||
|
||||
def hexstr2int(string):
|
||||
return int(string.replace(':', ''), 16)
|
||||
|
|
|
@ -114,6 +114,15 @@ class VirtualMachineTestCase(TestCase):
|
|||
self.virtualmachine = VirtualMachine(opennebula_id=self.opennebula_id,
|
||||
template=self.template)
|
||||
|
||||
def test_serializer_strips_of_public(self):
|
||||
""" Test the serialized object contains no 'public-'."""
|
||||
|
||||
template = self.manager.get_templates().first()
|
||||
serialized = VirtualMachineTemplateSerializer(template)
|
||||
self.assertEqual(serialized.data.name, template.name.strip('public-'))
|
||||
|
||||
|
||||
|
||||
def test_model_can_create_a_virtualmachine(self):
|
||||
"""Test the virtualmachine model can create a virtualmachine."""
|
||||
old_count = VirtualMachine.objects.count()
|
||||
|
|
Loading…
Reference in a new issue