

def _test_create_resource(self, resource, cmd, name, myid, args, position_names, position_values, tenant_id=None, tags=None, admin_state_up=True, extra_body=None, cmd_resource=None, parent_id=None, **kwargs):
    self.mox.StubOutWithMock(cmd, 'get_client')
    self.mox.StubOutWithMock(self.client.httpclient, 'request')
    cmd.get_client().MultipleTimes().AndReturn(self.client)
    if (not cmd_resource):
        cmd_resource = resource
    body = {
        resource: {
            
        },
    }
    if tenant_id:
        body[resource].update({
            'tenant_id': tenant_id,
        })
    if tags:
        body[resource].update({
            'tags': tags,
        })
    if extra_body:
        body[resource].update(extra_body)
    body[resource].update(kwargs)
    for i in range(len(position_names)):
        body[resource].update({
            position_names[i]: _str[i],
        })
    ress = {
        resource: {
            self.id_field: myid,
        },
    }
    if name:
        ress[resource].update({
            'name': name,
        })
    self.client.format = self.format
    resstr = self.client.serialize(ress)
    resource_plural = gbpV2_0._get_resource_plural(cmd_resource, self.client)
    path = getattr(self.client, (resource_plural + '_path'))
    if parent_id:
        path = (path % parent_id)
    if (self.format == 'json'):
        mox_body = MyComparator(body, self.client)
    else:
        mox_body = self.client.serialize(body)
    self.client.httpclient.request(end_url(path, format=self.format), 'POST', body=mox_body, headers=mox.ContainsKeyValue('X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr))
    args.extend(['--request-format', self.format])
    self.mox.ReplayAll()
    cmd_parser = cmd.get_parser(('create_' + resource))
    gbpshell.run_command(cmd, cmd_parser, args)
    self.mox.VerifyAll()
    self.mox.UnsetStubs()
    _str = self.fake_stdout.make_string()
    self.assertIn(myid, _str)
    if name:
        self.assertIn(name, _str)

dataset/ETHPy150Open openstack/python-group-based-policy-client/gbpclient/tests/unit/test_cli20.py CLITestV20Base._test_create_resource/VarMisuse@220/287 `position_values`->`_str`