<commit_before># encoding: utf-8
#
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Author: <NAME> (<EMAIL>)
#

from __future__ import unicode_literals
from __future__ import division
from active_data.app import OVERVIEW
from pyLibrary import convert
from pyLibrary.parsers import URL

from tests.base_test_class import ActiveDataBaseTest


class TestBasicRequests(ActiveDataBaseTest):

    def test_empty_request(self):
        response = self.utils.try_till_response(self.utils.service_url, data=b"")
        self.assertEqual(response.status_code, 400)

    def test_root_request(self):
        if self.utils.not_real_service():
            return

        url = URL(self.utils.service_url)
        url.path = ""
        url = str(url)
        response = self.utils.try_till_response(url, data=b"")
        self.assertEqual(response.status_code, 400)
        self.assertEqual(response.all_content, OVERVIEW)

    def test_bad_file_request(self):
        url = URL(self.utils.service_url)
        url.path = "/tools/../../README.md"

        response = self.utils.try_till_response(str(url), data=b"")
        self.assertEqual(response.status_code, 404)
        self.assertEqual(response.all_content, "")

    def test_query_on_static_file(self):
        url = URL(self.utils.service_url)
        url.path = "/tools/index.html?123"<commit_msg>some rule about having to return 200 on root :/  oh internet: you so bad!<commit_after># encoding: utf-8
#
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Author: <NAME> (<EMAIL>)
#

from __future__ import unicode_literals
from __future__ import division
from active_data.app import OVERVIEW
from pyLibrary import convert
from pyLibrary.parsers import URL

from tests.base_test_class import ActiveDataBaseTest


class TestBasicRequests(ActiveDataBaseTest):

    def test_empty_request(self):
        response = self.utils.try_till_response(self.utils.service_url, data=b"")
        self.assertEqual(response.status_code, 400)

    def test_root_request(self):
        if self.utils.not_real_service():
            return

        url = URL(self.utils.service_url)
        url.path = ""
        url = str(url)
        response = self.utils.try_till_response(url, data=b"")
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.all_content, OVERVIEW)

    def test_bad_file_request(self):
        url = URL(self.utils.service_url)
        url.path = "/tools/../../README.md"

        response = self.utils.try_till_response(str(url), data=b"")
        self.assertEqual(response.status_code, 404)
        self.assertEqual(response.all_content, "")

    def test_query_on_static_file(self):
        url = URL(self.utils.service_url)
        url.path = "/tools/index.html?123"
{'fraction_non_alphanumeric': 0.10522875816993464, 'fraction_numerical': 0.012091503267973857, 'mean_word_length': 3.281118881118881, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3924043', 'n_tokens_mistral': 990, 'n_tokens_neox': 940, 'n_words': 228}