Ejemplo n.º 1
0
 def test_post_value_onto_value(self):
     obj = self.objs["simple"]
     # number
     post(obj["path"] + "/name", 234).status(200)
     get(obj["path"] + "/name").status(200).equals(234)
     # string
     post(obj["path"] + "/name", "Jamie Alexandre").status(200)
     get(obj["path"] + "/name").status(200).equals("Jamie Alexandre")
Ejemplo n.º 2
0
 def test_post_value_onto_value(self):
     obj = self.objs["simple"]
     # number
     post(obj["path"] + "/name", 234).status(200)
     get(obj["path"] + "/name").status(200).equals(234)
     # string
     post(obj["path"] + "/name", "Jamie Alexandre").status(200)
     get(obj["path"] + "/name").status(200).equals("Jamie Alexandre")
Ejemplo n.º 3
0
 def test_post_object_onto_value(self):
     obj = self.objs["simple"]
     post(obj["path"] + "/name", {
         "first": "Jamie",
         "last": "Alexandre"
     }).status(200)
     get(obj["path"] + "/name").status(200).equals({
         "first": "Jamie",
         "last": "Alexandre"
     }).attrval("_id", None)
Ejemplo n.º 4
0
 def test_post_value_onto_array(self):
     obj = self.objs["complex"]
     old_array = get(obj["path"] + "/sections").body
     post(obj["path"] + "/sections", 17).status(200)
     post(obj["path"] + "/sections", "hello").status(200)
     get(obj["path"] + "/sections").contains(17).contains("hello")
     # check that only 2 items have been added
     new_array = get(obj["path"] + "/sections").body
     assert (
         len(new_array) == len(old_array) + 2
     ), "After adding 2 values, the length of the array went from %d to %d!" % (len(old_array), len(new_array))
Ejemplo n.º 5
0
 def test_post_value_onto_array(self):
     obj = self.objs["complex"]
     old_array = get(obj["path"] + "/sections").body
     post(obj["path"] + "/sections", 17).status(200)
     post(obj["path"] + "/sections", "hello").status(200)
     get(obj["path"] + "/sections").contains(17).contains("hello")
     # check that only 2 items have been added
     new_array = get(obj["path"] + "/sections").body
     assert len(new_array) == len(
         old_array
     ) + 2, "After adding 2 values, the length of the array went from %d to %d!" % (
         len(old_array), len(new_array))
Ejemplo n.º 6
0
 def test_put_object_onto_document(self):
     obj = self.objs["complex"]
     put(obj["path"], {"d": {"here": "?"}, "_id": dummy_id}).status(200)
     # check that the id didn't change
     get(obj["path"]).status(200).attrval("_id", obj["response"].body["_id"])
     # ensure that the value itself was set
     get(obj["path"] + "/d/here").status(200).equals("?")
     # ensure that it was a merge, not an overwrite
     get(obj["path"] + "/type").status(200).equals(obj["data"]["type"])
     # ensure that the merge was recursive
     get(obj["path"] + "/d/more").status(200).equals(obj["data"]["d"]["more"])
Ejemplo n.º 7
0
 def test_put_object_onto_object(self):
     obj = self.objs["embedded"]
     put(obj["path"] + "/a2", {"a2b1": {"a2b1c2": 17, "newkey": "hoi!"}}).status(200)
     # ensure that the value itself was updated
     get(obj["path"] + "/a2/a2b1/a2b1c2").status(200).equals(17)
     # ensure that the new field was added
     get(obj["path"] + "/a2/a2b1/newkey").status(200).equals("hoi!")
     # ensure that it was a merge, not an overwrite
     get(obj["path"] + "/a2/a2b2").status(200).equals(obj["data"]["a2"]["a2b2"])
     # ensure that the merge was recursive
     get(obj["path"] + "/a2/a2b1/a2b1c1").status(200).equals(obj["data"]["a2"]["a2b1"]["a2b1c1"])
Ejemplo n.º 8
0
 def test_put_object_onto_document(self):
     obj = self.objs["complex"]
     put(obj["path"], {"d": {"here": "?"}, "_id": dummy_id}).status(200)
     # check that the id didn't change
     get(obj["path"]).status(200).attrval("_id",
                                          obj["response"].body["_id"])
     # ensure that the value itself was set
     get(obj["path"] + "/d/here").status(200).equals("?")
     # ensure that it was a merge, not an overwrite
     get(obj["path"] + "/type").status(200).equals(obj["data"]["type"])
     # ensure that the merge was recursive
     get(obj["path"] + "/d/more").status(200).equals(
         obj["data"]["d"]["more"])
Ejemplo n.º 9
0
 def test_put_object_onto_object(self):
     obj = self.objs["embedded"]
     put(obj["path"] + "/a2", {
         "a2b1": {
             "a2b1c2": 17,
             "newkey": "hoi!"
         }
     }).status(200)
     # ensure that the value itself was updated
     get(obj["path"] + "/a2/a2b1/a2b1c2").status(200).equals(17)
     # ensure that the new field was added
     get(obj["path"] + "/a2/a2b1/newkey").status(200).equals("hoi!")
     # ensure that it was a merge, not an overwrite
     get(obj["path"] + "/a2/a2b2").status(200).equals(
         obj["data"]["a2"]["a2b2"])
     # ensure that the merge was recursive
     get(obj["path"] + "/a2/a2b1/a2b1c1").status(200).equals(
         obj["data"]["a2"]["a2b1"]["a2b1c1"])
