<commit_before>"""Experiment access unit test suite."""

import unittest.mock as mock

import pytest

import chamber.access.experiment as exp_acc


_DB_CREDENTIALS = dict(
    host='host', user='user', password='password', database='database'
    )


@pytest.fixture
def mock_mysql_connector(monkeypatch):  # noqa: D103
    print('mock_mysql_connector!!!!!!')
    mock_mysql_connector = mock.MagicMock()
    mock_mysql_connector.connect = mock.MagicMock(return_value='cnx')
    monkeypatch.setattr(
        'mysql.connector.connect', mock_mysql_connector.connect
        )
    return mock_mysql_connector


class TestConnect(object):
    """Unit test suite for chamber.access.experiment.connect()."""

    def test_can_call_connect(
            self, mock_mysql_connector, monkeypatch
            ):  # noqa: D102

        exp_acc.connect(**_DB_CREDENTIALS)

        mock_mysql_connector.connect.assert_called_with(**_DB_CREDENTIALS)

    def test_connect_returns_cnx(
            self, mock_mysql_connector, monkeypatch
            ):  # noqa: D102

        result = exp_acc.connect(**_DB_CREDENTIALS)

        assert result == 'cnx'<commit_msg>Adds @staticmethod decorator to unit tests.<commit_after>"""Experiment access unit test suite."""

import unittest.mock as mock

import pytest

import chamber.access.experiment as exp_acc


_DB_CREDENTIALS = dict(
    host='host', user='user', password='password', database='database'
    )


@pytest.fixture
def mock_mysql_connector(monkeypatch):
    """Avoid call to external mySQL database."""
    mock_mysql_connector = mock.MagicMock()
    mock_mysql_connector.connect = mock.MagicMock(return_value='cnx')

    monkeypatch.setattr(
        'mysql.connector.connect', mock_mysql_connector.connect
        )

    return mock_mysql_connector


class TestConnect(object):
    """Unit test suite for chamber.access.experiment.connect()."""

    @staticmethod
    def test_can_call_connect(mock_mysql_connector, monkeypatch):  # noqa: D102
        exp_acc.connect(**_DB_CREDENTIALS)
        mock_mysql_connector.connect.assert_called_with(**_DB_CREDENTIALS)

    @staticmethod
    def test_connect_returns_cnx(mock_mysql_connector, monkeypatch):  # noqa: D102
        result = exp_acc.connect(**_DB_CREDENTIALS)
        assert result == 'cnx'
{'fraction_non_alphanumeric': 0.10275470048097946, 'fraction_numerical': 0.006558810668998688, 'mean_word_length': 3.963123644251627, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4929089', 'n_tokens_mistral': 739, 'n_tokens_neox': 696, 'n_words': 133}