Esempio n. 1
0
def _createPhoto(_pDir, _pFileName):
    "Register a photo object in the photos table."
    print ("adding file %s/%s" % (_pDir, _pFileName))
    _lFullPath = "%s/%s" % (_pDir, _pFileName)
    _lDate = datetime.datetime.fromtimestamp(os.path.getctime(_lFullPath))
    lAffinity.q("INSERT (testphotos2_id, testphotos2_date, testphotos2_time, testphotos2_path, testphotos2_name, testphotos2_fullname) VALUES ('%s', TIMESTAMP'%s', INTERVAL'%s', '%s', '%s', '%s');" % \
        (uuid.uuid4().hex, AffinityTest.strftime(_lDate, "%4Y-%2m-%2d"), AffinityTest.strftime(_lDate, "%2H:%2M:%2S"), _pDir, _pFileName, _lFullPath))
Esempio n. 2
0
def _createPhoto(_pDir, _pFileName):
    "Register a photo object in the photos table."
    print ("adding file %s/%s" % (_pDir, _pFileName))
    _lFullPath = "%s/%s" % (_pDir, _pFileName)
    _lDate = datetime.datetime.fromtimestamp(os.path.getctime(_lFullPath))
    lAffinity.q("INSERT (\"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hasHash\", \"http://www.w3.org/2001/XMLSchema#date\", \"http://www.w3.org/2001/XMLSchema#time\", \"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileUrl\", \"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName\") VALUES ('%s', TIMESTAMP'%s', INTERVAL'%s', '%s', '%s');" % \
        (uuid.uuid4().hex, AffinityTest.strftime(_lDate, "%4Y-%2m-%2d"), AffinityTest.strftime(_lDate, "%2H:%2M:%2S"), _pDir, _pFileName))
Esempio n. 3
0
                lLeftCn = "http://testrete1/hier/cb%dto%d" % (pFrom, lMid)
                self.mDbConn.q("CREATE CLASS \"%s\" AS SELECT * FROM \"%s\" WHERE \"http://testrete1/hier/v\" >= %d AND \"http://testrete1/hier/v\" <= %d" % (lLeftCn, pBase, pFrom, lMid))
            else:
                lLeftCn = pBase                
            self.createClasses(pFrom, lMid, lLeftCn)
            # right
            if lMid + 1 < pTo:
                lRightCn = "http://testrete1/hier/cb%dto%d" % (lMid + 1, pTo)
                self.mDbConn.q("CREATE CLASS \"%s\" AS SELECT * FROM \"%s\" WHERE \"http://testrete1/hier/v\" >= %d AND \"http://testrete1/hier/v\" <= %d" % (lRightCn, pBase, lMid + 1, pTo))
            else:
                lRightCn = pBase
            self.createClasses(lMid + 1, pTo, lRightCn)
    def run(self):
        for iC in xrange(TESTRETE1_NUMCHECKS):
            self.mDbConn.q("INSERT \"http://testrete1/hier/v\"=%d" % (random.randrange(0, TESTRETE1_NUMCLASSES)))
    def check(self):
        lTot = 0
        for iC in xrange(TESTRETE1_NUMCLASSES):
            lTot += self.mDbConn.qCount("SELECT * FROM \"http://testrete1/hier/c%d\"" % iC)
        return lTot

class TestRete1(AffinityTest):
    "A basic test for flat vs hierarchical classification."
    def execute(self):
        _entryPoint()
AffinityTest.declare(TestRete1)

if __name__ == '__main__':
    lT = TestRete1()
    lT.execute()
Esempio n. 4
0
            pHandlerData=time.time(),
            pGroupNotifs=True,
        )
        print(" sleeping 10 seconds")
        time.sleep(10)
        with CheckCounts(0, 1):
            print("15. change related pin %s" % lNewPins[1].mPID)
            lNewPins[1]["http://localhost/afy/property/testnotifications1/name"] = "Pablo"
            print(" sleeping 20 seconds")
            time.sleep(20)
        with CheckCounts(0, 1):
            print("16. change related pin %s" % lNewPins[1].mPID)
            lNewPins[1]["http://localhost/afy/property/testnotifications1/name"] = "Paolo"
            time.sleep(1)
        print("17. unregister")
        AFYNOTIFIER.unregisterClass("http://localhost/afy/class/testnotifications1/Named", onClassNotif)


class TestNotifications1(AffinityTest):
    "A basic test for notifications."

    def execute(self):
        _entryPoint()


AffinityTest.declare(TestNotifications1)

if __name__ == "__main__":
    lT = TestNotifications1()
    lT.execute()
Esempio n. 5
0
        print ("user %s has tags %s" % (_pUser, _lTags))
        _lExpectedTags = lInMemoryChk.getUserTags(_pUser)
        if len(_lExpectedTags.difference(_lTags)) > 0:
            print ("WARNING: expected tags %s" % _lExpectedTags.difference(_lTags))
            assert False
        _lPhotos = _getpins("SELECT * FROM \"http://localhost/afy/class/testphotos1/photo\" AS p JOIN \"http://localhost/afy/class/testphotos1/tagging\" AS t ON (p.\"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hasHash\" = t.\"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hasHash\") WHERE t.\"http://code.google.com/p/tagont/hasTagLabel\" IN (%s);" % ','.join([("'%s'" % _iT) for _iT in _lTags]))
        _lUniquePhotos = set()
        for _iP in _lPhotos:
            _lUniquePhotos.add(_iP["http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hasHash"])
        if len(_lPhotos) != len(_lUniquePhotos):
            print ("non-unique: %s unique: %s" % (len(_lPhotos), len(_lUniquePhotos)))
        return len(_lUniquePhotos)
    for iU in lUsersOfInterest:
        lCntPhotos = _countUserPhotos(iU["http://code.google.com/p/tagont/hasVisibility"])
        _chkCount("photos that can be viewed by %s" % iU["http://code.google.com/p/tagont/hasVisibility"], _pExpected=lInMemoryChk.countPhotos(iU["http://code.google.com/p/tagont/hasVisibility"]), _pActual=lCntPhotos)
    if False:
        # Output the final state.
        print (_getpins("SELECT *;"))
    # Close everything.
    lAffinity.close()

class TestPhotos1(AffinityTest):
    "A simple application talking to the store through pathSQL only, and using a relational model with joins."
    def execute(self):
        _entryPoint()
AffinityTest.declare(TestPhotos1)

if __name__ == '__main__':
    lT = TestPhotos1()
    lT.execute()
Esempio n. 6
0
            cnt=cnt+1
        sql = "INSERT OPTIONS(TRANSIENT) temperature="+ str(temperature) +",distance=" + str(distance)
        lAffinity.q(sql)

    lPins = PIN.loadPINs(lAffinity.qProto("SELECT * FROM #count_fire_warning"))

    print "==> Totally " + str(cnt) + " fire warnings are detected!"
    assert lPins[0]['fire_warning_cnt'] == cnt
    
    lAffinity.close()
    return True 

def _entryPoint():
    start = time.time()
    test_case_1()
    print "Test rules complete!"
    end = time.time()
    print "Testrules costs : " + timeToString(end - start)
    
class TestRules(AffinityTest):
    def execute(self):
        _entryPoint()

AffinityTest.declare(TestRules)

if __name__ == '__main__':
    lT = TestRules()
    lT.execute()
    

Esempio n. 7
0
    # print "JSON result: %s" % lAffinity.check("SELECT * FROM cars AS c JOIN workers(@['d', 'n']) AS w ON (c.afy:pinID = w.cars) WHERE (c.year IN @[1980, 2000]);")
    print "Start step11"
    pins = PIN.loadPINs(lAffinity.qProto("SELECT * FROM cars AS c JOIN workers(@['d', 'n']) AS w ON (c.afy:pinID = w.cars) WHERE (c.year IN @[1980, 2000]);"))
    assert len(pins) > 0
    print "Step11 complete!" 

    # for repro bug#302
    lAffinity.q("DELETE FROM *;")
    assert lAffinity.qCount("select * where not exists(afy:predicate)") == 0
    lAffinity.close()	
    print "Test tutorial complete!"
    return True