Ejemplo n.º 10
0
 def test_post_object_onto_array(self):
     obj = self.objs["complex"]
     old_array = get(obj["path"] + "/sections").body
     # test with no specified _id
     _id = post(obj["path"] + "/sections", {"newstuff": 55}).status(200).hasfield("_id").body["_id"]
     get(obj["path"] + "/sections/" + _id).status(200).hasfield("_id").equals({"newstuff": 55})
     # test with _id specified
     _id = post(obj["path"] + "/sections", {"newobj": 34, "_id": dummy_id}).status(200).hasfield("_id").body["_id"]
     get(obj["path"] + "/sections/" + _id).status(200).id_changed().equals({"newobj": 34})
     # check that only 2 objects have been added
     new_array = get(obj["path"] + "/sections").body
     assert (
         len(new_array) == len(old_array) + 2
     ), "After adding 2 objects, the length of the array went from %d to %d!" % (len(old_array), len(new_array))
Ejemplo n.º 11
0
 def test_post_object_onto_object(self):
     obj = self.objs["embedded"]
     new_object = {"a2b1": {"a2b1c2": 17, "newkey": "hoi!"}}
     post(obj["path"] + "/a2", new_object).status(200)
     # ensure that the object was saved
     get(obj["path"] + "/a2").status(200).equals(new_object)
     # ensure that other parts of the document were not affected
     get(obj["path"] + "/a1").status(200).equals(obj["data"]["a1"])
     # post onto an object with _id, inside an array
     obj = self.objs["complex"]
     old_object = obj["response"].body["sections"][0]
     new_object = {"g": 92, "_id": dummy_id}
     post(obj["path"] + "/sections/" + old_object["_id"], new_object).status(200)
     get(obj["path"] + "/sections/" + old_object["_id"]).status(200).equals(new_object).attrval(
         "_id", old_object["_id"]
     )
Ejemplo n.º 12
0
 def test_post_object_onto_object(self):
     obj = self.objs["embedded"]
     new_object = {"a2b1": {"a2b1c2": 17, "newkey": "hoi!"}}
     post(obj["path"] + "/a2", new_object).status(200)
     # ensure that the object was saved
     get(obj["path"] + "/a2").status(200).equals(new_object)
     # ensure that other parts of the document were not affected
     get(obj["path"] + "/a1").status(200).equals(obj["data"]["a1"])
     # post onto an object with _id, inside an array
     obj = self.objs["complex"]
     old_object = obj["response"].body["sections"][0]
     new_object = {"g": 92, "_id": dummy_id}
     post(obj["path"] + "/sections/" + old_object["_id"],
          new_object).status(200)
     get(obj["path"] + "/sections/" +
         old_object["_id"]).status(200).equals(new_object).attrval(
             "_id", old_object["_id"])
Ejemplo n.º 13
0
 def test_post_object_onto_array(self):
     obj = self.objs["complex"]
     old_array = get(obj["path"] + "/sections").body
     # test with no specified _id
     _id = post(obj["path"] + "/sections", {
         "newstuff": 55
     }).status(200).hasfield("_id").body["_id"]
     get(obj["path"] + "/sections/" +
         _id).status(200).hasfield("_id").equals({"newstuff": 55})
     # test with _id specified
     _id = post(obj["path"] + "/sections", {
         "newobj": 34,
         "_id": dummy_id
     }).status(200).hasfield("_id").body["_id"]
     get(obj["path"] + "/sections/" + _id).status(200).id_changed().equals(
         {"newobj": 34})
     # check that only 2 objects have been added
     new_array = get(obj["path"] + "/sections").body
     assert len(new_array) == len(
         old_array
     ) + 2, "After adding 2 objects, the length of the array went from %d to %d!" % (
         len(old_array), len(new_array))
Ejemplo n.º 14
0
 def test_post_object_onto_collection(self):
     # we've already created objects in setUp, so just make sure they're accurate
     for obj in self.objs.values():
         get(obj["path"]).status(200).equals(obj["data"]).id_changed()
Ejemplo n.º 15
0
 def test_post_object_onto_document(self):
     for obj in self.objs.values():
         post(obj["path"], {"new": 33}).status(200)
         get(obj["path"]).equals({"new": 33}).attrval("_id", obj["id"])
Ejemplo n.º 16
0
 def test_delete_value(self):
     obj = self.objs["simple"]
     get(obj["path"] + "/name").status(200)
     delete(obj["path"] + "/name").status(200)
     get(obj["path"] + "/name").status(404)
     get(obj["path"] + "/nums").status(200)
