Skip to content

Commit

Permalink
[ODS-5921] Postman test coverage for Contacts (after renamed from Par…
Browse files Browse the repository at this point in the history
…ent in the standard) (#802)

* Update postman tests to use new env variables

* Update Postman colections to use contact/parent variables in requests

* Remove 'Parent' from names in the postman collection

* Remove more 'Parent' occurances from postman collections

* Update postman collection to use new parent/contact variables

* Fix tests in postman collection

* Update change-query Postman collection

* Update authorization tests Postman collection

* Postman test fixes

* More changes to postman collections

* Remove unneeded changes

* Refactor to only require a single new value in environment.json
  • Loading branch information
mjaksn authored Aug 8, 2023
1 parent 87c5906 commit 764c448
Show file tree
Hide file tree
Showing 6 changed files with 500 additions and 429 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9925,7 +9925,7 @@
]
},
{
"name": "Students and Parents",
"name": "Students and Contacts",
"item": [
{
"name": "Initialization",
Expand Down Expand Up @@ -10101,7 +10101,7 @@
"response": []
},
{
"name": "Create Parent",
"name": "Create Parent or Contact",
"event": [
{
"listen": "prerequest",
Expand All @@ -10117,7 +10117,7 @@
"script": {
"exec": [
"pm.test(\"Response is 201 or 404\", () => {\r",
" pm.expect(pm.response.code).to.be.oneOf([201, 404]) \r",
" pm.expect(pm.response.code).to.equal(201) \r",
" });\r",
"\r",
"if (pm.response.code === 201 ) {\r",
Expand All @@ -10133,23 +10133,23 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"parentUniqueId\": \"{{supplied:parentUniqueId}}\",\r\n \"birthDate\": \"1988-09-13\",\r\n \"firstName\": \"John\",\r\n \"lastSurname\": \"Doe\",\r\n \"_ext\": {\r\n \"Sample\": {\r\n \"teacherConference\": {\r\n \"dayOfWeek\": \"Monday\",\r\n \"endTime\": \"12:00:00\",\r\n \"startTime\": \"12:00:00\"\r\n },\r\n \"authors\": [],\r\n \"favoriteBookTitles\": [\r\n {\r\n \"favoriteBookTitle\": \"Green Eggs and Ham\"\r\n }\r\n ],\r\n \"isSportsFan\": false\r\n }\r\n }\r\n}",
"raw": "{\r\n \"{{ParentOrContactUniqueIdName}}\": \"{{supplied:parentUniqueId}}\",\r\n \"birthDate\": \"1988-09-13\",\r\n \"firstName\": \"John\",\r\n \"lastSurname\": \"Doe\",\r\n \"_ext\": {\r\n \"Sample\": {\r\n \"teacherConference\": {\r\n \"dayOfWeek\": \"Monday\",\r\n \"endTime\": \"12:00:00\",\r\n \"startTime\": \"12:00:00\"\r\n },\r\n \"authors\": [],\r\n \"favoriteBookTitles\": [\r\n {\r\n \"favoriteBookTitle\": \"Green Eggs and Ham\"\r\n }\r\n ],\r\n \"isSportsFan\": false\r\n }\r\n }\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/parents",
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/{{ParentOrContactCollectionName}}",
"host": [
"{{ApiBaseUrl}}"
],
"path": [
"data",
"v3",
"ed-fi",
"parents"
"{{ParentOrContactCollectionName}}"
]
}
},
Expand Down Expand Up @@ -10210,7 +10210,7 @@
"response": []
},
{
"name": "Create Student Parent Association",
"name": "Create Student Parent or Contact Association",
"event": [
{
"listen": "prerequest",
Expand All @@ -10226,7 +10226,7 @@
"script": {
"exec": [
"pm.test(\"Response is 201 or 404\", () => {\r",
" pm.expect(pm.response.code).to.be.oneOf([201, 404]) \r",
" pm.expect(pm.response.code).to.equal(201) \r",
" });\r",
"\r",
"if (pm.response.code === 201 ) {\r",
Expand All @@ -10242,23 +10242,23 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"parentReference\": {\r\n \"parentUniqueId\": \"{{supplied:parentUniqueId}}\"\r\n },\r\n \"studentReference\": {\r\n \"studentUniqueId\": \"{{supplied:studentUniqueId}}\"\r\n },\r\n \"_ext\": {\r\n \"Sample\": {\r\n \"bedtimeReader\": true,\r\n \"favoriteBookTitles\": [\r\n {\r\n \"favoriteBookTitle\": \"Green Eggs and Ham\"\r\n }\r\n ],\r\n \"telephone\": {\r\n \"telephoneNumber\": \"12345\",\r\n \"telephoneNumberTypeDescriptor\": \"uri://ed-fi.org/TelephoneNumberTypeDescriptor#Other\"\r\n }\r\n }\r\n }\r\n}",
"raw": "{\r\n \"{{ParentOrContactName}}Reference\": {\r\n \"{{ParentOrContactUniqueIdName}}\": \"{{supplied:parentUniqueId}}\"\r\n },\r\n \"studentReference\": {\r\n \"studentUniqueId\": \"{{supplied:studentUniqueId}}\"\r\n },\r\n \"_ext\": {\r\n \"Sample\": {\r\n \"bedtimeReader\": true,\r\n \"favoriteBookTitles\": [\r\n {\r\n \"favoriteBookTitle\": \"Green Eggs and Ham\"\r\n }\r\n ],\r\n \"telephone\": {\r\n \"telephoneNumber\": \"12345\",\r\n \"telephoneNumberTypeDescriptor\": \"uri://ed-fi.org/TelephoneNumberTypeDescriptor#Other\"\r\n }\r\n }\r\n }\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/studentParentAssociations",
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/{{StudentParentOrContactAssociationCollectionName}}",
"host": [
"{{ApiBaseUrl}}"
],
"path": [
"data",
"v3",
"ed-fi",
"studentParentAssociations"
"{{StudentParentOrContactAssociationCollectionName}}"
]
}
},
Expand Down Expand Up @@ -10328,10 +10328,10 @@
]
},
{
"name": "Parents",
"name": "Contacts",
"item": [
{
"name": "Change Parent First Name",
"name": "Change Parent or Contact First Name",
"event": [
{
"listen": "prerequest",
Expand All @@ -10346,12 +10346,12 @@
"listen": "test",
"script": {
"exec": [
"pm.test(\"Response is 400 or 404\", () => {\r",
" pm.expect(pm.response.code).to.be.oneOf([400, 404])\r",
"pm.test(\"Response is 400\", () => {\r",
" pm.expect(pm.response.code).to.equal(400)\r",
"});\r",
"\r",
"if (pm.response.code == 400) {\r",
" pm.test(\"Should indicate that Parent keys cannot be changed.\", () => {\r",
" pm.test(\"Should indicate that Contact keys cannot be changed.\", () => {\r",
" pm.expect(pm.response.json().message).to.include(\"Key values for this resource cannot be changed.\");\r",
" });\r",
"}"
Expand All @@ -10365,23 +10365,23 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"parentUniqueId\": \"{{supplied:parentUniqueId}}-Changed\",\r\n \"birthDate\": \"1988-09-13\",\r\n \"firstName\": \"Jonathon\",\r\n \"lastSurname\": \"Doe\",\r\n \"_ext\": {\r\n \"Sample\": {\r\n \"teacherConference\": {\r\n \"dayOfWeek\": \"Monday\",\r\n \"endTime\": \"12:00:00\",\r\n \"startTime\": \"12:00:00\"\r\n },\r\n \"authors\": [],\r\n \"favoriteBookTitles\": [\r\n {\r\n \"favoriteBookTitle\": \"Green Eggs and Ham\"\r\n }\r\n ],\r\n \"isSportsFan\": false\r\n }\r\n }\r\n}",
"raw": "{\r\n \"{{ParentOrContactUniqueIdName}}\": \"{{supplied:parentUniqueId}}-Changed\",\r\n \"birthDate\": \"1988-09-13\",\r\n \"firstName\": \"Jonathon\",\r\n \"lastSurname\": \"Doe\",\r\n \"_ext\": {\r\n \"Sample\": {\r\n \"teacherConference\": {\r\n \"dayOfWeek\": \"Monday\",\r\n \"endTime\": \"12:00:00\",\r\n \"startTime\": \"12:00:00\"\r\n },\r\n \"authors\": [],\r\n \"favoriteBookTitles\": [\r\n {\r\n \"favoriteBookTitle\": \"Green Eggs and Ham\"\r\n }\r\n ],\r\n \"isSportsFan\": false\r\n }\r\n }\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/parents/{{known:parent:id}}",
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/{{ParentOrContactCollectionName}}/{{known:parent:id}}",
"host": [
"{{ApiBaseUrl}}"
],
"path": [
"data",
"v3",
"ed-fi",
"parents",
"{{ParentOrContactCollectionName}}",
"{{known:parent:id}}"
]
}
Expand All @@ -10394,7 +10394,7 @@
"name": "Teardown",
"item": [
{
"name": "Delete Student Parent Association",
"name": "Delete Student Parent or Contact Association",
"event": [
{
"listen": "prerequest",
Expand All @@ -10409,8 +10409,8 @@
"listen": "test",
"script": {
"exec": [
"pm.test(\"Response is 204 or 404\", () => {\r",
" pm.expect(pm.response.code).to.be.oneOf([204, 404]) \r",
"pm.test(\"Response is 204\", () => {\r",
" pm.expect(pm.response.code).to.equal(204) \r",
" });\r",
""
],
Expand All @@ -10431,23 +10431,23 @@
}
},
"url": {
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/studentParentAssociations/{{known:studentParentAssociation:id}}",
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/{{StudentParentOrContactAssociationCollectionName}}/{{known:studentParentAssociation:id}}",
"host": [
"{{ApiBaseUrl}}"
],
"path": [
"data",
"v3",
"ed-fi",
"studentParentAssociations",
"{{StudentParentOrContactAssociationCollectionName}}",
"{{known:studentParentAssociation:id}}"
]
}
},
"response": []
},
{
"name": "Delete Parent",
"name": "Delete Parent or Contact",
"event": [
{
"listen": "prerequest",
Expand All @@ -10462,8 +10462,8 @@
"listen": "test",
"script": {
"exec": [
"pm.test(\"Response is 204 or 404\", () => {\r",
" pm.expect(pm.response.code).to.be.oneOf([204, 404]) \r",
"pm.test(\"Response is 204\", () => {\r",
" pm.expect(pm.response.code).to.equals(204) \r",
" });"
],
"type": "text/javascript"
Expand All @@ -10483,15 +10483,15 @@
}
},
"url": {
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/parents/{{known:parent:id}}",
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/{{ParentOrContactCollectionName}}/{{known:parent:id}}",
"host": [
"{{ApiBaseUrl}}"
],
"path": [
"data",
"v3",
"ed-fi",
"parents",
"{{ParentOrContactCollectionName}}",
"{{known:parent:id}}"
]
}
Expand Down Expand Up @@ -10975,6 +10975,20 @@
"",
"CreateAccessToken(\"TokenExpiry_255901044\",\"AccessToken_255901044\",\"ApiKey_255901044\",\"ApiSecret_255901044\")",
"",
"// Set variables related to data standard specific contact/parent variablility ",
"let ParentOrContactProperName = pm.environment.get(\"ParentOrContactProperName\");",
"let StudentParentOrContactAssociationCollectionName = \"Student\" + ParentOrContactProperName + \"Associations\";",
"let ParentOrContactUniqueIdName = ParentOrContactProperName + \"UniqueId\";",
"let ParentOrContactName = ParentOrContactProperName.toLowerCase();",
"let ParentOrContactCollectionName = ParentOrContactName + \"s\";",
"",
"pm.environment.set(\"StudentParentOrContactAssociationCollectionName\", StudentParentOrContactAssociationCollectionName);",
"pm.environment.set(\"ParentOrContactUniqueIdName\", ParentOrContactUniqueIdName);",
"pm.environment.set(\"ParentOrContactName\", ParentOrContactName);",
"pm.environment.set(\"ParentOrContactCollectionName\", ParentOrContactCollectionName);",
"",
"",
"",
"// Adapted from: https://marcin-chwedczuk.github.io/automatically-generate-new-oauth2-tokens-when-using-postman",
"// Assumes Environment with Environment Variables: ApiBaseUrl, ApiKey, ApiSecret",
"// See https://gist.github.com/blmeyers/21138bbe6f80b8c35701a8754bfe59d5 for an environment sample for Local (NOTE: environment variable names have been changed from the gist -- you must adjust accordingly)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6264,14 +6264,14 @@
"name": "Initialize Known",
"item": [
{
"name": "Initialize Known parents Data for Get Requests",
"name": "Initialize Known Contact Data for Get Requests",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Response is 200 or 404\", () => {\r",
" pm.expect(pm.response.code).to.be.oneOf([200, 404]) \r",
"pm.test(\"Response is 200\", () => {\r",
" pm.expect(pm.response.code).to.equal(200) \r",
" });\r",
"\r",
"if (pm.response.code === 200 ) {\r",
Expand All @@ -6289,10 +6289,10 @@
" \r",
" pm.environment.set('known:testSubject', JSON.stringify(testSubject));\r",
" \r",
" // Build request to update the Parent with address periods\r",
" // Build request to update the Contact with address periods\r",
" let postRequest = {\r",
" method: 'POST',\r",
" url: pm.environment.get('ApiBaseUrl') + '/data/v3/ed-fi/parents',\r",
" url: pm.environment.get('ApiBaseUrl') + '/data/v3/ed-fi/{{ParentOrContactCollectionName}}',\r",
" header: {\r",
" 'Content-Type': 'application/json',\r",
" 'Authorization': 'Bearer ' + pm.environment.get('AccessToken')\r",
Expand All @@ -6302,7 +6302,7 @@
" raw: JSON.stringify(testSubject)\r",
" }\r",
" };\r",
" // Update parent to assign address periods for the scenario\r",
" // Update parent/contact to assign address periods for the scenario\r",
" pm.sendRequest(postRequest, (err, response) => {\r",
" if (err) {\r",
" console.log(JSON.stringify(err));\r",
Expand All @@ -6320,15 +6320,15 @@
"method": "GET",
"header": [],
"url": {
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/parents",
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/{{ParentOrContactCollectionName}}",
"host": [
"{{ApiBaseUrl}}"
],
"path": [
"data",
"v3",
"ed-fi",
"parents"
"{{ParentOrContactCollectionName}}"
]
}
},
Expand Down Expand Up @@ -7531,7 +7531,7 @@
"script": {
"exec": [
"const __ = require('lodash');\r",
"pm.test(\"Response is 200 or 404\", () => {\r",
"pm.test(\"Response is 200 or 400\", () => {\r",
" pm.expect(pm.response.code).to.be.oneOf([200, 404]) \r",
" });\r",
"\r",
Expand Down Expand Up @@ -7595,7 +7595,7 @@
"{{supplied:parentId}}"
]
},
"description": "# Collection -> Collection\r\nScenario: Composite includes collection with collection\r\n Given the subject of the request is a StudentAssessment with ObjectAssessmentScoreResults\r\n When a GET (by id) request is submitted to the \"StudentCollectionWithCollection\" composite\r\n Then the response model should have only collection studentAssessmentStudentObjectiveAssessments with collection studentAssessmentStudentObjectiveAssessmentScoreResults\r\n And the queries generated should all match previously approved values\r\n \r\n \r\n ++++++++++++++++++++++++++++\r\n\tI would recommend changing this composite to go after Parent, ParentAddress, and ParentAddressPeriod.\r\n\t\r\n\t <Composite name=\"ResourceWithCollectionWithCollection\">\r\n <BaseResource name=\"Parent\">\r\n <Collection name=\"ParentAddresses\">\r\n <Collection name=\"ParentAddressPeriods\">\r\n <Property name=\"BeginDate\" />\r\n </Collection>\r\n </Collection>\r\n </BaseResource>\r\n </Composite>\r\n\t+++++++++++++++++++++++++++++++++"
"description": "# Collection -> Collection\r\nScenario: Composite includes collection with collection\r\n Given the subject of the request is a StudentAssessment with ObjectAssessmentScoreResults\r\n When a GET (by id) request is submitted to the \"StudentCollectionWithCollection\" composite\r\n Then the response model should have only collection studentAssessmentStudentObjectiveAssessments with collection studentAssessmentStudentObjectiveAssessmentScoreResults\r\n And the queries generated should all match previously approved values\r\n \r\n \r\n ++++++++++++++++++++++++++++\r\n\tI would recommend changing this composite to go after Contact, ContactAddress, and ContactAddressPeriod.\r\n\t\r\n\t <Composite name=\"ResourceWithCollectionWithCollection\">\r\n <BaseResource name=\"Contact\">\r\n <Collection name=\"ContactAddresses\">\r\n <Collection name=\"ContactAddressPeriods\">\r\n <Property name=\"BeginDate\" />\r\n </Collection>\r\n </Collection>\r\n </BaseResource>\r\n </Composite>\r\n\t+++++++++++++++++++++++++++++++++"
},
"response": []
}
Expand Down Expand Up @@ -8875,6 +8875,18 @@
"script": {
"type": "text/javascript",
"exec": [
"// Set variables related to data standard specific contact/parent variablility ",
"let ParentOrContactProperName = pm.environment.get(\"ParentOrContactProperName\");",
"let StudentParentOrContactAssociationCollectionName = \"Student\" + ParentOrContactProperName + \"Associations\";",
"let ParentOrContactUniqueIdName = ParentOrContactProperName + \"UniqueId\";",
"let ParentOrContactName = ParentOrContactProperName.toLowerCase();",
"let ParentOrContactCollectionName = ParentOrContactName + \"s\";",
"",
"pm.environment.set(\"StudentParentOrContactAssociationCollectionName\", StudentParentOrContactAssociationCollectionName);",
"pm.environment.set(\"ParentOrContactUniqueIdName\", ParentOrContactUniqueIdName);",
"pm.environment.set(\"ParentOrContactName\", ParentOrContactName);",
"pm.environment.set(\"ParentOrContactCollectionName\", ParentOrContactCollectionName);",
"",
"// Adapted from: https://marcin-chwedczuk.github.io/automatically-generate-new-oauth2-tokens-when-using-postman",
"// Assumes Environment with Environment Variables: ApiBaseUrl, ApiKey, ApiSecret",
"// See https://gist.github.com/blmeyers/21138bbe6f80b8c35701a8754bfe59d5 for an environment sample for Local (NOTE: environment variable names have been changed from the gist -- you must adjust accordingly)",
Expand Down
Loading

0 comments on commit 764c448

Please sign in to comment.