def test_module_setup(testdir):
    test_file = 'fixtures/test_module_setup.py'
    (result, scheduler) = run_test(testdir, [test_file])
    assert_outcomes(result, passed=2)

    assert scheduler.suite_items == [
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem('setup',
                  Location(test_file, module_for(test_file), None,
                           'setup_module', 4),
                  scope='module'),
        SuiteItem('test',
                  Location(test_file, module_for(test_file), None, 'test1',
                           9)),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), None, 'test2', 14)),
    ]

    assert scheduler.report_items == [
        ReportItem(
            'setup',
            Location(test_file, module_for(test_file), None, 'setup_module',
                     4), 'passed'),
        ReportItem(
            'test', Location(test_file, module_for(test_file), None, 'test1',
                             9), 'passed'),
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), None, 'test2', 14),
            'passed'),
    ]
def test_function_parameterized(testdir):
    test_file = 'fixtures/test_function_param.py'
    (result, scheduler) = run_test(testdir, [test_file])
    assert_outcomes(result, passed=3)

    assert scheduler.suite_items == [
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), None,
                     'test_param[2+4-6]', 4)),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), None,
                     'test_param[3+5-8]', 4)),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), None,
                     'test_param[6*9-54]', 4)),
    ]

    assert scheduler.report_items == [
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), None,
                     'test_param[2+4-6]', 4), 'passed'),
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), None,
                     'test_param[3+5-8]', 4), 'passed'),
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), None,
                     'test_param[6*9-54]', 4), 'passed'),
    ]
def test_fixture_fail(testdir):
    test_file = 'fixtures/test_fixture_fail.py'
    (result, scheduler) = run_test(testdir, [test_file])
    assert_outcomes(result, error=1)

    assert scheduler.suite_items == [
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem(
            'fixture',
            Location(test_file, module_for(test_file), None, 'fixture', 4)),
        SuiteItem('test',
                  Location(test_file, module_for(test_file), None,
                           'test_with_fixture', 9),
                  deps=[
                      SuiteItem(
                          'fixture',
                          Location(test_file, module_for(test_file), None,
                                   'fixture', 4)),
                  ]),
    ]

    assert scheduler.report_items == [
        ReportItem(
            'setup',
            Location(test_file, module_for(test_file), None, 'fixture', 4),
            'error', Failure('Exception', 'setup failed')),
        ReportItem(
            'teardown',
            Location(test_file, module_for(test_file), None, 'fixture', 4),
            'passed'),
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), None,
                     'test_with_fixture', 9), 'failed'),
    ]
def test_class_method_setup_fail(testdir):
    test_file = 'fixtures/test_class_method_setup_fail.py'
    (result, scheduler) = run_test(testdir, [test_file])
    assert_outcomes(result, error=1)

    assert scheduler.suite_items == [
        SuiteItem(
            'class',
            Location(test_file, module_for(test_file), 'TestObject', None, 1)),
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem('setup',
                  Location(test_file, module_for(test_file), 'TestObject',
                           'setup_method', 3),
                  scope='method'),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), 'TestObject', 'test',
                     6)),
    ]

    assert scheduler.report_items == [
        ReportItem(
            'setup',
            Location(test_file, module_for(test_file), 'TestObject',
                     'setup_method', 3), 'failed',
            Failure('Exception', 'setup failed')),
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), 'TestObject', 'test',
                     6), 'failed'),
    ]
def test_class_setup_tag(testdir):
    test_file = 'fixtures/test_class_setup_tag.py'
    (_, scheduler) = run_test(testdir, [test_file])

    assert scheduler.suite_items == [
        SuiteItem(
            'class',
            Location(test_file, module_for(test_file), 'TestObject', None, 4)),
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem('setup',
                  Location(test_file, module_for(test_file), 'TestObject',
                           'setup_class', 6),
                  scope='class',
                  tags=[Tag('my_group', False)]),
    ]
def test_class_decorator(testdir):
    test_file = 'fixtures/test_class_decorator.py'
    (result, scheduler) = run_test(testdir, [test_file])
    assert_outcomes(result, passed=1)

    assert scheduler.suite_items == [
        SuiteItem(
            'class',
            Location(test_file, module_for(test_file), 'TestObject', None, 4)),
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), 'TestObject', 'test',
                     6)),
    ]
