|
@@ -70,8 +70,9 @@ def check_reply(): |
|
|
app.processEvents() |
|
|
|
|
|
def testFetchGoodUrl(self): |
|
|
url = 'http://localhost:' + str(self.port) + '/qgis_local_server/index.html' |
|
|
registry = QgsApplication.networkContentFetcherRegistry() |
|
|
content = registry.fetch(QUrl('http://localhost:' + str(self.port) + '/qgis_local_server/index.html')) |
|
|
content = registry.fetch(QUrl(url)) |
|
|
self.loaded = False |
|
|
|
|
|
def check_reply(): |
|
@@ -85,8 +86,10 @@ def check_reply(): |
|
|
while not self.loaded: |
|
|
app.processEvents() |
|
|
|
|
|
self.assertEqual(registry.localPath(url), content.filePath()) |
|
|
|
|
|
# create new content with same URL |
|
|
contentV2 = registry.fetch(QUrl('http://localhost:' + str(self.port) + '/qgis_local_server/index.html')) |
|
|
contentV2 = registry.fetch(QUrl(url)) |
|
|
self.assertEqual(contentV2.status(), QgsFetchedContent.Finished) |
|
|
|
|
|
def testFetchReloadUrl(self): |
|
@@ -124,6 +127,18 @@ def check_reply(): |
|
|
|
|
|
os.remove('qgis_local_server/simple_content.txt') |
|
|
|
|
|
def testLocalPath(self): |
|
|
registry = QgsApplication.networkContentFetcherRegistry() |
|
|
filePath = 'qgis_local_server/index.html' |
|
|
self.assertEqual(registry.localPath(filePath), filePath) |
|
|
|
|
|
# a non existent download shall return untouched the path |
|
|
self.assertEqual(registry.localPath('xxxx'), 'xxxx') |
|
|
|
|
|
# an existent but unfinished download should return an empty path |
|
|
content = registry.fetch(QUrl('xxxx')) |
|
|
self.assertEqual(registry.localPath('xxxx'), '') |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
unittest.main() |