예제 #1
0
    def test_user_can_view_a_list_of_search_teams(self):
        admin = create_admin_user()
        token = authenticate_user(admin)
        search = create_search()
        with self.client:
            team_res = self.client.post(
                f"/api/searches/{search.uuid}/teams",
                data=json.dumps(
                    {
                        "team_leader": "Team Leader",
                        "medic": "Team Medic",
                        "responder_1": "First Responder",
                        "responder_2": "Second Responder",
                        "responder_3": "Third Responder",
                    }
                ),
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )
            team = json.loads(team_res.data.decode())

            res = self.client.get(
                f"/api/searches/{search.uuid}/teams",
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )
            data = json.loads(res.data.decode())

            self.assert200(res)
            self.assertIn(team["id"], data[0]["uuid"])
예제 #2
0
    def test_user_can_view_list_of_searches(self):
        admin = create_admin_user()
        token = authenticate_user(admin)
        search1 = create_search()
        search2 = create_search()

        with self.client:
            res = self.client.get(
                "/api/searches",
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )
            data = json.loads(res.data.decode())

            self.assert200(res)
            self.assertIn(search1.location, data[0]["location"])
            self.assertIn(search2.oic, data[1]["oic"])
예제 #3
0
    def test_admin_can_view_a_search(self):
        admin = create_admin_user()
        token = authenticate_user(admin)
        search = create_search()
        with self.client:
            res = self.client.get(
                f"/api/searches/{search.uuid}",
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )
            data = json.loads(res.data.decode())

            self.assert200(res)
            self.assertEqual(search.location, data["location"])
            self.assertEqual(search.oic, data["oic"])
예제 #4
0
    def test_admin_can_end_a_search(self):
        admin = create_admin_user()
        token = authenticate_user(admin)
        search = create_search()
        with self.client:
            res = self.client.post(
                f"/api/searches/{search.uuid}/end",
                data=json.dumps({
                    "end_time": "15:00",
                    "notes": "Nothing to note",
                }),
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )

            self.assertEqual(202, res.status_code)
예제 #5
0
    def test_user_can_assign_a_radio_to_a_user(self):
        admin = create_admin_user()
        token = authenticate_user(admin)
        search = create_search()

        with self.client:
            res = self.client.post(
                f"/api/searches/{search.uuid}/radios",
                data=json.dumps({
                    "call_sign": "WW01",
                    "tetra_number": "53831",
                    "name": "Test User"
                }),
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )

            self.assertEqual(201, res.status_code)
예제 #6
0
    def test_user_can_view_a_list_of_search_logs(self):
        admin = create_admin_user()
        token = authenticate_user(admin)
        search = create_search()
        log1 = create_search_log(search)
        log2 = create_search_log(search)

        with self.client:
            res = self.client.get(
                f"/api/searches/{search.uuid}/logs/search",
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )
            data = json.loads(res.data.decode())

            self.assert200(res)
            self.assertEqual(log1.team, data[0]["team"])
            self.assertEqual(log2.start_time, data[0]["start_time"])
예제 #7
0
    def test_user_can_create_comms_log_entry(self):
        admin = create_admin_user()
        token = authenticate_user(admin)
        search = create_search()

        with self.client:
            res = self.client.post(
                f"/api/searches/{search.uuid}/logs/comms",
                data=json.dumps({
                    "time": "12:00",
                    "call_sign": "WW01",
                    "message": "Test Message",
                    "action": "No Action Required",
                }),
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )

            self.assertEqual(201, res.status_code)
예제 #8
0
    def test_user_can_create_a_search_log(self):
        admin = create_admin_user()
        token = authenticate_user(admin)
        search = create_search()

        with self.client:
            res = self.client.post(
                f"/api/searches/{search.uuid}/logs/search",
                data=json.dumps(
                    {
                        "team": "Team 1",
                        "area": "Search Area",
                        "start_time": "12:00",
                    }
                ),
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )

            self.assertEqual(201, res.status_code)
예제 #9
0
    def test_user_can_view_list_of_radio_assignments(self):
        admin = create_admin_user()
        token = authenticate_user(admin)
        search = create_search()
        radio1 = create_radio_assignment(search)
        radio2 = create_radio_assignment(search)
        radio3 = create_radio_assignment(search)

        with self.client:
            res = self.client.get(
                f"/api/searches/{search.uuid}/radios",
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )

            data = json.loads(res.data.decode())

            self.assert200(res)
            self.assertEqual(radio1.name, data[0]["name"])
            self.assertEqual(radio2.tetra_number, data[1]["tetra_number"])
            self.assertEqual(radio3.call_sign, data[2]["call_sign"])
예제 #10
0
    def test_user_can_create_search_team(self):
        admin = create_admin_user()
        token = authenticate_user(admin)
        search = create_search()
        with self.client:
            res = self.client.post(
                f"/api/searches/{search.uuid}/teams",
                data=json.dumps(
                    {
                        "team_leader": "Team Leader",
                        "medic": "Team Medic",
                        "responder_1": "First Responder",
                        "responder_2": "Second Responder",
                        "responder_3": "Third Responder",
                    }
                ),
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )

            self.assertEqual(201, res.status_code)
예제 #11
0
    def test_user_can_update_a_search_log(self):
        admin = create_admin_user()
        token = authenticate_user(admin)
        search = create_search()
        log = create_search_log(search)

        with self.client:
            res = self.client.put(
                f"/api/searches/{search.uuid}/logs/search/{log.uuid}",
                data=json.dumps(
                    {
                        "team": log.team,
                        "area": log.area,
                        "start_time": log.start_time,
                        "end_time": "15:00",
                        "notes": "Nothing Found",
                    }
                ),
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )

            self.assertEqual(202, res.status_code)
예제 #12
0
    def test_user_can_update_a_specific_saerch_team(self):
        admin = create_admin_user()
        token = authenticate_user(admin)
        search = create_search()
        search_team = create_search_team(search)

        with self.client:
            res = self.client.put(
                f"/api/searches/{search.uuid}/teams/{search_team.uuid}",
                data=json.dumps(
                    {
                        "name": search_team.name,
                        "team_leader": search_team.team_leader,
                        "medic": "Test Medic",
                        "responder_1": search_team.responder_1,
                        "responder_2": search_team.responder_2,
                        "responder_3": search_team.responder_3,
                    }
                ),
                content_type="application/json",
                headers={"Authorization": f"Bearer {token}"},
            )

            self.assertEqual(202, res.status_code)