Exemplo n.º 1
0
def test_independent_tags():

    ddb = DefectsDB(TEST_DATABASE, read_only=False)

    # Create two defects
    create_defect_type(ddb, 0)
    create_defect_type(ddb, 1)
    create_defect_type(ddb, 2)

    ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "", "")
    ddb.insert("DQD_TEST_DEFECT_1", 100, 200, "", "")
    ddb.insert("DQD_TEST_DEFECT_2", 200, 300, "", "")

    dtag1 = ddb.new_defects_tag("dqd-test", "New iov tag")

    ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "", "", present=False)

    dtag2 = ddb.new_defects_tag("dqd-test-2", "New iov tag")

    # Make a virtual defect whose result is the combination of the above
    ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "",
                           "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")

    ltag1 = ddb.new_logics_tag()

    ddb.update_virtual_defect("DQD_TEST_VIRTUAL_DEFECT",
                              "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_2")

    ltag2 = ddb.new_logics_tag()

    iovs = DefectsDB(
        TEST_DATABASE,
        tag=("HEAD", ltag1)).retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
    assert iov_ranges(iovs) == [(100, 200)], str(iov_ranges(iovs))

    iovs = DefectsDB(
        TEST_DATABASE,
        tag=("HEAD", ltag2)).retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
    assert iov_ranges(iovs) == [(200, 300)], str(iov_ranges(iovs))

    iovs = DefectsDB(
        TEST_DATABASE,
        tag=(dtag1, ltag1)).retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
    assert iov_ranges(iovs) == [(0, 100), (100, 200)], str(iov_ranges(iovs))

    iovs = DefectsDB(
        TEST_DATABASE,
        tag=(dtag2, ltag2)).retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
    assert iov_ranges(iovs) == [(200, 300)], str(iov_ranges(iovs))

    htag = ddb.new_hierarchical_tag(dtag2, ltag2)

    iovs = DefectsDB(TEST_DATABASE,
                     tag=(htag,
                          htag)).retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
    assert iov_ranges(iovs) == [(200, 300)], str(iov_ranges(iovs))

    iovs = DefectsDB(TEST_DATABASE,
                     tag=htag).retrieve(channels=["DQD_TEST_VIRTUAL_DEFECT"])
    assert iov_ranges(iovs) == [(200, 300)], str(iov_ranges(iovs))
Exemplo n.º 2
0
def test_tagging_unicode():

    ddb = DefectsDB(TEST_DATABASE, read_only=False)

    # Create two defects
    create_defect_type(ddb, 0)
    create_defect_type(ddb, 1)

    ddb.insert(u"DQD_TEST_DEFECT_0", 0, 100, u"", u"")
    ddb.insert(u"DQD_TEST_DEFECT_1", 100, 200, u"", u"")

    defects_tag = ddb.new_defects_tag("dqd-test", u"New iov tag")

    # Make a virtual defect whose result is the combination of the above
    ddb.new_virtual_defect(u"DQD_TEST_VIRTUAL_DEFECT", u"",
                           u"DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")

    original_tag = ddb.new_logics_tag()
    original_htag = ddb.new_hierarchical_tag(defects_tag, original_tag)

    what = {"channels": [u"DQD_TEST_VIRTUAL_DEFECT"]}

    orig_iovs = DefectsDB((TEST_DATABASE),
                          tag=six.ensure_text(original_htag)).retrieve(**what)

    assert len(orig_iovs) == 2
    assert (orig_iovs[0].since, orig_iovs[0].until) == (0, 100)
    assert (orig_iovs[1].since, orig_iovs[1].until) == (100, 200)
Exemplo n.º 3
0
def test_update_virtual_defect():

    ddb = DefectsDB(TEST_DATABASE, read_only=False)

    # Create two defects
    create_defect_type(ddb, 0)
    create_defect_type(ddb, 1)
    create_defect_type(ddb, 2)

    ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "", "")
    ddb.insert("DQD_TEST_DEFECT_1", 100, 200, "", "")
    ddb.insert("DQD_TEST_DEFECT_2", 200, 300, "", "")

    defects_tag = ddb.new_defects_tag("dqd-test", "New iov tag")

    # Make a virtual defect whose result is the combination of the above
    ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "",
                           "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")

    original_tag = ddb.new_logics_tag()
    original_htag = ddb.new_hierarchical_tag(defects_tag, original_tag)

    ddb.update_virtual_defect("DQD_TEST_VIRTUAL_DEFECT",
                              "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_2")

    new_tag = ddb.new_logics_tag()
    new_htag = ddb.new_hierarchical_tag(defects_tag, new_tag)

    what = {"channels": ["DQD_TEST_VIRTUAL_DEFECT"]}

    orig_iovs = DefectsDB(TEST_DATABASE, tag=original_htag).retrieve(**what)
    new_iovs = DefectsDB(TEST_DATABASE, tag=new_htag).retrieve(**what)
    head_iovs = DefectsDB(TEST_DATABASE).retrieve(**what)

    assert head_iovs == new_iovs
    assert head_iovs != orig_iovs

    assert len(head_iovs) == 2
    assert (head_iovs[0].since, head_iovs[0].until) == (0, 100)
    assert (head_iovs[1].since, head_iovs[1].until) == (200, 300)

    from DQUtils.db import Databases
    db3 = Databases.get_instance(TEST_DATABASE, read_only=True)
    pfs = db3.getFolderSet('/GLOBAL/DETSTATUS')
    assert pfs.tagDescription(
        new_htag) != '', 'Hierarchical tag description not created'
