<commit_before>import unittest
from performance_testing.config import Config, Request
from performance_testing.errors import ConfigError


class ConfigTestCase(unittest.TestCase):
    def setUp(self):
        self.config = Config()
        self.config.host = 'http://www.example.com'
        self.config.requests = [
            Request(url='/', type='GET', data=''),
            Request(url='/about', type='GET', data=''),
            Request(url='/imprint', type='GET', data='')
        ]

    def test_check_valid(self):
        config = Config()
        with self.assertRaises(ConfigError) as error:
            config.check_valid()
        self.assertEqual(error.exception.message, 'Config with name "host" not set.')
        config.host = 'http://www.example.com'

        with self.assertRaises(ConfigError) as error:
            config.check_valid()
        self.assertEqual(error.exception.message, 'Config with name "requests_count" not set.')
        config.requests_count = 10

        with self.assertRaises(ConfigError) as error:
            config.check_valid()
        self.assertEqual(error.exception.message, 'Config with name "clients_count" not set.')
        config.clients_count = 2

        with self.assertRaises(ConfigError) as error:
            config.check_valid()
        self.assertEqual(error.exception.message, 'Config with name "requests" not set.')
        config.requests = [
            Request(url='/', type='GET', data=''),
            Request(url='/about', type='GET', data=''),
            Request(url='/imprint', type='GET', data='')
        ]

    def test_url(self):
        self.assertEqual('http://www.example.com/', self.config.url(self.config.requests[0].url))
        self.assertEqual('http://www.example.com/about', self.config.url(self.config.requests[1].url))
        self.assertEqual('http://www.example.com/imprint', self.config.url(self.config.requests[2].url))
<commit_msg>Update indention, write test for config.Request<commit_after>import unittest
from performance_testing.config import Config, Request
from performance_testing.errors import ConfigError


class ConfigTestCase(unittest.TestCase):
    def setUp(self):
        self.config = Config()
        self.config.host = 'http://www.example.com'
        self.config.requests = [
            Request(url='/', type='GET', data=''),
            Request(url='/about', type='GET', data=''),
            Request(url='/imprint', type='GET', data='')
        ]

    def test_check_valid(self):
        config = Config()
        with self.assertRaises(ConfigError) as error:
            config.check_valid()
        self.assertEqual(error.exception.message, 'Config with name "host" not set.')
        config.host = 'http://www.example.com'

        with self.assertRaises(ConfigError) as error:
            config.check_valid()
        self.assertEqual(error.exception.message, 'Config with name "requests_count" not set.')
        config.requests_count = 10

        with self.assertRaises(ConfigError) as error:
            config.check_valid()
        self.assertEqual(error.exception.message, 'Config with name "clients_count" not set.')
        config.clients_count = 2

        with self.assertRaises(ConfigError) as error:
            config.check_valid()
        self.assertEqual(error.exception.message, 'Config with name "requests" not set.')
        config.requests = [
            Request(url='/', type='GET', data=''),
            Request(url='/about', type='GET', data=''),
            Request(url='/imprint', type='GET', data='')
        ]

    def test_url(self):
        self.assertEqual('http://www.example.com/',
                         self.config.url(self.config.requests[0].url))
        self.assertEqual('http://www.example.com/about',
                         self.config.url(self.config.requests[1].url))
        self.assertEqual('http://www.example.com/imprint',
                         self.config.url(self.config.requests[2].url))

    def test_request_init(self):
        url = '/the/url'
        type = 'GET'
        data = 'foo=bar&bla=blubb'
        request = Request(url=url, type=type, data=data)
        self.assertEqual(request.url, url)
        self.assertEqual(request.type, type)
        self.assertEqual(request.data, data)

{'fraction_non_alphanumeric': 0.1414519906323185, 'fraction_numerical': 0.002810304449648712, 'mean_word_length': 2.598146588037068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, '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': '7208679', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1191, 'n_words': 233}