<commit_before>=======================
friendly TestCase class
=======================

funkload-friendly provides a TestCase, it is extended FunkLoadTestCase.

This class features: 

- Retain cookie data between multiple requrests.
- Be able to configure log and result output directory, and some shortcut attribute.
- decorator for test description

Cookie support
==============

In FunkLoad, cookie data doesn't retain between request.

In funkload-friendly, cookie data retain between request.
This means it easy to be able to test using the Cookie-based session.

**Example**:

.. code-block:: python

   class LoginTest(TestCase):
       def test_login(self):
           self.get(self.site_url + "/login/")  # take the CSRF token into cookie
           # Login with cookie (CSRF token required)
           self.post(self.site_url + "/login/",
               params=[
                   ['username', 'spam'],
                   ['password', '<PASSWORD>'],
                   ['csrfmiddlewaretoken', self.cookie['csrftoken']],
               ]
           )

Configration support
====================

Omit filename
-------------

In FunkLoad, output destination of log and result is, you must specify the file name.

In funkload-friendly, specify a directory name, you can omit the file name.

Shortcut attribute
------------------

- ``[main]-[url]`` to ``self.site_url``.

Description decorator
=====================

In FunkLoad, method description has must be described in config file.

In funkload-friendly, description can be described with the description descorator.

**Example**:

.. code-block:: python

   from funkload_friendly.test import TestCase, description


   class MainTest(TestCase):
       @description("Load top_page")
       def test_top_page(self):
           self.get(self.site_url + "/")

**Result(log)**::

   test_top_page: Starting -----------------------------------
           Load top_page
   test_top_page: GET: http://localhost:8000/<commit_msg>update document<commit_after>=======================
Friendly TestCase Class
=======================

funkload-friendly provides a TestCase, it is extended FunkLoadTestCase.

This class features: 

- Retain cookie data between multiple requrests.
- Be able to configure log and result output directory, and some shortcut attribute.
- decorator for test description

Cookie Support
==============

In FunkLoad, cookie data doesn't retain between request.

In funkload-friendly, cookie data retain between request.
This means it easy to be able to test using the Cookie-based session.

**Example**:

.. code-block:: python

   class LoginTest(TestCase):
       def test_login(self):
           self.get(self.site_url + "/login/")  # take the CSRF token into cookie
           # Login with cookie (CSRF token required)
           self.post(self.site_url + "/login/",
               params=[
                   ['username', 'spam'],
                   ['password', '<PASSWORD>'],
                   ['csrfmiddlewaretoken', self.cookie['csrftoken']],
               ]
           )

Configration Support
====================

funkload-friendly can be a configuration shown below.

Omit Filename
-------------

In FunkLoad, output destination of log and result is, you must specify the file name.

In funkload-friendly, specify a directory name, you can omit the file name.

**Example**:

.. code-block:: ini

   [ftest]
   log_to = console file
   log_directory = ftest/
   result_directory = ftest/

   [bench]
   log_to = console file
   log_directory = bench/
   result_directory = bench/

Shortcut Attribute
------------------

Some config value assign to the attribute of TestCase.

- section: ``[main]``, key: ``url`` map to ``TestCase.site_url``.

  Specify the ``url`` in ``http[s]://host[:port]`` format.

**Example**:

.. code-block:: ini

   [main]
   url = http://localhost:8000

Description Decorator
=====================

In FunkLoad, method description has must be described in config file.

In funkload-friendly, description can be described with the description descorator.

**Example**:

.. code-block:: python

   from funkload_friendly.test import TestCase, description


   class MainTest(TestCase):
       @description("Load top_page")
       def test_top_page(self):
           self.get(self.site_url + "/")

**Result(log)**::

   test_top_page: Starting -----------------------------------
           Load top_page
   test_top_page: GET: http://localhost:8000/
{'fraction_non_alphanumeric': 0.16420250896057348, 'fraction_numerical': 0.002688172043010753, 'mean_word_length': 2.8064791133844844, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3804964', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1158, 'n_words': 411}