From 747e9af19fb599a065d83901601973db1b5f427b Mon Sep 17 00:00:00 2001 From: meejah Date: Sat, 24 Aug 2019 12:20:50 -0600 Subject: [PATCH] fixup; remove fragile root tests --- src/allmydata/test/web/test_root.py | 345 ---------------------------- 1 file changed, 345 deletions(-) diff --git a/src/allmydata/test/web/test_root.py b/src/allmydata/test/web/test_root.py index 0572431e3..1e324c398 100644 --- a/src/allmydata/test/web/test_root.py +++ b/src/allmydata/test/web/test_root.py @@ -1,17 +1,8 @@ -# encoding: utf-8 - from twisted.trial import unittest -from twisted.internet.task import Clock -from twisted.internet.defer import inlineCallbacks -from twisted.web.template import XMLString, Element - -from nevow.testutil import FakeRequest, renderPage -from nevow.context import WebContext from ...storage_client import NativeStorageServer from ...web.root import Root from ...util.connection_status import ConnectionStatus -from allmydata.client import SecretHolder class FakeRoot(Root): def __init__(self): @@ -27,7 +18,6 @@ class FakeContext(object): self.slots[slotname] = contents class RenderServiceRow(unittest.TestCase): - def test_missing(self): # minimally-defined static servers just need anonymous-storage-FURL # and permutation-seed-base32. The WUI used to have problems @@ -46,338 +36,3 @@ class RenderServiceRow(unittest.TestCase): self.assertIdentical(res, ctx) self.assertEqual(ctx.slots["version"], "") self.assertEqual(ctx.slots["nickname"], "") - - -class FakeUploader(object): - """ - Fake enough of an uploader instance for /helper_status/ to render - """ - def get_helper_info(self): - return ("furl", False) - - -class FakeHelper(object): - """ - Fake enough of a Helper instance for /helper_status/ to render - """ - def get_stats(self): - return { - "chk_upload_helper.active_uploads": 0, - } - - -class FakeStorageBroker(object): - """ - Fake enough of a StorageBroker for root page rendering to work - """ - def get_connected_servers(self): - return {} - - def get_all_serverids(self): - return () - - def get_known_servers(self): - return () - - -class FakeMagicFolder(object): - """ - Fake enough of MagicFolder for status-rendering to work - """ - - def get_public_status(self): - return (True, ["this magic folder is alive"]) - - -# XXX there are several 'fake client' instance throughout the code -# .. probably should be a single one that works better and covers all -# the cases etc. -class FakeClient(object): - """ - just enough to let the node acquire an uploader (which it won't - use) and at least one magic-folder for RenderRoot tests. - """ - nickname = "fake_nickname" - stats_provider = None - uploader = FakeUploader() - helper = FakeHelper() - storage_broker = FakeStorageBroker() - - _secret_holder = SecretHolder("lease secret", "convergence secret") - _magic_folders = { - "foo": FakeMagicFolder(), - } - - def get_long_nodeid(self): - return "v0-nodeid" - - def get_long_tubid(self): - return "v0-tubid" - - def introducer_connection_statuses(self): - return {} - - def get_auth_token(self): - return "x" - - def getServiceNamed(self, name): - return { - "uploader": self.uploader, - "helper": self.helper, - }[name] - - def get_encoding_parameters(self): - return {"k": 3, "n": 10} - - def get_storage_broker(self): - return self.storage_broker - - def get_history(self): - return None - - -class RenderRoot(unittest.TestCase): - """ - Test rendering of the root template. - - These tests are fairly fragile because they have 'actual HTML' - burned into them -- they are here to prove that porting away from - Nevow hasn't changed the rendering drastically (perhaps they - should just be deleted or simplified after that). - """ - - def setUp(self): - self.root = FakeRoot() - self.context = WebContext() - self.clock = Clock() - self.client = FakeClient() - - def test_basic_stan(self): - """ - we can render the root without any exceptions - """ - - class MyRoot(Element): - loader = XMLString(GOLDEN_ROOT) - - request = FakeRequest() - r = MyRoot() - r.render(request) - - @inlineCallbacks - def test_root_template(self): - """ - The current root renders the same as it did with Nevow - """ - page = Root(self.client, self.clock, now_fn=self.clock.seconds) - page.addSlash = False # XXX hack around what looks like nevow testutils bug - - page_data = yield renderPage(page) - - # we chop up to the line with "