def test_class_tags(testdir):
    test_file = 'fixtures/test_class_tag.py'
    (result, scheduler) = run_test(testdir, [test_file])
    assert_outcomes(result, passed=1)

    assert scheduler.suite_items == [
        SuiteItem('class',
                  Location(test_file, module_for(test_file), 'TestObject',
                           None, 5),
                  tags=[Tag('my_group', False)]),
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), 'TestObject', 'test',
                     7)),
    ]
Ejemplo n.º 8
0
def collect_class(obj):
    location = func_to_location(None, obj)
    collect_item(SuiteItem('class', location, tags=parse_tags(obj)))

    add_introspection(obj, ['setup_class'], 'setup', 'class')
    add_introspection(obj, ['setup_method'], 'setup', 'method')
    add_introspection(obj, ['teardown_class'], 'teardown', 'class')
    add_introspection(obj, ['teardown_method'], 'teardown', 'method')
def test_function_pass(testdir):
    test_file = 'fixtures/test_function_pass.py'
    (result, scheduler) = run_test(testdir, [test_file])
    assert_outcomes(result, passed=1)

    assert scheduler.suite_items == [
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), None, 'test_pass', 1)),
    ]

    assert scheduler.report_items == [
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), None, 'test_pass', 1),
            'passed'),
    ]
def test_fixture_missing(testdir):
    test_file = 'fixtures/test_fixture_missing.py'
    (result, scheduler) = run_test(testdir, [test_file])
    assert_outcomes(result, error=1)

    assert scheduler.suite_items == [
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), None,
                     'test_with_missing_fixture', 1)),
    ]

    assert scheduler.report_items == [
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), None,
                     'test_with_missing_fixture', 1), 'failed'),
    ]
def test_fixture_tag(testdir):
    test_file = 'fixtures/test_fixture_tag.py'
    (_, scheduler) = run_test(testdir, [test_file])

    assert scheduler.suite_items == [
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem('fixture',
                  Location(test_file, module_for(test_file), None, 'fixture',
                           4),
                  tags=[Tag('my_group', True)]),
        SuiteItem('test',
                  Location(test_file, module_for(test_file), None,
                           'test_with_fixture', 10),
                  deps=[
                      SuiteItem('fixture',
                                Location(test_file, module_for(test_file),
                                         None, 'fixture', 4),
                                tags=[Tag('my_group', True)]),
                  ]),
    ]
def test_class_setup(testdir):
    test_file = 'fixtures/test_class_setup.py'
    (result, scheduler) = run_test(testdir, [test_file])
    assert_outcomes(result, passed=2)

    assert scheduler.suite_items == [
        SuiteItem(
            'class',
            Location(test_file, module_for(test_file), 'TestObject', None, 4)),
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem('setup',
                  Location(test_file, module_for(test_file), 'TestObject',
                           'setup_class', 6),
                  scope='class'),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), 'TestObject', 'test1',
                     11)),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), 'TestObject', 'test2',
                     15)),
    ]

    assert scheduler.report_items == [
        ReportItem(
            'setup',
            Location(test_file, module_for(test_file), 'TestObject',
                     'setup_class', 6), 'passed'),
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), 'TestObject', 'test1',
                     11), 'passed'),
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), 'TestObject', 'test2',
                     15), 'passed'),
    ]
Ejemplo n.º 13
0
def add_introspection(obj, names, type, scope):
    for name in names:
        if not hasattr(obj, name):
            continue
        func = getattr(obj, name)
        if hasattr(func, '__wrapped__'):
            func = func.__wrapped__
        func_loc = func_to_location(func, obj)
        collect_item(
            SuiteItem(type, func_loc, scope=scope, tags=parse_tags(func)))
        wrapped_func = wrap_with_report_func(func, func_loc, type)
        wrapped_func.__wrapped__ = func
        setattr(obj, name, wrapped_func)
        break  # stop after the first one
Ejemplo n.º 14
0
def collect_fixtures(node):
    fixtures = []
    if hasattr(node, '_fixtureinfo'):
        for _, fixturedef in sorted(
                node._fixtureinfo.name2fixturedefs.items()):
            fixture_fn = fixturedef[0].func
            location = func_to_location(fixture_fn)
            if is_artifical_fixture(fixturedef[0], location):
                continue
            fixtures.append(
                collect_item(
                    SuiteItem('fixture', location,
                              tags=parse_tags(fixture_fn))))
    return fixtures
def test_fixture_import(testdir):
    test_file = 'fixtures/test_fixture_import.py'
    (result, scheduler) = run_test(testdir, [test_file])
    assert_outcomes(result, passed=1)

    assert scheduler.suite_items == [
        SuiteItem('file', Location('fixtures/fixture.py'), size=42),
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem(
            'fixture',
            Location('fixtures/fixture.py', 'fixture', None, 'fixture_import',
                     4)),
        SuiteItem('test',
                  Location(test_file, module_for(test_file), None,
                           'test_with_fixture', 5),
                  deps=[
                      SuiteItem(
                          'fixture',
                          Location('fixtures/fixture.py', 'fixture', None,
                                   'fixture_import', 4)),
                  ]),
    ]

    assert scheduler.report_items == [
        ReportItem(
            'setup',
            Location('fixtures/fixture.py', 'fixture', None, 'fixture_import',
                     4), 'passed'),
        ReportItem(
            'teardown',
            Location('fixtures/fixture.py', 'fixture', None, 'fixture_import',
                     4), 'passed'),
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), None,
                     'test_with_fixture', 5), 'passed'),
    ]
def test_fixture_nested(testdir):
    test_file = 'fixtures/test_fixture_nested.py'
    (result, scheduler) = run_test(testdir, [test_file])
    assert_outcomes(result, passed=1)

    assert scheduler.suite_items == [
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem(
            'fixture',
            Location(test_file, module_for(test_file), None, 'fixture1', 4)),
        SuiteItem(
            'fixture',
            Location(test_file, module_for(test_file), None, 'fixture2', 9)),
        SuiteItem('test',
                  Location(test_file, module_for(test_file), None,
                           'test_with_fixture', 14),
                  deps=[
                      SuiteItem(
                          'fixture',
                          Location(test_file, module_for(test_file), None,
                                   'fixture1', 4)),
                      SuiteItem(
                          'fixture',
                          Location(test_file, module_for(test_file), None,
                                   'fixture2', 9)),
                  ]),
    ]

    # note that nested fixtures are evaluated sequentially, one _after_ the other
    assert scheduler.report_items == [
        ReportItem(
            'setup',
            Location(test_file, module_for(test_file), None, 'fixture1', 4),
            'passed'),
        ReportItem(
            'setup',
            Location(test_file, module_for(test_file), None, 'fixture2', 9),
            'passed'),
        ReportItem(
            'teardown',
            Location(test_file, module_for(test_file), None, 'fixture1', 4),
            'passed'),
        ReportItem(
            'teardown',
            Location(test_file, module_for(test_file), None, 'fixture2', 9),
            'passed'),
        ReportItem(
            'teardown',
            Location(test_file, module_for(test_file), None, 'fixture2', 9),
            'passed'),
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), None,
                     'test_with_fixture', 14), 'passed'),
    ]
Ejemplo n.º 17
0
def collect_item(item):
    def collect(item):
        if item.location in suite_item_locations:
            return False  # prevents duplicates
        suite_items.append(item)
        suite_item_locations.add(item.location)
        return True

    if collect(item):
        file = item.location.file
        file_size = suite_item_file_size_by_file.get(file, None)
        if not os.path.isdir(file) and file_size is None:
            file_size = os.path.getsize(file)
            suite_item_file_size_by_file[file] = file_size
        collect(SuiteItem('file', Location(file), size=file_size))

    return item
Ejemplo n.º 18
0
async def test_reply_to_suite_message():
    class MockSerializer:
        @staticmethod
        def serialize_suite(suite_items):
            return suite_items

    settings = MockSettings({})
    client = MockClient(settings)
    suite_items = [
        SuiteItem(
            'test',
            Location('tests/IT/stub/stub_A.py', 'stub_A', 'TestClass',
                     'test_A', 1))
    ]
    scheduler = Scheduler(settings, client, suite_items, 'my_worker_id',
                          MockSerializer)

    await scheduler.on_server_message(MessageType.Suite.value, None)

    assert client.received == [
        (MessageType.Suite, suite_items),
    ]

    await scheduler.stop()
Ejemplo n.º 19
0
def collect_test(node):
    location = node_to_location(node)
    fixtures = collect_fixtures(node)
    collect_item(
        SuiteItem('test', location, deps=fixtures, tags=parse_tags(node.obj)))
    tests_by_file[location.file].append(node)
def test_class_nested(testdir):
    test_file = 'fixtures/test_class_nested.py'
    (result, scheduler) = run_test(testdir, [test_file])
    assert_outcomes(result, passed=2)

    assert scheduler.suite_items == [
        SuiteItem(
            'class',
            Location(test_file, module_for(test_file), 'TestOuter', None, 1)),
        SuiteItem(
            'class',
            Location(test_file, module_for(test_file), 'TestOuter.TestInner',
                     None, 3)),
        SuiteItem('file', Location(test_file), size=42),
        SuiteItem('setup',
                  Location(test_file, module_for(test_file), 'TestOuter',
                           'setup_class', 22),
                  scope='class'),
        SuiteItem('setup',
                  Location(test_file, module_for(test_file), 'TestOuter',
                           'setup_method', 30),
                  scope='method'),
        SuiteItem('setup',
                  Location(test_file, module_for(test_file),
                           'TestOuter.TestInner', 'setup_class', 5),
                  scope='class'),
        SuiteItem('setup',
                  Location(test_file, module_for(test_file),
                           'TestOuter.TestInner', 'setup_method', 13),
                  scope='method'),
        SuiteItem('teardown',
                  Location(test_file, module_for(test_file), 'TestOuter',
                           'teardown_class', 26),
                  scope='class'),
        SuiteItem('teardown',
                  Location(test_file, module_for(test_file), 'TestOuter',
                           'teardown_method', 33),
                  scope='method'),
        SuiteItem('teardown',
                  Location(test_file, module_for(test_file),
                           'TestOuter.TestInner', 'teardown_class', 9),
                  scope='class'),
        SuiteItem('teardown',
                  Location(test_file, module_for(test_file),
                           'TestOuter.TestInner', 'teardown_method', 16),
                  scope='method'),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), 'TestOuter', 'test',
                     36)),
        SuiteItem(
            'test',
            Location(test_file, module_for(test_file), 'TestOuter.TestInner',
                     'test', 19)),
    ]

    assert scheduler.report_items == [
        ReportItem(
            'setup',
            Location(test_file, module_for(test_file), 'TestOuter',
                     'setup_class', 22), 'passed'),
        ReportItem(
            'setup',
            Location(test_file, module_for(test_file), 'TestOuter',
                     'setup_method', 30), 'passed'),
        ReportItem(
            'setup',
            Location(test_file, module_for(test_file), 'TestOuter.TestInner',
                     'setup_class', 5), 'passed'),
        ReportItem(
            'setup',
            Location(test_file, module_for(test_file), 'TestOuter.TestInner',
                     'setup_method', 13), 'passed'),
        ReportItem(
            'teardown',
            Location(test_file, module_for(test_file), 'TestOuter',
                     'teardown_class', 26), 'passed'),
        ReportItem(
            'teardown',
            Location(test_file, module_for(test_file), 'TestOuter',
                     'teardown_method', 33), 'passed'),
        ReportItem(
            'teardown',
            Location(test_file, module_for(test_file), 'TestOuter.TestInner',
                     'teardown_class', 9), 'passed'),
        ReportItem(
            'teardown',
            Location(test_file, module_for(test_file), 'TestOuter.TestInner',
                     'teardown_method', 16), 'passed'),
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), 'TestOuter', 'test',
                     36), 'passed'),
        ReportItem(
            'test',
            Location(test_file, module_for(test_file), 'TestOuter.TestInner',
                     'test', 19), 'passed'),
    ]
def test_class_inheritance(testdir):
    (result, scheduler) = run_test(testdir, [
        'fixtures/test_class_inheritance_1.py',
        'fixtures/test_class_inheritance_2.py'
    ])
    assert_outcomes(result, passed=3)

    assert scheduler.suite_items == [
        SuiteItem(
            'class',
            Location('fixtures/test_class_inheritance_1.py',
                     'test_class_inheritance_1', 'TestObject1', None, 1)),
        SuiteItem(
            'class',
            Location('fixtures/test_class_inheritance_2.py',
                     'test_class_inheritance_2', 'TestObject2', None, 4)),
        SuiteItem('file',
                  Location('fixtures/test_class_inheritance_1.py'),
                  size=42),
        SuiteItem('file',
                  Location('fixtures/test_class_inheritance_2.py'),
                  size=42),
        SuiteItem('setup',
                  Location('fixtures/test_class_inheritance_1.py',
                           'test_class_inheritance_1', 'TestObject1',
                           'setup_class', 3),
                  scope='class'),
        SuiteItem('setup',
                  Location('fixtures/test_class_inheritance_2.py',
                           'test_class_inheritance_2', 'TestObject2',
                           'setup_class', 3),
                  scope='class'),
        SuiteItem('teardown',
                  Location('fixtures/test_class_inheritance_1.py',
                           'test_class_inheritance_1', 'TestObject1',
                           'teardown_class', 7),
                  scope='class'),
        SuiteItem('teardown',
                  Location('fixtures/test_class_inheritance_2.py',
                           'test_class_inheritance_2', 'TestObject2',
                           'teardown_class', 7),
                  scope='class'),
        SuiteItem(
            'test',
            Location('fixtures/test_class_inheritance_1.py',
                     'test_class_inheritance_1', 'TestObject1', 'test1', 11)),
        SuiteItem(
            'test',
            Location('fixtures/test_class_inheritance_2.py',
                     'test_class_inheritance_2', 'TestObject2', 'test1', 11)),
        SuiteItem(
            'test',
            Location('fixtures/test_class_inheritance_2.py',
                     'test_class_inheritance_2', 'TestObject2', 'test2', 6)),
    ]

    assert scheduler.report_items == [
        ReportItem(
            'setup',
            Location('fixtures/test_class_inheritance_1.py',
                     'test_class_inheritance_1', 'TestObject1', 'setup_class',
                     3), 'passed'),
        ReportItem(
            'setup',
            Location('fixtures/test_class_inheritance_2.py',
                     'test_class_inheritance_2', 'TestObject2', 'setup_class',
                     3), 'passed'),
        ReportItem(
            'teardown',
            Location('fixtures/test_class_inheritance_1.py',
                     'test_class_inheritance_1', 'TestObject1',
                     'teardown_class', 7), 'passed'),
        ReportItem(
            'teardown',
            Location('fixtures/test_class_inheritance_2.py',
                     'test_class_inheritance_2', 'TestObject2',
                     'teardown_class', 7), 'passed'),
        ReportItem(
            'test',
            Location('fixtures/test_class_inheritance_1.py',
                     'test_class_inheritance_1', 'TestObject1', 'test1', 11),
            'passed'),
        ReportItem(
            'test',
            Location('fixtures/test_class_inheritance_2.py',
                     'test_class_inheritance_2', 'TestObject2', 'test1', 11),
            'passed'),
        ReportItem(
            'test',
            Location('fixtures/test_class_inheritance_2.py',
                     'test_class_inheritance_2', 'TestObject2', 'test2', 6),
            'passed'),
    ]
