dkayiwa
(Daniel Kayiwa)
September 16, 2021, 2:22pm
6
@sharif here is an example of tests in that spreadsheet that already exist in the module:
patient_search
Sheet1
S.No,Category,Endpoint Verb (GET/POST/PUT/DELETE),Endpoint URI,Tested By,Tested On,Result (Pass/Fail),Remarks
1,person_search,GET,GET http://localhost:8087/openmrs/ws/rest/v1/person?q=Mohit...
@Test
public void shouldGetAPatientByUuid() throws Exception {
MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid());
SimpleObject result = deserialize(handle(req));
Patient patient = service.getPatientByUuid(getUuid());
assertEquals(patient.getUuid(), PropertyUtils.getProperty(result, "uuid"));
assertNotNull(PropertyUtils.getProperty(result, "identifiers"));
assertNotNull(PropertyUtils.getProperty(result, "person"));
assertNull(PropertyUtils.getProperty(result, "auditInfo"));
}
patient_create
Sheet1
S.No,Category,Endpoint Verb (GET/POST/PUT/DELETE),Endpoint URI,Tested By,Tested On,Result (Pass/Fail),Remarks
1,person_search,GET,GET http://localhost:8087/openmrs/ws/rest/v1/person?q=Mohit...
@Test
public void shouldCreateAPatient() throws Exception {
long originalCount = service.getAllPatients().size();
String json = "{ \"person\": \"ba1b19c2-3ed6-4f63-b8c0-f762dc8d7562\", "
+ "\"identifiers\": [{ \"identifier\":\"abc123ez\", "
+ "\"identifierType\":\"2f470aa8-1d73-43b7-81b5-01f0c0dfa53c\", "
+ "\"location\":\"9356400c-a5a2-4532-8f2b-2361b3446eb8\", " + "\"preferred\": true }] }";
SimpleObject newPatient = deserialize(handle(newPostRequest(getURI(), json)));
assertNotNull(PropertyUtils.getProperty(newPatient, "uuid"));
assertEquals(originalCount + 1, service.getAllPatients().size());
}
And those tests run automatically for each pull request.
It is basing on the above that i conclude that our efforts are better spent on ensuring that each of the tests in that spreadsheet has a corresponding test in the module.
2 Likes