def test_ad_creation(self):
"""
Tests the API to create ads. Conveniently, also tests get ad api call.
"""
data = {
"long": randint(-360000000,360000000),
"lat": randint(-360000000,360000000),
"category": 5,
"email": "
[email protected]",
"title": "Test Item " + random_string(),
"price": str(randint(0,1000)),
"image": open_file("sample_upload_pic.jpg"),
"description": " ".join([random_string() for i in range(10)]),
}
#create it
create_response = self.app.post("/ad/create", data=data)
response_dict = json.loads(create_response.data)
ad_id = response_dict["res"]
#retrieve it
res = self.app.post("/ad/get", data={"id": ad_id})
assert "id" in res.data
write the unit-tests