Exemplo n.º 4
0
def test_rename_defects():
    
    ddb = DefectsDB(TEST_DATABASE, read_only=False)
    
    # Create two defects
    create_defect_type(ddb, 0)
    create_defect_type(ddb, 1)
    
    ddb.insert("DQD_TEST_DEFECT_0",   0, 100, "", "")
    ddb.insert("DQD_TEST_DEFECT_1", 100, 200, "", "")
    
    defects_tag = ddb.new_defects_tag("dqd-test", "New iov tag")
    
    # Make a virtual defect whose result is the combination of the above
    ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "", 
                           "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
    ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT_2", "", 
                           "DQD_TEST_VIRTUAL_DEFECT")
    # Make ones with inversion logic
    ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT_3", "", 
                           "DQD_TEST_DEFECT_0 !DQD_TEST_DEFECT_1")
    ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT_4", "", 
                           "!DQD_TEST_VIRTUAL_DEFECT")
    
    original_tag = ddb.new_logics_tag()
    original_htag = ddb.new_hierarchical_tag(defects_tag, original_tag)

    # The following is no longer considered an error condition
    ## exc_raised = False
    ## try:
    ##     ddb.rename_defect("DQD_TEST_DEFECT_0", "DQD_TEST_0")
    ## except AssertionError:
    ##     exc_raised = True
    ## assert exc_raised, "Bad defect rename did not raise exception"

    # first rename a primary defect
    ddb.rename_defect("DQD_TEST_DEFECT_0", "DQD_TEST_DEFECT_3")
    assert ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT'].clauses == ['DQD_TEST_DEFECT_3', 'DQD_TEST_DEFECT_1'], ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT'].clauses
    assert ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_3'].clauses == ['DQD_TEST_DEFECT_3', '!DQD_TEST_DEFECT_1'], ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_3'].clauses

    # also valid in other tags?
    ddb2 = DefectsDB(TEST_DATABASE, tag=original_htag)
    assert ddb2.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT'].clauses == ['DQD_TEST_DEFECT_3', 'DQD_TEST_DEFECT_1'], ddb2.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT'].clauses

    # Now try to rename a virtual defect
    ddb.rename_defect("DQD_TEST_VIRTUAL_DEFECT", "DQD_TEST_VIRTUAL_DEFECT_A")

    assert ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_2'].clauses == ['DQD_TEST_VIRTUAL_DEFECT_A'], ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_2'].clauses
    assert ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_4'].clauses == ['!DQD_TEST_VIRTUAL_DEFECT_A'], ddb.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_4'].clauses

    # also valid in other tags?
    ddb2 = DefectsDB(TEST_DATABASE, tag=original_htag)
    assert ddb2.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_2'].clauses == ['DQD_TEST_VIRTUAL_DEFECT_A'], ddb2.virtual_defect_logics['DQD_TEST_VIRTUAL_DEFECT_2'].clauses

    ddb._virtual_defect_consistency_check()
Exemplo n.º 5
0
def test_virtual_defect_hiding():
    ddb = DefectsDB(TEST_DATABASE, read_only=False)
    
    # Create two defects
    create_defect_type(ddb, 0)
    create_defect_type(ddb, 1)
    
    # Make a virtual defect whose result is the combination of the above
    ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "Comment", 
                           "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")
        
    new_tag = ddb.new_logics_tag()
                       
    ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT_2", "Comment",
                           "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")

    ddb2 = DefectsDB(TEST_DATABASE, tag=('HEAD', new_tag), read_only=True)
    assert ddb2.virtual_defect_names == set(['DQD_TEST_VIRTUAL_DEFECT']), 'Only one virtual defect should be in this tag'