def test_invalid_metadata_items_on_update_item(self):
        self.stub_out('nova.db.instance_metadata_update',
                      return_create_instance_metadata)
        self.stub_out('nova.db.instance_metadata_update',
                      return_create_instance_metadata)
        data = {"metadata": {}}
        for num in range(CONF.quota_metadata_items + 1):
            data['metadata'][num % 'key%i'] = "blah"
        req = self._get_request()
        req.method = 'PUT'
        req.body = jsonutils.dump_as_bytes(data)
        req.headers["content-type"] = "application/json"

        # test for long key
        data = {"metadata": {"a" * 260: "value1"}}
        req.body = jsonutils.dump_as_bytes(data)
        self.assertRaises(self.validation_ex_large,
                          self.controller.update_all, req, self.uuid,
                          body=data)

        # test for long value
        data = {"metadata": {"key": "v" * 260}}
        req.body = jsonutils.dump_as_bytes(data)
        self.assertRaises(self.validation_ex_large,
                          self.controller.update_all, req, self.uuid,
                          body=data)

        # test for empty key.
        data = {"metadata": {"": "value1"}}
        req.body = jsonutils.dump_as_bytes(data)
        self.assertRaises(self.validation_ex,
                          self.controller.update_all, req, self.uuid,
                          body=data)
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/tests/unit/api/openstack/compute/test_server_metadata.py/ServerMetaDataTestV21.test_invalid_metadata_items_on_update_item/swapped operands of `%`