コード例 #1
0
 def test_dependency_manager(self):
     dependency_manager = DependencyManager()
     assert dependency_manager is not None
     latest_dependencies = dependency_manager.get_latest_version_dependencies()
     assert isinstance(latest_dependencies, dict)
     assert latest_dependencies["org.gel.models.report.avro"] == protocols.reports_6_2_0
     dependencies_400 = dependency_manager.get_version_dependencies("4.0.0")
     assert isinstance(dependencies_400, dict)
     assert dependencies_400["org.gel.models.report.avro"] == protocols.reports_4_0_0
     assert dependencies_400["org.gel.models.report.avro"] != protocols.reports_4_2_0
コード例 #2
0
def mock_schema(protocol, version, fill_nullables):
    """
    :type protocol: Protocol
    :param version: the package version as registered in the dependency manager
    :type version: str
    :return: a dictionary following the schema of the protocol containing mocked values
    :rtype: dict
    """
    expected_schema = protocol.schema
    dependency_manager = DependencyManager()
    if version is not None:
        dependencies = dependency_manager.get_version_dependencies(version)
    else:
        dependencies = dependency_manager.get_latest_version_dependencies()

    mock_result = {}
    for field in expected_schema.fields:
        field_type = field.type.type
        field_name = field.name
        mock_result[field_name] = mock_field(field, field_type, dependencies,
                                             version, fill_nullables)
    return mock_result