<commit_before>from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase

from dashboard.models import Node, Author


class FriendRequestsTestCase(APITestCase):
    def setUp(self):
        self.node = Node.objects.create(name="Test", host="http://www.socdis.com/",
                                        service_url="http://api.socdis.com/")

        self.author = Author.objects.create(node=self.node, displayName="Test 1", activated=True)
        self.friend = Author.objects.create(node=self.node, displayName="Test 2", activated=True)

    def test_friend_requests(self):
        url = reverse('friend-request')

        data = {
            "query": "friendrequest",
            "author": {
                "id": "http://api.socdis.com/author/%s" % self.author.id,
                "host": "http://api.socdis.com/",
                "displayName": "<NAME>",
                "url": "http://api.socdis.com/author/%s" % self.author.id,
            },
            "friend": {
                "id": "http://api.socdis.com/author/%s" % self.friend.id,
                "host": "http://api.socdis.com/",
                "displayName": "<NAME>",
                "url": "http://api.socdis.com/author/%s" % self.friend.id,
            }
        }
<commit_msg>Test fails with 403: not authenticated<commit_after>from django.contrib.auth.models import User
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase

from dashboard.models import Node, Author


class FriendRequestsTestCase(APITestCase):
    def setUp(self):
        self.node = Node.objects.create(name="Test", host="http://www.socdis.com/",
                                        service_url="http://api.socdis.com/", local=True)

        user1 = User.objects.create(first_name="Test", last_name="One", username="1")
        user2 = User.objects.create(first_name="Test", last_name="Two", username="2")

        self.author = Author.objects.get(user__id=user1.id)
        self.friend = Author.objects.get(user__id=user2.id)

    def test_friend_requests(self):
        url = reverse('service:friend-request')

        data = {
            "query": "friendrequest",
            "author": {
                "id": "http://api.socdis.com/author/%s" % self.author.id,
                "host": "http://api.socdis.com/",
                "displayName": "<NAME>",
                "url": "http://api.socdis.com/author/%s" % self.author.id,
            },
            "friend": {
                "id": "http://api.socdis.com/author/%s" % self.friend.id,
                "host": "http://api.socdis.com/",
                "displayName": "<NAME>",
                "url": "http://api.socdis.com/author/%s" % self.friend.id,
            }
        }

{'fraction_non_alphanumeric': 0.157725321888412, 'fraction_numerical': 0.003934191702432046, 'mean_word_length': 2.0702524698133917, 'pattern_counts': {'":': 22, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1771148', 'n_tokens_mistral': 844, 'n_tokens_neox': 814, 'n_words': 140}