Ejemplo n.º 1
0
    def _create(cls, model_class, *args, **kwargs):
        os_server_fixture = kwargs.pop('os_server_fixture', None)
        server = super()._create(model_class, *args, **kwargs)

        # This isn't a model field, so it needs to be set separately, not passed to the model `__init__`
        server.nova = Mock()

        # Allow to set OpenStack API data for the current `self.os_server`, using fixtures
        if os_server_fixture is not None:
            add_fixture_to_object(server.nova.servers.get.return_value, os_server_fixture)

        return server
Ejemplo n.º 2
0
    def _create(cls, model_class, *args, **kwargs):
        os_server_fixture = kwargs.pop('os_server_fixture', None)
        server = super()._create(model_class, *args, **kwargs)

        # This isn't a model field, so it needs to be set separately, not passed to the model `__init__`
        server.nova = Mock()

        # Allow to set OpenStack API data for the current `self.os_server`, using fixtures
        if os_server_fixture is not None:
            add_fixture_to_object(server.nova.servers.get.return_value, os_server_fixture)

        return server
Ejemplo n.º 3
0
 def add_fixture(self, openstack_id, fixture_filename):
     """
     Add the contents of a fixture to the mock `os_server` attributes for this `openstack_id`
     """
     add_fixture_to_object(self.get_os_server(openstack_id), fixture_filename)
Ejemplo n.º 4
0
 def add_fixture(self, openstack_id, fixture_filename):
     """
     Add the contents of a fixture to the mock `os_server` attributes for this `openstack_id`
     """
     add_fixture_to_object(self.get_os_server(openstack_id), fixture_filename)