Ejemplo n.º 17
0
 def test_get_nonexistent_returns_404(self):
     get("/testingbadcollectionname").status(404)
     get(collection_path + "001001001001001001001001/").status(404)
Ejemplo n.º 18
0
 def test_delete_array(self):
     obj = self.objs["complex"]
     get(obj["path"] + "/sections").status(200)
     delete(obj["path"] + "/sections").status(200)
     get(obj["path"] + "/sections").status(404)
Ejemplo n.º 19
0
 def test_delete_object(self):
     # delete an object at a key
     obj = self.objs["embedded"]
     get(obj["path"] + "/a1").status(200)
     delete(obj["path"] + "/a1").status(200)
     get(obj["path"] + "/a1").status(404)
     get(obj["path"] + "/a2").status(200)
     # delete an object in an array
     obj = self.objs["complex"]
     _id = obj["response"].body["sections"][0]["_id"]
     _id2 = obj["response"].body["sections"][1]["_id"]
     get(obj["path"] + "/sections/" + _id).status(200)
     delete(obj["path"] + "/sections/" + _id).status(200)
     get(obj["path"] + "/sections/" + _id).status(404)
     get(obj["path"] + "/sections/" + _id2).status(200)
Ejemplo n.º 20
0
 def test_delete_document(self):
     obj = self.objs["embedded"]
     get(obj["path"]).status(200)
     delete(obj["path"]).status(200)
     get(obj["path"]).status(404)
Ejemplo n.º 21
0
 def test_post_object_onto_document(self):
     for obj in self.objs.values():
         post(obj["path"], {"new": 33}).status(200)
         get(obj["path"]).equals({"new": 33}).attrval("_id", obj["id"])
Ejemplo n.º 22
0
 def test_delete_object(self):
     # delete an object at a key
     obj = self.objs["embedded"]
     get(obj["path"] + "/a1").status(200)
     delete(obj["path"] + "/a1").status(200)
     get(obj["path"] + "/a1").status(404)
     get(obj["path"] + "/a2").status(200)
     # delete an object in an array
     obj = self.objs["complex"]
     _id = obj["response"].body["sections"][0]["_id"]
     _id2 = obj["response"].body["sections"][1]["_id"]
     get(obj["path"] + "/sections/" + _id).status(200)
     delete(obj["path"] + "/sections/" + _id).status(200)
     get(obj["path"] + "/sections/" + _id).status(404)
     get(obj["path"] + "/sections/" + _id2).status(200)
Ejemplo n.º 23
0
 def test_delete_array(self):
     obj = self.objs["complex"]
     get(obj["path"] + "/sections").status(200)
     delete(obj["path"] + "/sections").status(200)
     get(obj["path"] + "/sections").status(404)
Ejemplo n.º 24
0
 def test_post_array_onto_value(self):
     obj = self.objs["simple"]
     post(obj["path"] + "/name", ["Jamie", "Alexandre"]).status(200)
     get(obj["path"] + "/name").status(200).equals(["Jamie", "Alexandre"])
Ejemplo n.º 25
0
 def test_delete_value(self):
     obj = self.objs["simple"]
     get(obj["path"] + "/name").status(200)
     delete(obj["path"] + "/name").status(200)
     get(obj["path"] + "/name").status(404)
     get(obj["path"] + "/nums").status(200)
Ejemplo n.º 26
0
 def test_get_nonexistent_returns_404(self):
     get("/testingbadcollectionname").status(404)
     get(collection_path + "001001001001001001001001/").status(404)
Ejemplo n.º 27
0
 def test_post_array_onto_value(self):
     obj = self.objs["simple"]
     post(obj["path"] + "/name", ["Jamie", "Alexandre"]).status(200)
     get(obj["path"] + "/name").status(200).equals(["Jamie", "Alexandre"])
Ejemplo n.º 28
0
 def test_delete_document(self):
     obj = self.objs["embedded"]
     get(obj["path"]).status(200)
     delete(obj["path"]).status(200)
     get(obj["path"]).status(404)
Ejemplo n.º 29
0
 def test_post_array_onto_array(self):
     obj = self.objs["complex"]
     post(obj["path"] + "/sections", ["a", "b"]).status(200)
     get(obj["path"] + "/sections").status(200).equals(["a", "b"])
Ejemplo n.º 30
0
 def test_post_object_onto_collection(self):
     # we've already created objects in setUp, so just make sure they're accurate
     for obj in self.objs.values():
         get(obj["path"]).status(200).equals(obj["data"]).id_changed()
Ejemplo n.º 31
0
 def test_post_object_onto_value(self):
     obj = self.objs["simple"]
     post(obj["path"] + "/name", {"first": "Jamie", "last": "Alexandre"}).status(200)
     get(obj["path"] + "/name").status(200).equals({"first": "Jamie", "last": "Alexandre"}).attrval("_id", None)
Ejemplo n.º 32
0
 def test_post_array_onto_array(self):
     obj = self.objs["complex"]
     post(obj["path"] + "/sections", ["a", "b"]).status(200)
     get(obj["path"] + "/sections").status(200).equals(["a", "b"])