class Test( unittest.TestCase ): def setUp( self ): self.testproject = getObject( Project().getType(), remote_id = testProjectID ) self.eventprocessor = LocalDBEventSpooler() self.sg = shotgun.Shotgun( config.SHOTGUN_URL, config.SHOTGUN_SYNC_SKRIPT, config.SHOTGUN_SYNC_KEY ) self.shotgun2local = shotgun_to_local.EventSpooler() def tearDown( self ): self.assertTrue( self.shotgun2local.connectAndRun(), "synch not successful" ) def test_create( self ): shot = Shot() shot.code = "delete me again - " + str( uuid.uuid1() ) shot.project = self.testproject shot.save() newshotid = shot.getLocalID() self.assertTrue( self.eventprocessor.connectAndRun(), "synch not successful" ) shot_ret = getObject( "Shot", local_id = newshotid ) newRemoteID = shot_ret.getRemoteID() self.assertTrue( newRemoteID != None and newRemoteID != shotgun_replica.UNKNOWN_SHOTGUN_ID ) newCutIn = 1234 shot_ret.sg_cut_in = newCutIn shot_ret.save() self.assertTrue( self.eventprocessor.connectAndRun(), "synch not successful" ) newshot = self.sg.find( "Shot", filters = [['id', 'is', newRemoteID]], fields = ['id', 'sg_cut_in'], filter_operator = 'all', limit = 100 ) self.assertEqual( newshot[0]['sg_cut_in'], newCutIn ) shot_ret = shot_ret.delete() self.assertEqual( shot_ret, None ) isShot = getObject( "Shot", local_id = newshotid ) self.assertEqual( isShot, None ) self.assertTrue( self.eventprocessor.connectAndRun(), "synch not successful" ) newshot = self.sg.find( "Shot", filters = [['id', 'is', newRemoteID]], fields = ['id', 'sg_cut_in'], filter_operator = 'all', limit = 100 ) self.assertEqual( len( newshot ), 0 )
def setUp(self): self.testproject = getObject(Project().getType(), remote_id=testProjectID) self.local2shotgun = LocalDBEventSpooler() self.sg = shotgun.Shotgun(config.SHOTGUN_URL, config.SHOTGUN_SYNC_SKRIPT, config.SHOTGUN_SYNC_KEY) self.shotgun2local = shotgun_to_local.EventSpooler()
def setUp(self): self.testproject = getObject(Project().getType(), remote_id=testProjectID) self.eventprocessor = LocalDBEventSpooler() self.sg = shotgun.Shotgun(config.SHOTGUN_URL, config.SHOTGUN_SYNC_SKRIPT, config.SHOTGUN_SYNC_KEY) self.shotgun2local = shotgun_to_local.EventSpooler() self.testshot = factories.getObject(entities.Shot, remote_id=testShotID) self.current_cut_in = self.testshot.sg_cut_in
def setUp( self ): self.testproject = getObject( Project().getType(), remote_id = testProjectID ) self.eventprocessor = LocalDBEventSpooler() self.sg = shotgun.Shotgun( config.SHOTGUN_URL, config.SHOTGUN_SYNC_SKRIPT, config.SHOTGUN_SYNC_KEY ) self.shotgun2local = shotgun_to_local.EventSpooler()
class Test(unittest.TestCase): def setUp(self): self.testproject = getObject(Project().getType(), remote_id=testProjectID) self.eventprocessor = LocalDBEventSpooler() self.sg = shotgun.Shotgun(config.SHOTGUN_URL, config.SHOTGUN_SYNC_SKRIPT, config.SHOTGUN_SYNC_KEY) self.shotgun2local = shotgun_to_local.EventSpooler() self.testshot = factories.getObject(entities.Shot, remote_id=testShotID) self.current_cut_in = self.testshot.sg_cut_in def tearDown(self): self.testshot.sg_cut_in = self.current_cut_in self.testshot.save() self.assertTrue(self.shotgun2local.connectAndRun(), "synch not successful") def test_create(self): shot = Shot() shot.code = "delete me again - " + str(uuid.uuid1()) shot.project = self.testproject shot.save() newshotid = shot.getLocalID() self.assertTrue(self.eventprocessor.connectAndRun(), "synch not successful") shot_ret = getObject("Shot", local_id=newshotid) newRemoteID = shot_ret.getRemoteID() self.assertTrue(newRemoteID != None and newRemoteID != shotgun_replica.UNKNOWN_SHOTGUN_ID) newCutIn = 1234 shot_ret.sg_cut_in = newCutIn shot_ret.save() self.assertTrue(self.eventprocessor.connectAndRun(), "synch not successful") newshot = self.sg.find("Shot", filters=[['id', 'is', newRemoteID]], fields=['id', 'sg_cut_in'], filter_operator='all', limit=100) self.assertEqual(newshot[0]['sg_cut_in'], newCutIn) shot_ret = shot_ret.delete() self.assertEqual(shot_ret, None) isShot = getObject("Shot", local_id=newshotid) self.assertEqual(isShot, None) self.assertTrue(self.eventprocessor.connectAndRun(), "synch not successful") newshot = self.sg.find("Shot", filters=[['id', 'is', newRemoteID]], fields=['id', 'sg_cut_in'], filter_operator='all', limit=100) self.assertEqual(len(newshot), 0) def test_change_Nones(self): self.testshot.sg_cut_in = None self.testshot.save() self.assertTrue(self.eventprocessor.connectAndRun(), "synch not successful") newshot = factories.getObject(entities.Shot, remote_id=testShotID) self.assertEqual(newshot.sg_cut_in, None)
def setUp( self ): self.serverHandler = server.Handler() self.eventprocessor = LocalDBEventSpooler()
class Test( unittest.TestCase ): def setUp( self ): self.serverHandler = server.Handler() self.eventprocessor = LocalDBEventSpooler() def tearDown( self ): pass def testProjectCreation( self ): userdict = config.getUserDict() nowstr = datetime.datetime.now().strftime( "%Y-%m-%d %H:%M:%S" ) projectData = { "name": "TESTPROJECTE - DELETE ME - " + str( uuid.uuid1() ), "code": "0000_" + str( uuid.uuid1() ), "updated_by": userdict, "updated_at": nowstr, "created_by": userdict, "created_at": nowstr } entityDictStr = self.serverHandler.POST( "Project", None, None, testdata = projectData ) entityDict = json.loads( entityDictStr ) self.assertTrue( entityDict["__local_id"] != None ) newObj = factories.getObject( "Project", local_id = entityDict["__local_id"] ) self.assertTrue( newObj != None ) allOk = self.eventprocessor.connectAndRun() self.assertTrue( allOk, "errors on event processing" ) newObj = factories.getObject( "Project", local_id = entityDict["__local_id"] ) self.assertTrue( newObj.getRemoteID() ) self.serverHandler.DELETE( "Project", entityDict["__local_id"], None, testdata = "dummy" ) newObj = factories.getObject( "Project", local_id = entityDict["__local_id"] ) self.assertTrue( newObj == None ) self.eventprocessor.connectAndRun() def testProjectUpdate( self ): userdict = config.getUserDict() nowdt = datetime.datetime.now() nowstr = nowdt.strftime( "%Y-%m-%d %H:%M:%S" ) projectData = { "sg_status": "Active", "sg_due": "2012-08-08" } content = self.serverHandler.PUT( "Project", None, testProjectID, testdata = projectData ) entityDict = json.loads( content ) self.assertEqual( entityDict["sg_due"], "2012-08-08" ) newObj = factories.getObject( "Project", local_id = entityDict["__local_id"] ) self.assertEqual( newObj.sg_due, datetime.date( 2012, 8, 8 ) ) self.eventprocessor.connectAndRun() def testVersionCreation( self ): node = factories.getObject( "Node", remote_id = testNodeID_1 ) output = factories.getObject( "Output", remote_id = testOutputID_1 ) project = factories.getObject( "Project", remote_id = testProjectID ) versionData = { "code": "001", "description": "delete me %s" % uuid.uuid1(), "entity": node.sg_link.getShortDict(), "sg_source_output": output.getShortDict(), "project": project.getShortDict(), } content = self.serverHandler.POST( "Version", None, None, versionData ) entityDict = json.loads( content ) self.assertTrue( entityDict["__local_id"] != None ) self.assertEqual( entityDict["entity"]["__local_id"], node.sg_link.getLocalID() ) content = self.serverHandler.DELETE( "Version", entityDict["__local_id"], None, testdata = "dummy" )
class Test(unittest.TestCase): def setUp(self): self.testproject = getObject(Project().getType(), remote_id=testProjectID) self.local2shotgun = LocalDBEventSpooler() self.sg = shotgun.Shotgun(config.SHOTGUN_URL, config.SHOTGUN_SYNC_SKRIPT, config.SHOTGUN_SYNC_KEY) self.shotgun2local = shotgun_to_local.EventSpooler() def tearDown(self): self.assertTrue(self.shotgun2local.connectAndRun(), "synch not successful") def test_create(self): shot = Shot() shot.code = "delete me again - " + str(uuid.uuid1()) shot.project = self.testproject shot.save() newshotid = shot.getLocalID() self.assertTrue(newshotid != None and newshotid != shotgun_replica.UNKNOWN_SHOTGUN_ID) shot_ret = getObject("Shot", local_id=newshotid) self.assertTrue(shot_ret != None) self.assertTrue(shot_ret.getSgObj() == None) allOk = self.local2shotgun.connectAndRun() self.assertTrue(allOk, "errors while syncing ") shot_ret = getObject("Shot", local_id=newshotid) newRemoteID = shot_ret.getRemoteID() self.assertTrue( newRemoteID != None and newRemoteID != shotgun_replica.UNKNOWN_SHOTGUN_ID, "Shot with local ID %d has no remote id %s" % (newshotid, newRemoteID)) self.assertTrue(shot_ret.getSgObj() != None) entity_manipulation.deleteEntity(shot_ret) shot_ret = getObject("Shot", local_id=newshotid) self.assertTrue(shot_ret == None) newshot = self.sg.find("Shot", filters=[['id', 'is', newRemoteID]], fields=['id'], filter_operator='all', limit=100) self.assertEqual(len(newshot), 1) allOk = self.local2shotgun.connectAndRun() self.assertTrue(allOk, "errors while syncing ") newshot = self.sg.find("Shot", filters=[['id', 'is', newRemoteID]], fields=['id'], filter_operator='all', limit=100) self.assertEqual(len(newshot), 0) def test_create_and_delete(self): testshot = factories.getObject("Shot", remote_id=testShotID) node = entities.Node() node.code = "testshot_" + str(uuid.uuid1())[0:8] node.sg_link = testshot node.project = self.testproject node.save() newNodeID = node.getLocalID() output = entities.Output() output.sg_link = node output.code = str(uuid.uuid1())[0:8] + "_" + "_SCR" output.sg_type = "SCR" output.project = self.testproject output.save() newOutputID = output.getLocalID() node.delete() output.delete() ret = self.local2shotgun.connectAndRun() self.assertTrue(ret, "errors while syncing ") node = factories.getObject(entities.Node._type, local_id=newNodeID) self.assertEqual(node, None, "node should not exist anymore") output = factories.getObject(entities.Output._type, local_id=newOutputID) self.assertEqual(output, None, "output should not exist anymore")
class Test( unittest.TestCase ): def setUp( self ): self.testproject = getObject( Project().getType(), remote_id = testProjectID ) self.local2shotgun = LocalDBEventSpooler() self.sg = shotgun.Shotgun( config.SHOTGUN_URL, config.SHOTGUN_SYNC_SKRIPT, config.SHOTGUN_SYNC_KEY ) self.shotgun2local = shotgun_to_local.EventSpooler() def tearDown( self ): self.assertTrue( self.shotgun2local.connectAndRun(), "synch not successful" ) def test_create( self ): shot = Shot() shot.code = "delete me again - " + str( uuid.uuid1() ) shot.project = self.testproject shot.save() newshotid = shot.getLocalID() self.assertTrue( newshotid != None and newshotid != shotgun_replica.UNKNOWN_SHOTGUN_ID ) shot_ret = getObject( "Shot", local_id = newshotid ) self.assertTrue( shot_ret != None ) self.assertTrue( shot_ret.getSgObj() == None ) allOk = self.local2shotgun.connectAndRun() self.assertTrue( allOk, "errors while syncing " ) shot_ret = getObject( "Shot", local_id = newshotid ) newRemoteID = shot_ret.getRemoteID() self.assertTrue( newRemoteID != None and newRemoteID != shotgun_replica.UNKNOWN_SHOTGUN_ID, "Shot with local ID %d has no remote id %s" % ( newshotid, newRemoteID ) ) self.assertTrue( shot_ret.getSgObj() != None ) entity_manipulation.deleteEntity( shot_ret ) shot_ret = getObject( "Shot", local_id = newshotid ) self.assertTrue( shot_ret == None ) newshot = self.sg.find( "Shot", filters = [['id', 'is', newRemoteID]], fields = ['id'], filter_operator = 'all', limit = 100 ) self.assertEqual( len( newshot ), 1 ) allOk = self.local2shotgun.connectAndRun() self.assertTrue( allOk, "errors while syncing " ) newshot = self.sg.find( "Shot", filters = [['id', 'is', newRemoteID]], fields = ['id'], filter_operator = 'all', limit = 100 ) self.assertEqual( len( newshot ), 0 ) def test_create_and_delete( self ): testshot = factories.getObject( "Shot", remote_id = testShotID ) node = entities.Node() node.code = "testshot_" + str( uuid.uuid1() )[0:8] node.sg_link = testshot node.project = self.testproject node.save() newNodeID = node.getLocalID() output = entities.Output() output.sg_link = node output.code = str( uuid.uuid1() )[0:8] + "_" + "_SCR" output.sg_type = "SCR" output.project = self.testproject output.save() newOutputID = output.getLocalID() node.delete() output.delete() ret = self.local2shotgun.connectAndRun() self.assertTrue( ret, "errors while syncing " ) node = factories.getObject( entities.Node._type, local_id = newNodeID ) self.assertEqual( node, None, "node should not exist anymore" ) output = factories.getObject( entities.Output._type, local_id = newOutputID ) self.assertEqual( output, None, "output should not exist anymore" )