Example #1
0
 def createRepo(self):
     repopath =  self.getTempFolderPath()         
     repo = Repository(repopath, init = True)
     shpfile = os.path.join(os.path.dirname(__file__), "data", "shp", "landuse", "landuse2.shp")
     repo.importshp(shpfile, False, "landuse", "fid")
     repo.addandcommit("first")        
     return repo
Example #2
0
 def testOsmImport(self):
     repoPath =  self.getTempRepoPath()         
     repo = Repository(repoPath, init = True)
     osmfile = os.path.join(os.path.dirname(__file__), "data", "osm", "ways.xml")        
     repo.importosm(osmfile)
     feature = Feature(repo, geogit.WORK_HEAD, "way/31045880")
     self.assertTrue(feature.exists())
Example #3
0
 def testResetMixed(self):
     origin = Repository(os.path.join(os.path.dirname(__file__), 'data/testrepo'))
     dst = self.getTempRepoPath()        
     cloned = origin.clone(dst)       
     cloned.reset(cloned.head.parent.ref, geogit.RESET_MODE_MIXED)
     self.assertEqual("message_3", cloned.log()[0].message)
     self.assertTrue(len(cloned.unstaged()) > 0)     
Example #4
0
 def testOsmImportWithMappingFile(self):
     repoPath =  self.getTempRepoPath()         
     repo = Repository(repoPath, init = True)
     osmfile = os.path.join(os.path.dirname(__file__), "data", "osm", "ways.xml")
     mappingfile = os.path.join(os.path.dirname(__file__), "data", "osm", "mapping.json")
     repo.importosm(osmfile, False, mappingfile)     
     feature = Feature(repo, geogit.WORK_HEAD, "onewaystreets/31045880")
     self.assertTrue(feature.exists())
Example #5
0
 def testLargeDiff(self):
     repo = Repository(self.getTempRepoPath(), init=True)
     path = os.path.join(os.path.dirname(__file__), "data", "shp", "1", "parks.shp")
     repo.importshp(path)   
     repo.addandcommit("message")
     path = os.path.join(os.path.dirname(__file__), "data", "shp", "elevation", "elevation.shp")
     repo.importshp(path)  
     repo.addandcommit("message_2")
     s = repo.diff("HEAD~1", "HEAD")
Example #6
0
 def testImportExportInDifferentFormats(self):
     repopath =  self.getTempFolderPath()         
     repo = Repository(repopath, init = True)
     geojsonfile = os.path.join(os.path.dirname(__file__), "data", "geojson", "landuse.geojson")
     repo.importgeojson(geojsonfile, False, "landuse", "fid")
     repo.addandcommit("commit")
     shpfile = os.path.join(self.getTempFolderPath(), "landuse.shp")
     repo.exportshp(geogit.HEAD, "landuse", shpfile)
     repo.importshp(shpfile, False, "landuse", "fid")
     unstaged = repo.unstaged()
     self.assertEquals(0, unstaged)
Example #7
0
 def testPush(self):
     origin = Repository(os.path.join(os.path.dirname(__file__), 'data/testrepo'))
     dst = self.getTempRepoPath()        
     cloned = origin.clone(dst) 
     dst = self.getTempRepoPath()        
     cloned2 = cloned.clone(dst) 
     path = os.path.join(os.path.dirname(__file__), "data", "shp", "1", "parks.shp")
     cloned2.importshp(path)
     cloned2.addandcommit("new_message")
     cloned.push("origin", geogit.MASTER)
     log = cloned.log()
     self.assertTrue("new_message", log[0].message)
Example #8
0
 def testOsmImportWithMapping(self):
     mapping = OSMMapping()
     rule = OSMMappingRule("onewaystreets")
     rule.addfilter("oneway", "yes")
     rule.addfield("lit", "lit", geogit.TYPE_STRING)
     rule.addfield("geom", "the_geom", geogit.TYPE_LINESTRING)
     mapping.addrule(rule)
     repoPath =  self.getTempRepoPath()         
     repo = Repository(repoPath, init = True)
     osmfile = os.path.join(os.path.dirname(__file__), "data", "osm", "ways.xml")        
     repo.importosm(osmfile, False, mapping)     
     feature = Feature(repo, geogit.WORK_HEAD, "onewaystreets/31045880")
     self.assertTrue(feature.exists())
Example #9
0
 def testLargeHistory(self):
     NUMPOINTS = 6000
     repo = Repository(self.getTempRepoPath(), init=True)
     path = os.path.join(os.path.dirname(__file__), "data", "shp", "elevation", "elevation.shp")
     repo.importshp(path)
     repo.add()   
     for i in xrange(NUMPOINTS):
         feature = "elevation/" + str(i+1);            
         message = "message " + str(i+1)
         repo.commit(message, [feature])
     log = repo.log()
     
     
     
Example #10
0
 def testLogEmptyRepo(self):
     repoPath =  self.getTempRepoPath()         
     repo = Repository(repoPath, init = True) 
     log = repo.log()
     self.assertFalse(log)
Example #11
0
def createRepo():
    repo = Repository(getTempRepoPath(), init = True)
    path = os.path.join(os.path.dirname(__file__), "data", "shp", "1", "parks.shp")
    repo.importshp(path)   
    repo.addandcommit("message")
    path = os.path.join(os.path.dirname(__file__), "data", "shp", "2", "parks.shp")
    repo.importshp(path)
    repo.addandcommit("message_2")        
    path = os.path.join(os.path.dirname(__file__), "data", "shp", "3", "parks.shp")
    repo.importshp(path)
    repo.addandcommit("message_3")
    repo.createbranch(geogit.HEAD, "conflicted")
    repo.createbranch(geogit.HEAD, "unconflicted")
    path = os.path.join(os.path.dirname(__file__), "data", "shp", "4", "parks.shp")
    repo.importshp(path)
    repo.addandcommit("message_4")
    repo.checkout("conflicted")
    path = os.path.join(os.path.dirname(__file__), "data", "shp", "5", "parks.shp")
    repo.importshp(path)
    repo.addandcommit("message_5")
    repo.checkout("unconflicted")
    path = os.path.join(os.path.dirname(__file__), "data", "shp", "6", "parks.shp")
    repo.importshp(path)
    repo.addandcommit("message_6")
    shutdownServer()
Example #12
0
def getClonedRepo(): 
    repo = Repository(os.path.join(os.path.dirname(__file__), '../test/data/testrepo'))
    dst = getTempPath()
    return repo.clone(dst)