def test_create_duplicate_entry(self): """ Tests entry creation """ key = "foo" value = "bar" event = gen_event(key, [value]) res = create(event, None) self.assertEquals(201, res['statusCode']) data = json.loads(res["body"]) self.assertEquals(data, {"key": key, "value": [value]}) res2 = create(event, None) self.assertEquals(201, res2['statusCode']) data2 = json.loads(res["body"]) self.assertEquals(data2, {"key": key, "value": [value]})
def test_create_nonstring_key(self): key = 1 value = ["bar"] event = gen_event(key, value) res = create(event, None) self.assertEquals(res["statusCode"], 422) data = json.loads(res["body"]) self.assertEquals(data["error_message"], "key: Key must be a string")
def test_create_nonlist_value(self): key = "foo" value = "bar" event = gen_event(key, value) res = create(event, None) self.assertEquals(res["statusCode"], 422) data = json.loads(res["body"]) self.assertEquals(data["error_message"], "value: 'value' must be a list of strings")