Commit 211d61b4 authored by Erlend Ydse's avatar Erlend Ydse
Browse files

Fix broken tests

parent 4a7f1514
Pipeline #117168 passed with stage
in 1 minute and 6 seconds
......@@ -45,19 +45,19 @@ class EditProfileAPITests(APITestCase):
img.save("test.jpg")
with open("test.jpg", "rb") as f:
data = { "profile_image": f }
response = self.client.patch(path=f"{self.path}{self.alice_data['id']}/", data=data)
response = self.client.put(path=f"{self.path}{self.alice_data['id']}/", data=data)
self.assertEqual(response.status_code, 200)
self.assertContains(response=response, text="test.jpg")
img = Image.new(mode="RGB", size=(400, 400), color=(255, 0, 0))
img.save("test2.jpg")
with open("test2.jpg", "rb") as f:
data = { "profile_image": f }
response = self.client.patch(path=f"{self.path}{self.alice_data['id']}/", data=data)
response = self.client.put(path=f"{self.path}{self.alice_data['id']}/", data=data)
self.assertEqual(response.status_code, 200)
self.assertContains(response=response, text="test2.jpg")
def test_edit_bio(self):
data = { "bio": "hello", "athletes": self.alice_data['athletes'] }
response = self.client.patch(path=f"{self.path}{self.alice_data['id']}/", data=data)
response = self.client.put(path=f"{self.path}{self.alice_data['id']}/", data=data)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data["bio"], "hello")
\ No newline at end of file
......@@ -54,16 +54,16 @@ class FriendRequestAPITests(APITestCase):
def test_can_add_friends(self):
data = { "symmetric_friends": self.bob_data['id'] }
response = self.client.patch(path=f"{self.path}{self.alice_data['id']}/", data=data)
response = self.client.put(path=f"{self.path}{self.alice_data['id']}/", data=data)
data = { "symmetric_friends": self.clair_data['id'] }
response = self.client.patch(path=f"{self.path}{self.alice_data['id']}/", data=data)
response = self.client.put(path=f"{self.path}{self.alice_data['id']}/", data=data)
self.assertEqual(len(response.data["symmetric_friends"]), 2)
def test_can_add_and_view_friends(self):
data = { "symmetric_friends": self.bob_data['id'] }
response = self.client.patch(path=f"{self.path}{self.alice_data['id']}/", data=data)
response = self.client.put(path=f"{self.path}{self.alice_data['id']}/", data=data)
data = { "symmetric_friends": self.clair_data['id'] }
response = self.client.patch(path=f"{self.path}{self.alice_data['id']}/", data=data)
response = self.client.put(path=f"{self.path}{self.alice_data['id']}/", data=data)
self.assertEqual(len(response.data["symmetric_friends"]), 2)
response = self.client.get(path=f"{self.path}{self.alice_data['id']}/")
self.assertEqual(len(response.data["symmetric_friends"]), 2)
......
......@@ -100,6 +100,7 @@ class UserPutSerializer(serializers.ModelSerializer):
if "profile_image" in validated_data:
instance.profile_image = validated_data["profile_image"]
if "symmetric_friends" in validated_data:
if len(validated_data["symmetric_friends"]) > 0:
instance.symmetric_friends.add(validated_data["symmetric_friends"][0])
return instance
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment