# Path: django_performance_testing/serializer.py
# DEFAULT_DJPT_DATAFILE_PATH = 'djpt.results_collected'
# def get_datafile_path():
#     def __init__(self, fpath):
#     def read_all(self):
#     def __init__(self, fpath):
#     def start(self):
#     def end(self):
#     def handle_results_collected(self, sender, results, context, **kwargs):
#     def handle_result(self, sender, results, context):
# class Reader:
# class Writer:
# 
# Path: django_performance_testing/signals.py



import pytest
from django_performance_testing import serializer
from django_performance_testing.signals import results_collected, results_read
from testapp.test_helpers import FakeSender, WithId


def pytest_generate_tests(metafunc):
    if 'collector_cls_with_sample_result' in metafunc.fixturenames:
        plugin_cls_fixtures = metafunc._arg2fixturedefs['collector_cls']
        assert len(plugin_cls_fixtures) == 1
        plugin_cls_fixture = plugin_cls_fixtures[0]
        sample_results = []
        ids = []
        for collector_cls in plugin_cls_fixture.params:
            for i, sample in enumerate(collector_cls.get_sample_results()):
                sample_results.append((collector_cls, sample))
                ids.append('-sample{}-'.format(i))
        metafunc.parametrize(
            argnames='collector_cls_with_sample_result',
            argvalues=sample_results,
            ids=ids
        )


@pytest.fixture
def sample_result(collector_cls, collector_cls_with_sample_result):
    if collector_cls != collector_cls_with_sample_result[0]:
        pytest.skip('this sample result is not for this plugin')
    result = collector_cls_with_sample_result[-1]
    return result


def test_datafile_path_depends_on_setting(settings):
    assert not hasattr(settings, 'DJPT_DATAFILE_PATH'), 'test assumption'

# Path: django_performance_testing/serializer.py
# DEFAULT_DJPT_DATAFILE_PATH = 'djpt.results_collected'
# def get_datafile_path():
#     def __init__(self, fpath):
#     def read_all(self):
#     def __init__(self, fpath):
#     def start(self):
#     def end(self):
#     def handle_results_collected(self, sender, results, context, **kwargs):
#     def handle_result(self, sender, results, context):
# class Reader:
# class Writer:
# 
# Path: django_performance_testing/signals.py



# Path: tests/testapp/tests/test_serialization.py
import pytest
from django_performance_testing import serializer
from django_performance_testing.signals import results_collected, results_read
from testapp.test_helpers import FakeSender, WithId



def pytest_generate_tests(metafunc):
    if 'collector_cls_with_sample_result' in metafunc.fixturenames:
        plugin_cls_fixtures = metafunc._arg2fixturedefs['collector_cls']
        assert len(plugin_cls_fixtures) == 1
        plugin_cls_fixture = plugin_cls_fixtures[0]
        sample_results = []
        ids = []
        for collector_cls in plugin_cls_fixture.params:
            for i, sample in enumerate(collector_cls.get_sample_results()):
                sample_results.append((collector_cls, sample))
                ids.append('-sample{}-'.format(i))
        metafunc.parametrize(
            argnames='collector_cls_with_sample_result',
            argvalues=sample_results,
            ids=ids
        )


@pytest.fixture
def sample_result(collector_cls, collector_cls_with_sample_result):
    if collector_cls != collector_cls_with_sample_result[0]:
        pytest.skip('this sample result is not for this plugin')
    result = collector_cls_with_sample_result[-1]
    return result


def test_datafile_path_depends_on_setting(settings):
    assert not hasattr(settings, 'DJPT_DATAFILE_PATH'), 'test assumption'

    assert serializer.get_datafile_path() == 'djpt.results_collected'