use QueuedItem directly instead of FakeStatusItem

This commit is contained in:
meejah 2018-02-20 16:13:55 -07:00
parent 1b16e1f792
commit 75e97e6c6d
1 changed files with 11 additions and 14 deletions

View File

@ -1,6 +1,7 @@
import os.path, re, urllib, time, cgi import os.path, re, urllib, time, cgi
import json import json
import treq import treq
import mock
from twisted.application import service from twisted.application import service
from twisted.trial import unittest from twisted.trial import unittest
@ -30,6 +31,7 @@ from allmydata.immutable import upload
from allmydata.immutable.downloader.status import DownloadStatus from allmydata.immutable.downloader.status import DownloadStatus
from allmydata.dirnode import DirectoryNode from allmydata.dirnode import DirectoryNode
from allmydata.nodemaker import NodeMaker from allmydata.nodemaker import NodeMaker
from allmydata.frontends.magic_folder import QueuedItem
from allmydata.web import status from allmydata.web import status
from allmydata.web.common import WebError, MultiFormatPage from allmydata.web.common import WebError, MultiFormatPage
from allmydata.util import fileutil, base32, hashutil from allmydata.util import fileutil, base32, hashutil
@ -120,18 +122,13 @@ class FakeStatus(object):
return self.status return self.status
class FakeStatusItem(object): def create_test_queued_item(relpath_u, history=[]):
def __init__(self, p, history): progress = mock.Mock()
self.relpath_u = p progress.progress = 100.0
self.history = history item = QueuedItem(relpath_u, progress, 1234)
import mock for status, ts in history:
self.progress = mock.Mock() item.set_status(status, current_time=ts)
self.progress.progress = 100.0 return item
self.size = 1234
def status_history(self):
return self.history
class FakeMagicFolder(object): class FakeMagicFolder(object):
@ -1006,7 +1003,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
def test_magicfolder_status_success(self): def test_magicfolder_status_success(self):
self.s._magic_folders['default'] = mf = FakeMagicFolder() self.s._magic_folders['default'] = mf = FakeMagicFolder()
mf.uploader.status = [ mf.uploader.status = [
FakeStatusItem(u"rel/path", [('done', 12345)]) create_test_queued_item(u"rel/path", [('done', 12345)])
] ]
data = yield self.POST( data = yield self.POST(
'/magic_folder?t=json', '/magic_folder?t=json',
@ -1033,7 +1030,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
def test_magicfolder_root_success(self): def test_magicfolder_root_success(self):
self.s._magic_folders['default'] = mf = FakeMagicFolder() self.s._magic_folders['default'] = mf = FakeMagicFolder()
mf.uploader.status = [ mf.uploader.status = [
FakeStatusItem(u"rel/path", [('done', 12345)]) create_test_queued_item(u"rel/path", [('done', 12345)])
] ]
data = yield self.GET( data = yield self.GET(
'/', '/',