# Path: tests/fixtures/build_fixture.py
# def build_fixture(modulename, data_variable_name='DATA'):
#     fixtures = deepcopy(
#         getattr(
#             importlib.import_module('..%s' % modulename, __name__),
#             data_variable_name,
#         )
#     )
# 
#     if 'submissions_xml' in fixtures:
#         # This fixture contains XML submissions, which apparently aren't used
#         # for anything yet; see
#         # `TestFormPackFixtures.test_xml_instances_loaded()`.
#         # Example XML fixture: tests/fixtures/favcolor/xml_instances.json
#         return fixtures
# 
#     title = fixtures.get('title')
# 
#     # separate the submissions from the schema
#     schemas = [dict(v) for v in fixtures['versions']]
#     submissions = []
#     for schema in schemas:
#         version = schema.get('version')
#         version_id_key = schema.get('version_id_key', '__version__')
#         for submission in schema.pop('submissions'):
#             submission.update({version_id_key: version})
#             submissions.append(submission)
#     return title, schemas, submissions


import json
import pytest
import pyxform
from copy import deepcopy
from nose.tools import raises
from formpack import FormPack, constants
from formpack.utils.iterator import get_first_occurrence
from .fixtures import build_fixture
from formpack.schema.datadef import FormGroup
        },
    ]
    fp = FormPack(schemas)
    fields = fp.get_fields_for_versions(fp.versions)
    choice_names = fields[0].choice.options.keys()
    assert 'first_version_choice_name' in choice_names
    assert 'second_version_choice_name' in choice_names


def test_field_position_with_multiple_versions():
    title, schemas, submissions = build_fixture(
        'field_position_with_multiple_versions'
    )
    fp = FormPack(schemas, title)

    all_fields = fp.get_fields_for_versions(fp.versions.keys())
    expected = [
        'City',
        'Firstname',
        'Lastname',
        'Gender',
        'Age',
        'Fullname',
    ]
    field_names = [field.name for field in all_fields]
    assert len(all_fields) == 6
    assert field_names == expected


def test_fields_for_versions_list_index_out_of_range():

# Path: tests/fixtures/build_fixture.py
# def build_fixture(modulename, data_variable_name='DATA'):
#     fixtures = deepcopy(
#         getattr(
#             importlib.import_module('..%s' % modulename, __name__),
#             data_variable_name,
#         )
#     )
# 
#     if 'submissions_xml' in fixtures:
#         # This fixture contains XML submissions, which apparently aren't used
#         # for anything yet; see
#         # `TestFormPackFixtures.test_xml_instances_loaded()`.
#         # Example XML fixture: tests/fixtures/favcolor/xml_instances.json
#         return fixtures
# 
#     title = fixtures.get('title')
# 
#     # separate the submissions from the schema
#     schemas = [dict(v) for v in fixtures['versions']]
#     submissions = []
#     for schema in schemas:
#         version = schema.get('version')
#         version_id_key = schema.get('version_id_key', '__version__')
#         for submission in schema.pop('submissions'):
#             submission.update({version_id_key: version})
#             submissions.append(submission)
#     return title, schemas, submissions


# Path: tests/test_formpack_internals.py
import json
import pytest
import pyxform
from copy import deepcopy
from nose.tools import raises
from formpack import FormPack, constants
from formpack.utils.iterator import get_first_occurrence
from .fixtures import build_fixture
from formpack.schema.datadef import FormGroup

        },
    ]
    fp = FormPack(schemas)
    fields = fp.get_fields_for_versions(fp.versions)
    choice_names = fields[0].choice.options.keys()
    assert 'first_version_choice_name' in choice_names
    assert 'second_version_choice_name' in choice_names


def test_field_position_with_multiple_versions():
    title, schemas, submissions = build_fixture(
        'field_position_with_multiple_versions'
    )
    fp = FormPack(schemas, title)

    all_fields = fp.get_fields_for_versions(fp.versions.keys())
    expected = [
        'City',
        'Firstname',
        'Lastname',
        'Gender',
        'Age',
        'Fullname',
    ]
    field_names = [field.name for field in all_fields]
    assert len(all_fields) == 6
    assert field_names == expected


def test_fields_for_versions_list_index_out_of_range():

    title, schemas, submissions = build_fixture(