<commit_before>from django.test import TestCase
from django.test.client import Client

from metashare import test_utils
from metashare.settings import DJANGO_BASE, ROOT_PATH, DJANGO_URL, SITEMAP_URL


class SEOTest(TestCase):
    """
    Check the sitemap's and robots.txt's format
    """

    def test_sitemap(self):
        """
        Tests the correct appearance of the sitemap
        """
       
        imported_res = test_utils.import_xml('{}/repository/fixtures/'
          'testfixture.xml'.format(ROOT_PATH))[0]
        imported_res.storage_object.published = True
        imported_res.storage_object.save()
        client = Client()
        # assert that a two-token search finds a camelCase term:
        response = client.get('/{0}sitemap.xml'.format(DJANGO_BASE),
          follow=True)
        self.assertContains(response, 
          '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">', \
          status_code=200)
        self.assertContains(response, 
          '{}/repository/browse/italian-tts-speech-corpus-appen/' \
          .format(DJANGO_URL), status_code=200)


    def test_robots_txt(self):
        """
        Tests the correct appearance of the robots.txt file
        """
        client = Client()
        if DJANGO_BASE == '':
            response = client.get('/{0}robots.txt'.format(DJANGO_BASE),
              follow=True)
            self.assertContains(response, 
              'Disallow: /admin/', status_code=200)<commit_msg>Changes to pass jenkins tests.<commit_after>from django.test import TestCase
from django.test.client import Client

from metashare import test_utils
from metashare.settings import DJANGO_BASE, ROOT_PATH, DJANGO_URL, SITEMAP_URL


class SEOTest(TestCase):
    """
    Check the sitemap's and robots.txt's format
    """

    def test_sitemap(self):
        """
        Tests the correct appearance of the sitemap
        """
       
        imported_res = test_utils.import_xml('{}/repository/fixtures/'
          'testfixture.xml'.format(ROOT_PATH))[0]
        imported_res.storage_object.published = True
        imported_res.storage_object.save()
        client = Client()
        # assert that a two-token search finds a camelCase term:
        response = client.get('/{0}sitemap.xml'.format(DJANGO_BASE))
        self.assertContains(response, 
          '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">', \
          status_code=200)
        self.assertContains(response, 
          '{}/repository/browse/italian-tts-speech-corpus-appen/' \
          .format(DJANGO_URL), status_code=200)


    def test_robots_txt(self):
        """
        Tests the correct appearance of the robots.txt file
        """
        client = Client()
        if DJANGO_BASE == '':
            response = client.get('/{0}robots.txt'.format(DJANGO_BASE))
            self.assertContains(response, 
              'Disallow: /admin/', status_code=200)
{'fraction_non_alphanumeric': 0.11323982210058159, 'fraction_numerical': 0.009579199452617175, 'mean_word_length': 2.5059952038369304, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 8}, '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': '6068235', 'n_tokens_mistral': 917, 'n_tokens_neox': 879, 'n_words': 171}