def _entryPoint():
    start = time.time()
    test_executable_doc() # TODO: Review... doesn't seem happy...
    test_tutorial()
    end = time.time()
    print "TestOnlineMaterials costs : " + timeToString(end - start)
    
class TestOnlineMaterials(AffinityTest):
    def execute(self):
        _entryPoint()

AffinityTest.declare(TestOnlineMaterials)

if __name__ == '__main__':
    lT = TestOnlineMaterials()
    lT.execute()

Esempio n. 8
0
def _entryPoint():
    lAffinity = AFFINITY()
    lAffinity.open()

    # VT_STRING
    lValue = "Hello how are you";
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES ('%s');" % lValue))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = lValue
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_STRING == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_STRING == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType

    # VT_BSTR
    lValue = bytearray(b"Hello how are you")
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (X'%s');" % ''.join("%02x" % iB for iB in lValue)))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = lValue
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_BSTR == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_BSTR == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType

    # VT_INT
    lValue = 12345
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (%d);" % lValue))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = lValue
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_INT == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_INT == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType

    # VT_UINT
    lValue = 12345
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (%du);" % lValue))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = (lValue, PIN.Extra(pType=affinity_pb2.Value.VT_UINT))
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_UINT == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_UINT == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType

    # VT_INT64
    lValue = -8589934592
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (%d);" % lValue))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = lValue
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_INT64 == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_INT64 == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType

    # VT_UINT64
    lValue = 8589934592
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (%dU);" % lValue))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = (lValue, PIN.Extra(pType=affinity_pb2.Value.VT_UINT64))
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_UINT64 == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_UINT64 == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType

    # VT_FLOAT
    lValue = 123.5
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (%sf);" % lValue))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = (lValue, PIN.Extra(pType=affinity_pb2.Value.VT_FLOAT))
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_FLOAT == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_FLOAT == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType

    # VT_DOUBLE
    lValue = 123.5
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (%s);" % lValue))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = lValue
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_DOUBLE == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_DOUBLE == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType

    # VT_BOOL
    lValue = True
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (%s);" % lValue))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = lValue
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_BOOL == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_BOOL == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType

    # VT_DATETIME
    # Review: timezone handling seems strange...
    lValue = datetime.datetime.utcnow()
    lValue2 = lValue.replace(tzinfo=None) - datetime.timedelta(seconds=time.timezone)
    lValueStr = AffinityTest.strftime(lValue, "%4Y-%2m-%2d %2H:%2M:%2S.%f")
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (TIMESTAMP'%s');" % lValueStr))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = lValue2
    lPin.refreshPIN()
    assert lValue2.timetuple() == lPin['http://localhost/afy/property/testtypes1/value1'].timetuple()
    assert lValue2.timetuple() == lPin['http://localhost/afy/property/testtypes1/value2'].timetuple()
    assert affinity_pb2.Value.VT_DATETIME == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_DATETIME == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType
    lAffinity.qProto("UPDATE %s ADD \"http://localhost/afy/property/testtypes1/value1\"=%s;" % (lPin.mPID, 123))
    lPin.refreshPIN()
    lReferenced1 = lPin

    # VT_INTERVAL
    lValue = datetime.timedelta(seconds=123.5)
    lValueStr = AffinityTest.strftime((datetime.datetime(year=1970, month=1, day=1) + lValue), "%2H:%2M:%2S.%f")
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (INTERVAL'%s');" % lValueStr))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = lValue
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_INTERVAL == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_INTERVAL == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType

    # VT_REFID
    lValue = PIN.Ref.fromPID(lReferenced1.mPID)
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (%s);" % lReferenced1.mPID))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = lValue
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_REFID == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_REFID == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType

    # VT_REFIDPROP
    lValue = PIN.Ref(pLocalPID=lReferenced1.mPID.mLocalPID, pIdent=lReferenced1.mPID.mIdent, pProperty='http://localhost/afy/property/testtypes1/value1')
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (&%s.\"http://localhost/afy/property/testtypes1/value1\");" % lReferenced1.mPID))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = lValue
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_REFIDPROP == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_REFIDPROP == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType

    # VT_REFIDELT    
    lValue = PIN.Ref(pLocalPID=lReferenced1.mPID.mLocalPID, pIdent=lReferenced1.mPID.mIdent, pProperty='http://localhost/afy/property/testtypes1/value1', pEid=lReferenced1.getExtra('http://localhost/afy/property/testtypes1/value1', pEpos=1).mEid)
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (&%s.\"http://localhost/afy/property/testtypes1/value1\"[%d]);" % (lReferenced1.mPID, lValue.mEid)))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = lValue
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_REFIDELT == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_REFIDELT == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType    

    # TODO: VT_EXPR
    # TODO: VT_QUERY
    # TODO: VT_CURRENT - available?
    # TODO: VT_ENUM - available?
    # TODO: VT_DECIMAL - available?
    # TODO: VT_URIID - purpose? vs VT_REFID?
    # TODO: VT_IDENTITY - purpose?
    # TODO: VT_REFCID - purpose?
    # TODO: VT_RANGE - purpose?
    # NOTE: VT_ARRAY is tested with collections.

    lAffinity.close()
Esempio n. 9
0
    lPin = PIN.loadPINs(lAffinity.qProto("INSERT (\"http://localhost/afy/property/testtypes1/value1\") VALUES (&%s.\"http://localhost/afy/property/testtypes1/value1\"[%d]);" % (lReferenced1.mPID, lValue.mEid)))[0]
    lPin['http://localhost/afy/property/testtypes1/value2'] = lValue
    lPin.refreshPIN()
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value1']
    assert lValue == lPin['http://localhost/afy/property/testtypes1/value2']
    assert affinity_pb2.Value.VT_REFIDELT == lPin.getExtra('http://localhost/afy/property/testtypes1/value1').mType
    assert affinity_pb2.Value.VT_REFIDELT == lPin.getExtra('http://localhost/afy/property/testtypes1/value2').mType    

    # TODO: VT_EXPR
    # TODO: VT_QUERY
    # TODO: VT_CURRENT - available?
    # TODO: VT_ENUM - available?
    # TODO: VT_DECIMAL - available?
    # TODO: VT_URIID - purpose? vs VT_REFID?
    # TODO: VT_IDENTITY - purpose?
    # TODO: VT_REFCID - purpose?
    # TODO: VT_RANGE - purpose?
    # NOTE: VT_ARRAY is tested with collections.

    lAffinity.close()

class TestTypes1(AffinityTest):
    "A basic test for native data types (python and Affinity)."
    def execute(self):
        _entryPoint()
AffinityTest.declare(TestTypes1)

if __name__ == '__main__':
    lT = TestTypes1()
    lT.execute()
Esempio n. 10
0
    if len(lPBStream.pins) > 1:
        print ("\nA basic PIN modification test (ISession::modify style).")
        lPid = lPBStream.pins[1].id
        print ("before modify: %s" % lAffinity.check("SELECT * FROM {@%x};" % lPid.id))
        lPin = PIN({PIN.SK_PID:PIN.PID.fromPB(lPid), "http://localhost/afy/property/testbasics1/myprop1":"bien"})
        #lPin = PIN(__PID__=PIN.PID.fromPB(lPid), testbasics1_myprop1="bien")
        lPin.savePIN()
        print ("after modify: %s" % lAffinity.check("SELECT * FROM {@%x};" % lPid.id))

    if len(lPBStream.pins) > 1:
        print ("\nA basic PIN deletion test.")
        lPid = lPBStream.pins[1].id
        print ("before delete: %s" % lAffinity.check("SELECT * FROM {@%x};" % lPid.id))
        PIN.deletePINs([PIN.PID.fromPB(lPid)])
        #print ("after delete: %s" % lAffinity.check("SELECT * FROM {@%x};" % lPid.id))

    #print ("\nFinal state check.")
    #print (lAffinity.check("SELECT *"))
    lAffinity.close()

class TestBasics1(AffinityTest):
    "First basic test (originally written for testgen/python)."
    def execute(self):
        _entryPoint()
AffinityTest.declare(TestBasics1)

if __name__ == '__main__':
    lT = TestBasics1()
    lT.execute()
Esempio n. 11
0
    assert 1 == lAffinity.qCount("SELECT color FROM houses(1).doors WHERE doorid=2;")
    assert 3 == lAffinity.qCount("SELECT color FROM houses(1).doors")
    assert 3 == lAffinity.qCount("SELECT color FROM houses.doors;") 

    lAffinity.close()
    return True  

def _entryPoint():
    # test cases are executed here
    start = time.time()
    TEST = 'test_case_'
    cnt = 0
    for i in range(1, 49):
        eval(TEST+str(i)+'()')
        cnt+=1
    
    end = time.time()
    print "Totally " + str(cnt) + " cases have been tested."
    print "TestBasicPathSQL costs : " + timeToString(end - start)
    
class TestBasicPathSQL(AffinityTest):
    def execute(self):
        _entryPoint()

AffinityTest.declare(TestBasicPathSQL)

if __name__ == '__main__':
    lT = TestBasicPathSQL()
    lT.execute()

Esempio n. 12
0
    # verify the results
    assert lAffinity.qCount("select * where exists(T6_P2);") == (TOTAL - cnt)
    assert lAffinity.qCount("SELECT * FROM T6_LEV_C1;") == cnt
    lAffinity.close()
    print "Test test_case_6 complete!"
    return True

def _entryPoint():
    start = time.time()
    test_case_1()
    test_case_2()
    test_case_3()
    #test_case_4()
    test_case_5()
    test_case_6()
    end = time.time()
    print "Test transient pins complete!"
    print "TestTransient costs : " + timeToString(end - start)
    
class TestTransient(AffinityTest):
    def execute(self):
        _entryPoint()

AffinityTest.declare(TestTransient)

if __name__ == '__main__':
    lT = TestTransient()
    lT.execute()

Esempio n. 13
0
        lCollection3b = list(lCollection3)
        checkPersistedProp("comparing reloaded testcollections1/mycoll3 to lCollection3", lPin1, "http://localhost/afy/property/testcollection1/mycoll3", lCollection3b)
        while len(lCollection3b) > 1:
            del lPin1["http://localhost/afy/property/testcollection1/mycoll3"][0]
            del lCollection3b[0]
            if 0 != cmp(lPin1["http://localhost/afy/property/testcollection1/mycoll3"], lCollection3b):
                reportError("comparing in-memory testcollections1/mycoll3 to lCollection3b, after deletion of element")
            checkPersistedProp("comparing reloaded testcollections1/mycoll3 to lCollection3b, after deletion of element", lPin1, "http://localhost/afy/property/testcollection1/mycoll3", lCollection3b)
        del lPin1["http://localhost/afy/property/testcollection1/mycoll3"]
        try:
            if lPin1.has_key("http://localhost/afy/property/testcollection1/mycoll3") or lPin1.getExtra("http://localhost/afy/property/testcollection1/mycoll3"):
                reportError("retrieving testcollection1/mycoll3 after deletion of the property")
        except Exception as ex:
            #print repr(ex)
            pass
        lPinChk = PIN.createFromPID(lPin1.mPID)
        if lPinChk.has_key("http://localhost/afy/property/testcollection/mycoll3"):
            reportError("retrieving testcollection1/mycoll3 after deletion of the property, on reloaded pin")

    lAffinity.close()

class TestCollections1(AffinityTest):
    "A basic test for collections."
    def execute(self):
        _entryPoint()
AffinityTest.declare(TestCollections1)

if __name__ == '__main__':
    lT = TestCollections1()
    lT.execute()