<commit_before>import json
from rest_framework import status
from rest_framework.test import APITestCase


class SiteTest(APITestCase):

    fixtures = [
        'dcim',
        'ipam',
        'extras',
    ]

    standard_fields = [
        'id',
        'name',
        'slug',
        'facility',
        'asn',
        'physical_address',
        'shipping_address',
        'comments',
        'count_prefixes',
        'count_vlans',
        'count_racks',
        'count_devices',
        'count_circuits'
    ]

    nested_fields = [
        'id',
        'name',
        'slug'
    ]

    rack_fields = [
        'id',
        'name',
        'facility_id',
        'display_name',
        'site',
        'group',
        'u_height',
        'comments'
    ]

    graph_fields = [
        'name',
        'embed_url',
        'link',
    ]

    def test_get_list(self, endpoint='/api/dcim/sites/'):
        response = self.client.get(endpoint)
        content = json.loads(response.content)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        for i in content:
            self.assertEqual(
                sorted(i.keys()),
                sorted(self.standard_fields),
            )

    def test_get_detail(self, endpoint='/api/dcim/sites/1/'):
        response = self.client.get(endpoint)
        content = json.loads(response.content)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(
            sorted(content.keys()),
            sorted(self.standard_fields),
        )

    def test_get_site_list_rack(self, endpoint='/api/dcim/sites/1/racks/'):
        response = self.client.get(endpoint)
        content = json.loads(response.content)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        for i in json.loads(response.content):
            self.assertEqual(
                sorted(i.keys()),
                sorted(self.rack_fields),
            )<commit_msg>Corrected SiteTest to account for earlier Graph model change<commit_after>import json
from rest_framework import status
from rest_framework.test import APITestCase


class SiteTest(APITestCase):

    fixtures = [
        'dcim',
        'ipam',
        'extras',
    ]

    standard_fields = [
        'id',
        'name',
        'slug',
        'facility',
        'asn',
        'physical_address',
        'shipping_address',
        'comments',
        'count_prefixes',
        'count_vlans',
        'count_racks',
        'count_devices',
        'count_circuits'
    ]

    nested_fields = [
        'id',
        'name',
        'slug'
    ]

    rack_fields = [
        'id',
        'name',
        'facility_id',
        'display_name',
        'site',
        'group',
        'u_height',
        'comments'
    ]

    graph_fields = [
        'name',
        'embed_url',
        'embed_link',
    ]

    def test_get_list(self, endpoint='/api/dcim/sites/'):
        response = self.client.get(endpoint)
        content = json.loads(response.content)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        for i in content:
            self.assertEqual(
                sorted(i.keys()),
                sorted(self.standard_fields),
            )

    def test_get_detail(self, endpoint='/api/dcim/sites/1/'):
        response = self.client.get(endpoint)
        content = json.loads(response.content)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(
            sorted(content.keys()),
            sorted(self.standard_fields),
        )

    def test_get_site_list_rack(self, endpoint='/api/dcim/sites/1/racks/'):
        response = self.client.get(endpoint)
        content = json.loads(response.content)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        for i in json.loads(response.content):
            self.assertEqual(
                sorted(i.keys()),
                sorted(self.rack_fields),
            )
{'fraction_non_alphanumeric': 0.11926835379604109, 'fraction_numerical': 0.005512402906539714, 'mean_word_length': 1.8172194777699364, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6935177', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1201, 'n_words': 190}