'attempts to change one-time-keys should be rejected'

@defer.inlineCallbacks
def test_change_one_time_keys(self):

    local_user = ('@boris:' + self.hs.hostname)
    device_id = 'xyz'
    keys = {'alg1:k1': 'key1', 'alg2:k2': {'key': 'key2', 'signatures': {'k1': 'sig1'}}, 'alg2:k3': {'key': 'key3'}}
    res = (yield self.handler.upload_keys_for_user(local_user, device_id, {'one_time_keys': keys}))
    self.assertDictEqual(res, {'one_time_key_counts': {'alg1': 1, 'alg2': 2}})
    try:
        (yield self.handler.upload_keys_for_user(local_user, device_id, {'one_time_keys': {'alg1:k1': 'key2'}}))
        self.fail('No    error    when    changing    string    key')
    except errors.SynapseError:
        pass
    try:
        (yield self.handler.upload_keys_for_user(local_user, device_id, {'one_time_keys': {'alg2:k3': 'key2'}}))
        self.fail('No    error    when    replacing    dict    key    with    string')
    except errors.SynapseError:
        pass
    try:
        (yield self.handler.upload_keys_for_user(local_user, device_id, {'one_time_keys': {'alg1:k1': {'key': 'key'}}}))
        self.fail('No    error    when    replacing    string    key    with    dict')
    except errors.SynapseError:
        pass
    try:
        (yield self.handler.upload_keys_for_user(local_user, device_id, {'one_time_keys': {'alg2:k2': {'key': 'key3', 'signatures': {'k1': 'sig1'}}}}))
        self.fail('No    error    when    replacing    dict    key')
    except errors.SynapseError:
        pass
