-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
4adcfe0
commit 2982a77
Showing
3 changed files
with
60 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,37 @@ | ||
defmodule EpjsApp.TeamMemberControllerTest do | ||
use EpjsApp.ConnCase | ||
alias EpjsApp.{EPJSTeamMember, Repo} | ||
alias EpjsApp.{EPJSUser, EPJSTeamMember, Repo} | ||
|
||
describe "team member controller returns json response with valid user data" do | ||
describe "routes with no clinician return empty lists" do | ||
test "GET /epjsteammember/clinician-connection/find-clinician?user_data=", %{conn: conn} do | ||
user_data = "[email protected]&UserId=badS tring&tokenexpiry=3000-06-23T11:15:53" | ||
conn = get conn, "/epjsteammember/clinician-connection/find-clinician?user_data=" <> user_data | ||
assert conn.resp_body == "{\"decrypted_user_guid\":\"randomstringtotestwith\",\"decrypted_time_str\":\"3000-06-23T11:15:53\",\"clinician\":[]}" | ||
assert conn.resp_body | ||
|> Poison.decode! | ||
|> Map.get("clinician") == [] | ||
end | ||
|
||
test "GET /epjsteammember/clinician-connection/get-patients?clinician= with clinician not in db returns no data", %{conn: conn} do | ||
clinician = %{ | ||
id: 321, | ||
first_name: "rob", | ||
last_name: "stallion", | ||
email: "[email protected]", | ||
security_question: "Question?", | ||
security_answer: "Answer", | ||
role: "clinician", | ||
user_guid: "randomstringtotestwith" | ||
} |> Poison.encode! | ||
|
||
conn = get conn, "/epjsteammember/clinician-connection/get-patients?clinician=" <> clinician | ||
assert conn.resp_body | ||
|> Poison.decode! | ||
|> Map.get("patient_ids") == [] | ||
end | ||
end | ||
|
||
describe "routes with clinician return lists" do | ||
setup %{} do | ||
Repo.insert!(%EPJSTeamMember{ | ||
Patient_ID: 123, | ||
|
@@ -14,28 +43,42 @@ defmodule EpjsApp.TeamMemberControllerTest do | |
User_Guid: "randomstringtotestwith" | ||
}) | ||
|
||
Repo.insert!(%EPJSUser{ | ||
Patient_ID: 123, | ||
Forename: "kat", | ||
Surname: "bow" | ||
}) | ||
|
||
:ok | ||
end | ||
|
||
test "GET /epjsteammember/clinician-connection/find-clinician?user_data=", %{conn: conn} do | ||
user_data = "[email protected]&UserId=randomstringtotestwith&tokenexpiry=3000-06-23T11:15:53" | ||
conn = get conn, "http://localhost:4001/epjsteammember/clinician-connection/find-clinician?user_data=" <> user_data | ||
conn = get conn, "/epjsteammember/clinician-connection/find-clinician?user_data=" <> user_data | ||
clinician = conn.resp_body | ||
|> Poison.decode! | ||
|> Map.get("clinician") | ||
|> Enum.at(0) | ||
assert clinician["Staff_ID"] == 321 | ||
end | ||
end | ||
|
||
describe "team member controller returns empty clinician list with invalid user_data" do | ||
test "GET /epjsteammember/clinician-connection/find-clinician?user_data=", %{conn: conn} do | ||
user_data = "[email protected]&UserId=randomstringtotestwith&tokenexpiry=3000-06-23T11:15:53" | ||
conn = get conn, "http://localhost:4001/epjsteammember/clinician-connection/find-clinician?user_data=" <> user_data | ||
assert conn.resp_body == "{\"decrypted_user_guid\":\"randomstringtotestwith\",\"decrypted_time_str\":\"3000-06-23T11:15:53\",\"clinician\":[]}" | ||
test "GET /epjsteammember/clinician-connection/get-patients?clinician= returns expected data", %{conn: conn} do | ||
clinician = %{ | ||
id: 321, | ||
first_name: "rob", | ||
last_name: "stallion", | ||
email: "[email protected]", | ||
security_question: "Question?", | ||
security_answer: "Answer", | ||
role: "clinician", | ||
user_guid: "randomstringtotestwith" | ||
} |> Poison.encode! | ||
|
||
conn = get conn, "/epjsteammember/clinician-connection/get-patients?clinician=" <> clinician | ||
assert conn.resp_body | ||
|> Poison.decode! | ||
|> Map.get("clinician") == [] | ||
|> Map.get("patient_ids") == [123] | ||
end | ||
end | ||
end | ||
"/epjsteammember/clinician-connection/get-patients" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters