示例#1
0
def set_type_attributes_correct():
    table = Table("table.txt")
    score = 0
    try:
        table.set_type("configuration")
        if table.get_attributes() == CONFIGURATION_ATTRIBUTES and table.get_degree() == 3 and table.get_key() == CONFIGURATION_KEY:
            score+=1
    except:
        a = 0
    table = Table("table.txt")
    try:
        table.set_type("inverted_index")
        if table.get_attributes() == INVERTED_INDEX_ATTRIBUTES and table.get_degree() == 2 and table.get_key() == INVERTED_INDEX_KEY:
            score+=1        
    except:
        a = 0
    return str(score)  
示例#2
0
def set_attributes_correct():
    table = Table("table.txt")
    try:
        table.set_attributes(["name", "age", "weight"])
        if table.get_attributes() == ["name", "age", "weight"] and table.get_degree() == 3 and table.get_key() == "name":
            return "2"
    except:
        return "0"
    return "0"
示例#3
0
def getters_raise_exceptions():
    table = Table("table.txt")
    try:
        table.get_degree()
        return "0"
    except:
        a = 0
    try:
        table.get_attributes()
        return "0"
    except:
        a = 0
    try:
        table.get_key()
        return "0"
    except:
        a = 0
    return "1"