<commit_before>import os
import pytest
from utils import retry
from faker import Faker
from factories import ContainerFactory


@pytest.fixture(scope="module")
def minion_id():
    fake = Faker()
    return u'{0}_{1}'.format(fake.word(), fake.word())


@pytest.fixture(scope="module")
def proxy_config():
    return {'port': 8000}


@pytest.fixture(scope="module")
def proxy_server(request, salt_root, docker_client, proxy_config):
    fake = Faker()
    name = u'proxy_server_{0}_{1}'.format(fake.word(), fake.word())
    command = 'python -m tests.scripts.proxy_server {0}'.format(proxy_config['port'])
    obj = ContainerFactory(
        docker_client=docker_client,
        config__command=command,
        config__name=name,
        config__salt_config=None,
        config__host_config=docker_client.create_host_config(
            binds={
                os.getcwd(): {
                    'bind': "/salt-toaster/",
                    'mode': 'rw'
                }
            }
        ),
        config__volumes=[os.getcwd()]
    )
    request.addfinalizer(
        lambda: obj['docker_client'].remove_container(
            obj['config']['name'], force=True))
    return obj


@pytest.fixture(scope="module")
def master_container_extras(minion_id, proxy_server, proxy_config):
    return dict(
        config__salt_config__id=minion_id,
        config__salt_config__pillar={
            'top': {'base': {minion_id: [minion_id]}},
            minion_id: {
                'proxy': {
                    'proxytype': 'rest_sample',
                    'url': 'http://{0}:{1}'.format(
                        proxy_server['ip'], proxy_config['port']
                    )
                }
            }
        }
    )


@pytest.fixture(scope="module")
def minion_container_extras(minion_id):
    return dict(config__salt_config__id=minion_id)


def test_ping_proxyminion(master, minion, minion_key_accepted):

    def ping():
        return master.salt(minion['id'], "test.ping")[minion['id']] is True<commit_msg>Clean test_proxy<commit_after>import os
import pytest
from utils import retry
from faker import Faker
from factories import ContainerFactory


PROXY_PORT = 8000


@pytest.fixture(scope="module")
def minion_id():
    fake = Faker()
    return u'{0}_{1}'.format(fake.word(), fake.word())


@pytest.fixture(scope="module")
def proxy_server(request, salt_root, docker_client):
    fake = Faker()
    name = u'proxy_server_{0}_{1}'.format(fake.word(), fake.word())
    command = 'python -m tests.scripts.proxy_server {0}'.format(PROXY_PORT)
    obj = ContainerFactory(
        docker_client=docker_client,
        config__command=command,
        config__name=name,
        config__salt_config=None,
        config__host_config=docker_client.create_host_config(
            binds={
                os.getcwd(): {
                    'bind': "/salt-toaster/",
                    'mode': 'rw'
                }
            }
        ),
        config__volumes=[os.getcwd()]
    )
    request.addfinalizer(
        lambda: obj['docker_client'].remove_container(
            obj['config']['name'], force=True))
    return obj


@pytest.fixture(scope="module")
def master_container_extras(minion_id, proxy_server):
    proxy_url = 'http://{0}:{1}'.format(proxy_server['ip'], PROXY_PORT)
    return dict(
        config__salt_config__id=minion_id,
        config__salt_config__pillar={
            'top': {'base': {minion_id: [minion_id]}},
            minion_id: {
                'proxy': {'proxytype': 'rest_sample', 'url': proxy_url}
            }
        }
    )


@pytest.fixture(scope="module")
def minion_container_extras(minion_id):
    return dict(config__salt_config__id=minion_id)


def test_ping_proxyminion(master, minion, minion_key_accepted):

    def ping():
        return master.salt(minion['id'], "test.ping")[minion['id']] is True
{'fraction_non_alphanumeric': 0.13428201811125484, 'fraction_numerical': 0.005692108667529107, 'mean_word_length': 2.71373679154659, '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': '3582618', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1223, 'n_words': 203}