def test_do_host_create_ignores_unknown_fields(self, mock_create):
     """Verify that do host create ignores unknown field."""
     client = mock.Mock()
     inventory = mock.Mock()
     inventory.hosts = hosts.HostManager(mock.ANY, mock.ANY,
                                         'http://127.0.0.1/')
     client.inventory = mock.Mock(name='inventory')
     client.inventory.return_value = inventory
     hosts_shell.do_host_create(client, self.host_invalid_field)
     mock_create.assert_called_once_with(**vars(self.host_valid_fields))
 def test_do_host_delete_calls_host_manager_with_fields(self, mock_delete):
     """Verify that do host update calls HostManager create."""
     client = mock.Mock()
     inventory = mock.Mock()
     inventory.hosts = hosts.HostManager(mock.ANY, mock.ANY,
                                         'http://127.0.0.1/')
     client.inventory = mock.Mock(name='inventory')
     client.inventory.return_value = inventory
     test_args = Namespace(id=1, region=1)
     hosts_shell.do_host_delete(client, test_args)
     mock_delete.assert_called_once_with(vars(test_args)['id'])
 def test_do_host_update_calls_host_manager_with_fields(self, mock_update):
     """Verify that do host update calls HostManager create."""
     client = mock.Mock()
     inventory = mock.Mock()
     inventory.hosts = hosts.HostManager(mock.ANY, mock.ANY,
                                         'http://127.0.0.1/')
     client.inventory = mock.Mock(name='inventory')
     client.inventory.return_value = inventory
     valid_input = Namespace(region=1, id=1, name='mock_host')
     hosts_shell.do_host_update(client, valid_input)
     vars(valid_input).pop('region')
     mock_update.assert_called_once_with(**vars(valid_input))
    def __init__(self, session, url, region_id):
        """Initialize our client object with our session and url.

        :param session:
            Initialized Session object.
        :type session:
            cratonclient.session.Session
        :param str url:
            The URL that points us to the craton instance. For example,
            'https://10.1.1.0:8080/'.
        """
        # TODO(cmspence): self.region = self.regions.get(region=region_id)
        self.hosts = hosts.HostManager(region_id, session, url)
        self.cells = cells.CellManager(region_id, session, url)
 def test_do_host_update_ignores_unknown_fields(self, mock_update):
     """Verify that do host create ignores unknown field."""
     client = mock.Mock()
     inventory = mock.Mock()
     inventory.hosts = hosts.HostManager(mock.ANY, mock.ANY,
                                         'http://127.0.0.1/')
     client.inventory = mock.Mock(name='inventory')
     client.inventory.return_value = inventory
     invalid_input = Namespace(region=1,
                               id=1,
                               name='mock_host',
                               invalid=True)
     hosts_shell.do_host_update(client, invalid_input)
     vars(invalid_input).pop('region')
     vars(invalid_input).pop('invalid')
     mock_update.assert_called_once_with(**vars(invalid_input))