<commit_before>from rest_framework import status

from hs_core.hydroshare import resource

from .base import HSRESTTestCase


class TestCustomScimetaEndpoint(HSRESTTestCase):
    def setUp(self):
        super(TestCustomScimetaEndpoint, self).setUp()

        self.rtype = 'GenericResource'
        self.title = 'My Test resource'
        res = resource.create_resource(self.rtype,
                                       self.user,
                                       self.title,
                                       unpack_file=False)

        self.pid = res.short_id
        self.resources_to_delete.append(self.pid)

    def test_set_metadata(self):
        set_metadata = "/hsapi/resource/%s/scimeta/custom/" % self.pid
        response = self.client.post(set_metadata, {
            "resource-mode": "edit",
            "foo": "bar"
        }, format='json')

        self.assertEqual(response.status_code, status.HTTP_200_OK)

    def test_set_metadata_no_resource_mode(self):
        set_metadata = "/hsapi/resource/%s/scimeta/custom/" % self.pid
        response = self.client.post(set_metadata, {
            "foo": "bar"
        }, format='json')

        self.assertEqual(response.status_code, status.HTTP_200_OK)
<commit_msg>Test cleanup as per code review<commit_after>from rest_framework import status

from hs_core.hydroshare import resource

from .base import HSRESTTestCase


class TestCustomScimetaEndpoint(HSRESTTestCase):
    def setUp(self):
        super(TestCustomScimetaEndpoint, self).setUp()

        self.rtype = 'GenericResource'
        self.title = 'My Test resource'
        res = resource.create_resource(self.rtype,
                                       self.user,
                                       self.title)

        self.pid = res.short_id
        self.resources_to_delete.append(self.pid)

    def test_set_custom_metadata(self):
        set_metadata = "/hsapi/resource/%s/scimeta/custom/" % self.pid
        response = self.client.post(set_metadata, {
            "resource-mode": "edit",
            "foo": "bar"
        }, format='json')

        self.assertEqual(response.status_code, status.HTTP_200_OK)

    def test_set_custom_metadata_no_resource_mode(self):
        set_metadata = "/hsapi/resource/%s/scimeta/custom/" % self.pid
        response = self.client.post(set_metadata, {
            "foo": "bar"
        }, format='json')

        self.assertEqual(response.status_code, status.HTTP_200_OK)

{'fraction_non_alphanumeric': 0.10252237591537836, 'fraction_numerical': 0.004882017900732303, 'mean_word_length': 2.227034120734908, 'pattern_counts': {'":': 6, '<': 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': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7650504', 'n_tokens_mistral': 731, 'n_tokens_neox': 693, 'n_words': 120}