From c14197e1bc409f323e3a8eb41977f0726079f3aa Mon Sep 17 00:00:00 2001 From: Sajith Sasidharan Date: Fri, 17 Jul 2020 16:13:07 -0400 Subject: [PATCH] Make FakeDownloadStatus an instance of DownloadStatus The real DownloadStatus is easy enough to instantiate. Might as well use that, cutting some crufty code here. --- src/allmydata/test/web/test_status.py | 43 ++++----------------------- 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/src/allmydata/test/web/test_status.py b/src/allmydata/test/web/test_status.py index 42f2b9794..c52a50bfb 100644 --- a/src/allmydata/test/web/test_status.py +++ b/src/allmydata/test/web/test_status.py @@ -4,11 +4,9 @@ from bs4 import BeautifulSoup from twisted.web.template import flattenString from zope.interface import implementer -from allmydata.interfaces import ( - IDownloadResults, - IDownloadStatus, -) +from allmydata.interfaces import IDownloadResults from allmydata.web.status import DownloadStatusElement +from allmydata.immutable.downloader.status import DownloadStatus from .common import ( assert_soup_has_favicon, @@ -37,8 +35,7 @@ class FakeDownloadResults(object): self.timings = timings -@implementer(IDownloadStatus) -class FakeDownloadStatus(object): +class FakeDownloadStatus(DownloadStatus): def __init__(self, storage_index = None, @@ -50,49 +47,21 @@ class FakeDownloadStatus(object): """ See IDownloadStatus and IDownloadResults for parameters. """ - self.storage_index = storage_index - self.file_size = file_size - self.dyhb_requests = [] - self.read_events = [] - self.segment_events = [] - self.block_requests = [] + super(FakeDownloadStatus, self).__init__(storage_index, file_size) self.servers_used = servers_used self.server_problems = server_problems self.servermap = servermap 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): - return FakeDownloadResults(self.file_size, + return FakeDownloadResults(self.size, self.servers_used, self.server_problems, self.servermap, self.timings) + # Tests for code in allmydata.web.status.DownloadStatusElement class DownloadStatusElementTests(TrialTestCase):