Ejemplo n.º 22
0
async def test_successful_server_communication(config, mock_server):
    os.environ['MY_CI'] = 'true'
    settings = MockSettings({
        'api_domain': mock_server.url,
        'api_key': 'api_key',
        'api_retry_limit': '1',
        'api_wait_limit': '0',
        'build_dir': '/app',
        'build_id': config['build']['id'],
        'build_job': 'job',
        'enabled': True,
        'vcs_branch': 'master',
        'vcs_repo': 'github.com/myrepo',
        'vcs_revision': 'asd43da',
        'vcs_revision_message': 'my commit',
    })
    client = Client(settings)
    client.subscribe(settings)
    suite_items = [
        SuiteItem(
            'test',
            Location('tests/IT/stub/stub_A.py', 'stub_A', 'TestClass',
                     'test_A', 1)),
        SuiteItem('test',
                  Location('tests/IT/stub/stub_B.py', 'stub_B', 'TestClass',
                           'test_B', 1),
                  tags=[Tag('my_group', False)]),
        SuiteItem('test',
                  Location('tests/IT/stub/stub_C.py', 'stub_C', 'TestClass',
                           'test_C', 1),
                  deps=[
                      SuiteItem(
                          'fixture',
                          Location('tests/IT/stub/stub_fixture.py', 'fixtures',
                                   'FixtureClass', 'test_C', 0)),
                  ]),
    ]
    scheduler = Scheduler(settings, client, suite_items, 'my_worker_id')

    # (1) CONNECT

    await client.start()

    # (2) SERVER REQUESTS ENV

    await mock_server.send(MessageType.Envs, [{
        'name': 'CI',
        'conditions': ['my_CI'],
        'mapping': {}
    }])

    # (3) CLIENT REPLIES WITH ENV

    await assert_received_eventually(mock_server, [
        (MessageType.Envs.value, 'CI'),
        (MessageType.Ack.value, {
            'message_num': 0,
            'status': 'success'
        }),
    ])

    # (4) SERVER REQUESTS CONFIG

    await mock_server.send(MessageType.Config, {})

    # (5) CLIENT REPLIES WITH CONFIG

    await assert_received_eventually(mock_server, [
        (MessageType.Config.value, {
            'build': {
                'dir': '/app',
                'id': config['build']['id'],
                'job': 'job',
                'node': 'random-uuid',
                'pool': 0,
                'project': None,
                'url': None
            },
            'client': {
                'capabilities':
                ['fixtures', 'lifecycle_timings', 'split_by_file'],
                'messages': [
                    'ack', 'config', 'done', 'envs', 'error', 'report',
                    'schedules', 'suite'
                ],
                'name':
                'pytest-conquer',
                'version':
                '1.0',
                'workers':
                1,
                'worker_id':
                'my_worker_id',
            },
            'platform': {
                'name': 'python',
                'version': '3.6'
            },
            'runner': {
                'args': ['arg1'],
                'name': None,
                'plugins': [],
                'root': None,
                'version': None
            },
            'system': {
                'context': {},
                'cpus': 3,
                'os': 'Linux',
                'os_version': '1.42',
                'provider': 'CI',
                'ram': 17179869184
            },
            'vcs': {
                'branch': 'master',
                'pr': None,
                'repo': 'github.com/myrepo',
                'revision': 'asd43da',
                'revision_message': 'my commit',
                'tag': None,
                'type': 'git'
            },
        }),
        (MessageType.Ack.value, {
            'message_num': 1,
            'status': 'success'
        }),
    ])

    # (6) SERVER REQUESTS SUITE

    await mock_server.send(MessageType.Suite, {})

    # (7) CLIENT SENDS SUITE

    await assert_received_eventually(mock_server, [
        (MessageType.Suite.value, {
            'items': [
                {
                    'type': 'test',
                    'location': {
                        'file': 'tests/IT/stub/stub_A.py',
                        'func': 'test_A',
                        'module': 'stub_A',
                        'class': 'TestClass',
                        'line': 1
                    }
                },
                {
                    'type': 'test',
                    'location': {
                        'file': 'tests/IT/stub/stub_B.py',
                        'func': 'test_B',
                        'module': 'stub_B',
                        'class': 'TestClass',
                        'line': 1
                    },
                    'tags': [{
                        'group': 'my_group'
                    }]
                },
                {
                    'type':
                    'test',
                    'location': {
                        'file': 'tests/IT/stub/stub_C.py',
                        'func': 'test_C',
                        'module': 'stub_C',
                        'class': 'TestClass',
                        'line': 1
                    },
                    'deps': [{
                        'type': 'fixture',
                        'location': {
                            'file': 'tests/IT/stub/stub_fixture.py',
                            'func': 'test_C',
                            'module': 'fixtures',
                            'class': 'FixtureClass'
                        }
                    }]
                },
            ],
        }),
        (MessageType.Ack.value, {
            'message_num': 2,
            'status': 'success'
        }),
    ])

    # (8) SERVER SENDS SCHEDULE #1

    await mock_server.send(MessageType.Schedules, [{
        'id':
        '0',
        'items': [
            {
                'file': 'tests/IT/stub/stub_A.py'
            },
            {
                'file': 'tests/IT/stub/stub_B.py'
            },
        ],
    }])

    await assert_received_eventually(mock_server, [
        (MessageType.Ack.value, {
            'message_num': 3,
            'status': 'success'
        }),
    ])

    assert await scheduler.next() == Schedule('0', [
        ScheduleItem('tests/IT/stub/stub_A.py'),
        ScheduleItem('tests/IT/stub/stub_B.py'),
    ])

    # (9) CLIENT SENDS REPORT #1

    await scheduler.report(
        Report('0', [
            ReportItem(
                'test',
                Location('tests/IT/stub/stub_A.py', 'stub_A', 'TestClass',
                         'test_A', 3), 'failed',
                Failure('AssertionError', 'assert 1 + 1 == 4'), time, time),
            ReportItem(
                'test',
                Location('tests/IT/stub/stub_B.py', 'stub_B', 'TestClass',
                         'test_B', 1), 'passed', None, time, time),
        ], time, time, time))

    await assert_received_eventually(mock_server, [
        (MessageType.Ack.value, {
            'schedule_id': '0',
            'status': 'success'
        }),
        (MessageType.Report.value, {
            'schedule_id':
            '0',
            'items': [{
                'type': 'test',
                'location': {
                    'file': 'tests/IT/stub/stub_A.py',
                    'func': 'test_A',
                    'module': 'stub_A',
                    'class': 'TestClass',
                    'line': 3
                },
                'status': 'failed',
                'started_at': '2000-01-01T00:00:00.000Z',
                'finished_at': '2000-01-01T00:00:00.000Z',
                'error': {
                    'type': 'AssertionError',
                    'message': 'assert 1 + 1 == 4'
                },
            }, {
                'type': 'test',
                'location': {
                    'file': 'tests/IT/stub/stub_B.py',
                    'func': 'test_B',
                    'module': 'stub_B',
                    'class': 'TestClass',
                    'line': 1
                },
                'status': 'passed',
                'started_at': '2000-01-01T00:00:00.000Z',
                'finished_at': '2000-01-01T00:00:00.000Z',
            }],
            'pending_at':
            '2000-01-01T00:00:00.000Z',
            'started_at':
            '2000-01-01T00:00:00.000Z',
            'finished_at':
            '2000-01-01T00:00:00.000Z',
        }),
    ])

    # (10) SERVER SENDS SCHEDULE #2

    await mock_server.send(MessageType.Schedules,
                           [{
                               'id': '1',
                               'items': [
                                   {
                                       'file': 'tests/IT/stub/stub_C.py'
                                   },
                               ],
                           }])

    await assert_received_eventually(mock_server, [
        (MessageType.Ack.value, {
            'message_num': 4,
            'status': 'success'
        }),
    ])

    assert await scheduler.next() == Schedule('1', [
        ScheduleItem('tests/IT/stub/stub_C.py'),
    ])

    # (12) CLIENT SENDS REPORT #2

    await scheduler.report(
        Report('1', [
            ReportItem(
                'test',
                Location('tests/IT/stub/stub_C.py', 'stub_C', 'TestClass',
                         'test_C', 1), 'passed', None, time, time),
        ], time, time, time))

    await assert_received_eventually(mock_server, [
        (MessageType.Ack.value, {
            'schedule_id': '1',
            'status': 'success'
        }),
        (MessageType.Report.value, {
            'schedule_id':
            '1',
            'items': [{
                'type': 'test',
                'location': {
                    'file': 'tests/IT/stub/stub_C.py',
                    'func': 'test_C',
                    'module': 'stub_C',
                    'class': 'TestClass',
                    'line': 1
                },
                'status': 'passed',
                'started_at': '2000-01-01T00:00:00.000Z',
                'finished_at': '2000-01-01T00:00:00.000Z',
            }],
            'pending_at':
            '2000-01-01T00:00:00.000Z',
            'started_at':
            '2000-01-01T00:00:00.000Z',
            'finished_at':
            '2000-01-01T00:00:00.000Z',
        }),
    ])

    # (13) SERVER SENDS DONE

    await mock_server.send(MessageType.Done, {})
    await asyncio.sleep(0.1)
    assert scheduler.more is False

    # (14) SHUTDOWN

    await scheduler.stop()
    await client.stop()