Пример #1
0
    def test_update_user(self):
        endpoint = "/users/"
        body = {
                "email": "*****@*****.**",
                "subscription_status": "false"
            }
        body2 = {
                "email": "*****@*****.**",
                "subscription_status": "true"
            }
        response, data = Helpers.patch_request(
            endpoint, self.headers["test1"], body)
        response2, data2 = Helpers.patch_request(
            endpoint, self.headers["test2"], body2)
        user1 = Helpers.get_request(endpoint, self.headers["test1"])
        user2 = Helpers.get_request(endpoint, self.headers["test2"])

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response2.status_code, 200)
        self.assertEqual(len(data), 3)
        self.assertEqual(user1[1]["email"], "*****@*****.**")
        self.assertEqual(user2[1]["subscription_status"], True)
Пример #2
0
    def test_group_update(self):
        header = self.headers["test3"]
        profile_ids = Helpers.get_profile_id(header)

        while len(profile_ids) == 0:
            self.tearDown()
            self.setUp()
            profile_ids = Helpers.get_profile_id(header)

        groups = Helpers.get_request(f"/groups/?profile_id={profile_ids[0]}",
                                     header=header)
        group_ids = []
        for group in groups[1]:
            if group["admin"]:
                group_ids.append(group["groups"]["group_id"])
        non_group_ids = [i for i in range(1, 11) if i not in group_ids]

        endpoint1 = f"/groups/{group_ids[0]}?profile_id={profile_ids[0]}"
        endpoint2 = f"/groups/{non_group_ids[0]}?profile_id={profile_ids[0]}"
        body1 = {
            "name": "New group name",
            "description": "New group description"
        }
        body2 = {"name": "", "description": ""}

        response, data = Helpers.patch_request(endpoint1, header, body1)
        response2, data2 = Helpers.patch_request(endpoint2, header, body1)
        response3, data3 = Helpers.patch_request(endpoint1, header, body2)

        self.assertEqual(response.status_code, 200)
        self.assertTrue(response2.status_code in [401, 404])
        self.assertEqual(response3.status_code, 400)
        self.assertEqual(data["name"], "New group name")
        self.assertEqual(data["description"], "New group description")
        self.assertIsNone(data2)
        self.assertIsInstance(data3, dict)