Ejemplo n.º 1
0
def test_requirementobj__init__defaults():
    obj = versions.RequirementObj(call=("echo", "foo"),
                                  search=r"(\d+)\.(\d+)",
                                  checks=versions.Any())

    assert_equal(obj.name, "echo")
    assert_equal(obj.priority, 0)
Ejemplo n.º 2
0
def test_requirementobj__version__version_str_not_found():
    call = _echo_version("A typical error\n")
    obj = versions.RequirementObj(call=call,
                                  search=r"v(\d+)\.(\d+)",
                                  checks=versions.Any())

    assert_raises(versions.VersionRequirementError, getattr, obj, "version")
Ejemplo n.º 3
0
def test_requirementobj__version__func_call():
    def _return_version():
        return "This is v5.3!"

    obj = versions.RequirementObj(call=_return_version,
                                  search=r"v(\d+)\.(\d+)",
                                  checks=versions.Any())
    assert_equal(obj.version, (5, 3))
Ejemplo n.º 4
0
def test_requirementobj__version__func_call_with_arguments():
    def _return_version(arg1, arg2):
        assert_equal((arg1, arg2), (2, "foo"))
        return "This is v5.3!"

    obj = versions.RequirementObj(call=(_return_version, 2, "foo"),
                                  search=r"v(\d+)\.(\d+)",
                                  checks=versions.Any())
    assert_equal(obj.version, (5, 3))
Ejemplo n.º 5
0
def test_requirementobj__init__non_defaults():
    obj = versions.RequirementObj(call=("bash", "foo"),
                                  search=r"(\d+)\.(\d+)",
                                  checks=versions.Any(),
                                  name="A name",
                                  priority=17)

    assert_equal(obj.name, "A name")
    assert_equal(obj.priority, 17)
Ejemplo n.º 6
0
def test_check__can_pickle():
    def _do_test_can_pickle(obj):
        pickle.dumps(obj)

    yield _do_test_can_pickle, versions.EQ(1, 2, 3)
    yield _do_test_can_pickle, versions.GE(1, 2, 3)
    yield _do_test_can_pickle, versions.LT(1, 2, 3)
    yield _do_test_can_pickle, versions.Any()
    yield _do_test_can_pickle, versions.And(versions.EQ(1, 2, 3))
    yield _do_test_can_pickle, versions.Or(versions.GE(1, 2, 3))
Ejemplo n.º 7
0
    def _do_test_outdated_jre(message):
        obj = versions.RequirementObj(call=lambda: message,
                                      search=r"v(\d+)\.(\d+)",
                                      checks=versions.Any())

        try:
            obj.version
            assert False  # pragma: no coverage
        except versions.VersionRequirementError, error:
            assert_in(error_msg, str(error))
Ejemplo n.º 8
0
def test_requirementobj__version__command_not_found():
    obj = versions.RequirementObj(call=("xyzabcdefoo",),
                                  search=r"v(\d+)\.(\d+)",
                                  checks=versions.Any())

    try:
        obj.version  # pylint: disable=
        assert False  # pragma: no coverage
    except versions.VersionRequirementError, error:
        # Should include OSError message
        assert_in("No such file or directory", str(error))
Ejemplo n.º 9
0
def _get_gatk_version_check(config):
    """Returns a version-check object for the "GenomeAnalysisTK.jar" located at
    config.jar_root; for now, this check only serves to verify that the JAR can
    be executed, which may not be the case if the JRE is outdated.
    """
    jar_file = os.path.join(config.jar_root, "GenomeAnalysisTK.jar")
    if jar_file not in _GATK_VERSION:
        params = AtomicJavaCmdBuilder(jar_file,
                                      temp_root=config.temp_root,
                                      jre_options=config.jre_options)
        params.add_value("--version")

        # Any version is fine; for now just catch old JREs
        requirement = versions.Requirement(call=params.finalized_call,
                                           name="GenomeAnalysisTK",
                                           search=r"^(\d+)\.(\d+)",
                                           checks=versions.Any())
        _GATK_VERSION[jar_file] = requirement
    return _GATK_VERSION[jar_file]
Ejemplo n.º 10
0
def test_requirementobj__version__return_code_is_ignored():
    obj = versions.RequirementObj(_echo_version("v1.2.3", returncode=1),
                                  search=r"v(\d+)\.(\d+)",
                                  checks=versions.Any())
    assert_equal(obj.version, (1, 2))
Ejemplo n.º 11
0
 def _do_test_version__single_digit(pipe, regexp, equals):
     call = _echo_version("v3.5.2\n", to=pipe)
     obj = versions.RequirementObj(call=call,
                                   search=regexp,
                                   checks=versions.Any())
     assert_equal(obj.version, equals)
Ejemplo n.º 12
0
def test_lt__check_values__always_true():
    obj = versions.Any()
    assert obj((1,))
    assert obj((2, 3))
    assert obj((4, 5, 6))
    assert obj((5, 6, 7, 8))
Ejemplo n.º 13
0
def test_any__str():
    obj = versions.Any()
    assert_equal(str(obj), "any version")