def test_extend_object_field_not_list(self):
     base_obj = k8s.V1Container(name='base_container', image='image')
     client_obj = k8s.V1Container(name='client_container')
     with pytest.raises(ValueError):
         extend_object_field(base_obj, client_obj, 'image')
     base_obj = k8s.V1Container(name='base_container')
     client_obj = k8s.V1Container(name='client_container', image='image')
     with pytest.raises(ValueError):
         extend_object_field(base_obj, client_obj, 'image')
    def test_extend_object_field_empty(self):
        ports = [k8s.V1ContainerPort(container_port=1, name='port')]
        base_obj = k8s.V1Container(name='base_container', ports=ports)
        client_obj = k8s.V1Container(name='client_container')
        res = extend_object_field(base_obj, client_obj, 'ports')
        client_obj.ports = ports
        assert client_obj == res

        base_obj = k8s.V1Container(name='base_container')
        client_obj = k8s.V1Container(name='base_container', ports=ports)
        res = extend_object_field(base_obj, client_obj, 'ports')
        assert client_obj == res
Пример #3
0
 def test_extend_object_field(self):
     base_ports = [k8s.V1ContainerPort(container_port=1, name='base_port')]
     base_obj = k8s.V1Container(name='base_container', ports=base_ports)
     client_ports = [k8s.V1ContainerPort(container_port=1, name='client_port')]
     client_obj = k8s.V1Container(name='client_container', ports=client_ports)
     res = extend_object_field(base_obj, client_obj, 'ports')
     client_obj.ports = base_ports + client_ports
     self.assertEqual(client_obj, res)