mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-02 03:06:41 +00:00
Make FakeDownloadStatus an instance of DownloadStatus
The real DownloadStatus is easy enough to instantiate. Might as well use that, cutting some crufty code here.
This commit is contained in:
parent
7bee9ff540
commit
c14197e1bc
@ -4,11 +4,9 @@ from bs4 import BeautifulSoup
|
|||||||
from twisted.web.template import flattenString
|
from twisted.web.template import flattenString
|
||||||
from zope.interface import implementer
|
from zope.interface import implementer
|
||||||
|
|
||||||
from allmydata.interfaces import (
|
from allmydata.interfaces import IDownloadResults
|
||||||
IDownloadResults,
|
|
||||||
IDownloadStatus,
|
|
||||||
)
|
|
||||||
from allmydata.web.status import DownloadStatusElement
|
from allmydata.web.status import DownloadStatusElement
|
||||||
|
from allmydata.immutable.downloader.status import DownloadStatus
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
assert_soup_has_favicon,
|
assert_soup_has_favicon,
|
||||||
@ -37,8 +35,7 @@ class FakeDownloadResults(object):
|
|||||||
self.timings = timings
|
self.timings = timings
|
||||||
|
|
||||||
|
|
||||||
@implementer(IDownloadStatus)
|
class FakeDownloadStatus(DownloadStatus):
|
||||||
class FakeDownloadStatus(object):
|
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
storage_index = None,
|
storage_index = None,
|
||||||
@ -50,49 +47,21 @@ class FakeDownloadStatus(object):
|
|||||||
"""
|
"""
|
||||||
See IDownloadStatus and IDownloadResults for parameters.
|
See IDownloadStatus and IDownloadResults for parameters.
|
||||||
"""
|
"""
|
||||||
self.storage_index = storage_index
|
super(FakeDownloadStatus, self).__init__(storage_index, file_size)
|
||||||
self.file_size = file_size
|
|
||||||
self.dyhb_requests = []
|
|
||||||
self.read_events = []
|
|
||||||
self.segment_events = []
|
|
||||||
self.block_requests = []
|
|
||||||
|
|
||||||
self.servers_used = servers_used
|
self.servers_used = servers_used
|
||||||
self.server_problems = server_problems
|
self.server_problems = server_problems
|
||||||
self.servermap = servermap
|
self.servermap = servermap
|
||||||
self.timings = timings
|
self.timings = timings
|
||||||
|
|
||||||
def get_started(self):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_storage_index(self):
|
|
||||||
return self.storage_index
|
|
||||||
|
|
||||||
def get_size(self):
|
|
||||||
return self.file_size
|
|
||||||
|
|
||||||
def using_helper(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_status(self):
|
|
||||||
return "FakeDownloadStatus"
|
|
||||||
|
|
||||||
def get_progress(self):
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def get_active():
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_counter():
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def get_results(self):
|
def get_results(self):
|
||||||
return FakeDownloadResults(self.file_size,
|
return FakeDownloadResults(self.size,
|
||||||
self.servers_used,
|
self.servers_used,
|
||||||
self.server_problems,
|
self.server_problems,
|
||||||
self.servermap,
|
self.servermap,
|
||||||
self.timings)
|
self.timings)
|
||||||
|
|
||||||
|
|
||||||
# Tests for code in allmydata.web.status.DownloadStatusElement
|
# Tests for code in allmydata.web.status.DownloadStatusElement
|
||||||
class DownloadStatusElementTests(TrialTestCase):
|
class DownloadStatusElementTests(TrialTestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user