Exemplo n.º 1
0
def test_go_rule29():
    # Nov 11, 1990, more than a year old
    assoc = make_annotation(evidence="IEA", date="19901111").associations[0]

    ## Base test: old IEA.
    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.ERROR

    ## Pass if not IEA
    assoc.evidence.type = Curie.from_str("ECO:0000305")  # Not IEA
    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    ## Pass if only a half year old.
    now = datetime.datetime.now()
    six_months_ago = now - datetime.timedelta(days=180)
    assoc.date = six_months_ago.strftime("%Y%m%d")
    assoc.evidence.type = Curie.from_str("ECO:0000501")
    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    ## Warning if a year and a half year old.
    eighteen_months_ago = now - datetime.timedelta(days=(30*18))
    assoc.date = eighteen_months_ago.strftime("%Y%m%d")
    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.WARNING
Exemplo n.º 2
0
def test_go_rule29():
    a = ["blah"] * 15
    a[3] = ""
    a[6] = "IEA"
    a[8] = "P"
    a[13] = "19901111" # Nov 11, 1990, more than a year old
    assoc = gafparser.to_association(a).associations[0]

    ## Base test: old IEA.
    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.ERROR

    ## Pass if not IEA
    assoc.evidence.type = "ECO:0000305" #Not IEA
    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    ## Pass if only a half year old.
    now = datetime.datetime.now()
    six_months_ago = now - datetime.timedelta(days=180)
    assoc.date = six_months_ago.strftime("%Y%m%d")
    assoc.evidence.type = "ECO:0000501"
    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    ## Warning if a year and a half year old.
    eighteen_months_ago = now - datetime.timedelta(days=(30*18))
    assoc.date = eighteen_months_ago.strftime("%Y%m%d")
    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.WARNING
Exemplo n.º 3
0
def test_go_rule29():

    # Nov 11, 1990, more than a year old
    assoc = make_annotation(evidence="IEA", date="19901111").associations[0]

    ## Base test: old IEA.
    test_result = qc.GoRule29().test(assoc, all_rules_config())
    assert test_result.result_type == qc.ResultType.ERROR

    ## Pass if not IEA
    assoc.evidence.type = Curie.from_str(ic_eco)  # Not IEA
    test_result = qc.GoRule29().test(assoc, all_rules_config())
    assert test_result.result_type == qc.ResultType.PASS

    ## Pass if only a half year old.
    now = datetime.datetime.now()
    six_months_ago = now - datetime.timedelta(days=180)
    assoc.date = association.Date(six_months_ago.year, six_months_ago.month,
                                  six_months_ago.day, "")
    assoc.evidence.type = Curie.from_str(iea_eco)
    test_result = qc.GoRule29().test(assoc, all_rules_config())
    assert test_result.result_type == qc.ResultType.PASS

    ## Warning if a year and a half year old.
    eighteen_months_ago = now - datetime.timedelta(days=(30 * 18))
    assoc.date = association.Date(eighteen_months_ago.year,
                                  eighteen_months_ago.month,
                                  eighteen_months_ago.day, "")
    test_result = qc.GoRule29().test(assoc, all_rules_config())
    assert test_result.result_type == qc.ResultType.WARNING

    ## Confirm the test can parse a YYYY-MM-DD date format from GPAD 2.0
    gpad_2_0_vals = assoc.to_gpad_2_0_tsv(
    )  # Cheat to shortcut DB and DB_Object_ID concatenation
    gpad_2_0_vals[5] = iea_eco
    gpad_2_0_vals[8] = "1990-11-11"
    assoc = gpadparser.to_association(gpad_2_0_vals,
                                      version="2.0").associations[0]
    test_result = qc.GoRule29().test(assoc, all_rules_config())
    assert test_result.result_type == qc.ResultType.ERROR
Exemplo n.º 4
0
def test_go_rule29():
    a = ["blah"] * 16
    a[6] = "IEA"
    a[13] = "19901111"  # Nov 11, 1990, more than a year old

    test_result = qc.GoRule29().test(a, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.ERROR

    a = ["blah"] * 16
    a[6] = "FOO"
    a[13] = "19901111"

    test_result = qc.GoRule29().test(a, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    now = datetime.datetime.now()
    six_months_ago = now - datetime.timedelta(days=180)
    a = ["blah"] * 16
    a[6] = "IEA"
    a[13] = six_months_ago.strftime("%Y%m%d")

    test_result = qc.GoRule29().test(a, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS
Exemplo n.º 5
0
def test_go_rule29():
    a = ["blah"] * 15
    a[3] = ""
    a[6] = "IEA"
    a[8] = "P"
    a[13] = "19901111"  # Nov 11, 1990, more than a year old
    assoc = gafparser.to_association(a).associations[0]

    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.ERROR

    assoc.evidence.type = "ECO:0000305"  #Not IEA

    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS

    now = datetime.datetime.now()
    six_months_ago = now - datetime.timedelta(days=180)
    assoc.date = six_months_ago.strftime("%Y%m%d")
    assoc.evidence.type = "ECO:0000501"

    test_result = qc.GoRule29().test(assoc, assocparser.AssocParserConfig())
    assert test_result.result_type == qc.ResultType.PASS