Commit Graph

5717 Commits

Author SHA1 Message Date
Itamar Turner-Trauring
5fd01523cf This module is not a thing. 2020-07-14 13:53:13 -04:00
Itamar Turner-Trauring
21a9ffef7a Not strings. 2020-07-14 13:46:12 -04:00
Itamar Turner-Trauring
a81e859b82 Fix flake error. 2020-07-14 13:44:56 -04:00
Itamar Turner-Trauring
27d8eb47fc Test improvements. 2020-07-14 13:44:00 -04:00
Itamar Turner-Trauring
db41d5af6f
Merge pull request #743 from tahoe-lafs/3342-more-tests-for-base32-base62
Fixes https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3343
2020-07-14 13:41:20 -04:00
Itamar Turner-Trauring
e0adb3b37d Port to Python 3. 2020-07-14 13:35:46 -04:00
Itamar Turner-Trauring
b5db85afbe Initial, manual steps of Python 3 port. 2020-07-14 11:53:40 -04:00
Itamar Turner-Trauring
3abb9e9db4 Rip out a whole bunch of code, either deleting or replacing with stdlib's base32 implementation. 2020-07-14 11:45:05 -04:00
Itamar Turner-Trauring
f3db64ad74 Port to Python 3. 2020-07-14 11:29:09 -04:00
Itamar Turner-Trauring
ab3737d686 Note this module has been ported to Python 3. 2020-07-14 11:28:51 -04:00
Itamar Turner-Trauring
9c428be0e2 Port base62 to Python 3. 2020-07-14 11:24:45 -04:00
Itamar Turner-Trauring
b1e732fb9a Port test_base62 to Python 3. 2020-07-14 10:34:53 -04:00
Itamar Turner-Trauring
e34a01d547 A couple more asserts. 2020-07-14 10:28:22 -04:00
Itamar Turner-Trauring
459d68118c Merge branch '3342-more-tests-for-base32-base62' into 3342-base32-and-base62-to-python-3 2020-07-14 10:26:46 -04:00
Itamar Turner-Trauring
f378edd9d8 Fix missing import. 2020-07-14 10:20:51 -04:00
Sajith Sasidharan
54e952ceda Test for 404 responses from status page subpaths 2020-07-14 09:01:31 -04:00
Chad Whitacre
329bfe05f9 Make a crucial relative import explicit 2020-07-13 22:27:59 -04:00
Sajith Sasidharan
abd539588f Rename nested functions for clarity
... and also to remove embarrassing copy-pasta mistakes.
2020-07-13 20:52:12 -04:00
Sajith Sasidharan
b48556c2cb Add tests for status subpages
Coverage tests for the coverage gods
2020-07-13 20:44:30 -04:00
Itamar Turner-Trauring
ead2a79cf7 Everything should be bytes. 2020-07-13 16:21:15 -04:00
Itamar Turner-Trauring
6464e226c6 Hypothesis-based roundtrip test. 2020-07-13 16:19:48 -04:00
Itamar Turner-Trauring
828e6bc28a Minimal tests for could_be_base32_encoded(). 2020-07-13 16:18:13 -04:00
Itamar Turner-Trauring
77ae087c77 Remove a2b_l and b2a_l from public API, to ease likely future switch to stdlib
base64's implementation.
2020-07-13 16:12:53 -04:00
Itamar Turner-Trauring
e23dbcdf56 Document current public API. 2020-07-13 15:41:01 -04:00
Itamar Turner-Trauring
bbfd39e6c0 Test larger variety of inputs using hypothesis. 2020-07-13 15:30:11 -04:00
Itamar Turner-Trauring
a8a7d48c12 Everything must be bytes. 2020-07-13 15:25:07 -04:00
Itamar Turner-Trauring
f27cba181e Move existing base32 tests out of test_util.py. 2020-07-13 15:22:03 -04:00
Itamar Turner-Trauring
1a3a1ffcaa Restore eliot code. 2020-07-13 14:33:13 -04:00
Itamar Turner-Trauring
af916c3968
Merge branch 'master' into 3341-more-python-3-utils 2020-07-13 14:30:11 -04:00
Sajith Sasidharan
144001f380 Use a better assert in status subpath test 2020-07-11 08:30:39 -04:00
Sajith Sasidharan
d4a02aa1cd Remove a print statement 2020-07-09 17:14:55 -04:00
Sajith Sasidharan
5276ea5b37 Merge branch 'master' into 3254.status-status-nevow-to-twisted-web 2020-07-09 17:09:50 -04:00
Sajith Sasidharan
956c2c535d Remove unused import 2020-07-09 17:09:12 -04:00
Sajith Sasidharan
a56d077d3d Test HTML document generated by web.status.Status 2020-07-09 16:59:04 -04:00
Sajith Sasidharan
8331e7d8ec Remove now-unnecessary UploadResultsPage.render_UPLOAD 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
44ecfdad09 Make UploadResultsPage a Resource 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
62e803db25 Make UploadStatusPage a Resource 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
38fe7dd3f5 Remove unused import 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
f30dcc7ec6 Make Element the superclass of UploadResultsRendererMixin 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
4b560d10cc Move time formatter tests
UploadResultsRendererMixin no longer has render_time(); moving tests
for render_time() as tests for abbreviate_time() to a more appropriate
place.
2020-07-09 16:05:31 -04:00
Sajith Sasidharan
9c14eec1e0 Avoid use of RateAndTimeMixin in UploadResultsRendererMixin 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
118ea4267c Render abbreviated rate and time values 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
c0d83def22 Document UploadResultsPage parameter 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
0af8df7203 Document UploadStatusPage 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
855668b188 Remove unused imports 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
a0655c18d6 Handle "t=upload" in UploadResultsPage POST handling 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
6b4d27bec1 Use twisted web template in UploadResultsRendererMixin 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
2ab7b15f8b Make UploadResultsPage a MultiFormatResource 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
71fd4f5d10 Use twisted template tags in upload results page template 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
e6f0f9d038 Make UploadStatusPage a MultiFormatResource 2020-07-09 16:05:31 -04:00
Sajith Sasidharan
d24babe873 Use twisted template tags in upload status page template 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
96fbff684f Use an inner JSONRequest class with renderJSON
Once nevow is removed from web/common.py, we can simplify
renderJSON(), like so:

  def renderJSON():
      req = Request()
      req.args = {"t": ["json"]}
      req.fields = {}
      return resource.render(req)

But for now we have to live with an inner class that implements the
nevow.inevow.IRequest interface.
2020-07-09 16:05:30 -04:00
Sajith Sasidharan
92e83f268b Declare JSON request interface using @implementer
"zope.interface.implements(IRequest)" is deprectated in favor of
"@zope.interface.implementer(IRequest)" decorator.
2020-07-09 16:05:30 -04:00
Sajith Sasidharan
d449306b19 Use DummyRequest in storage tests
Using twisted.web.server.Request causes test_new_style_classes to
fail like so:

  Traceback (most recent call last):
  Failure: testtools.testresult.real._StringException: Traceback (most recent call last):
    File ".tox/coverage/lib/python2.7/site-packages/allmydata/test/test_python2_regressions.py", line 69, in test_new_style_classes
      "Expected to find no classic classes.",
    File ".tox/coverage/lib/python2.7/site-packages/testtools/testcase.py", line 502, in assertThat
      raise mismatch_error
  testtools.matchers._impl.MismatchError: !=:
  reference = set([])
  actual    = set([<class allmydata.test.test_storage.JSONRequest at 0x7fd938040bb0>])
  : Expected to find no classic classes.

Seems that `DummyRequest` is an acceptable new style class.
2020-07-09 16:05:30 -04:00
Sajith Sasidharan
6b61b75658 Refactor storage test helpers
Rewrite `renderSynchronously()` to use `renderDeferred()`
2020-07-09 16:05:30 -04:00
Sajith Sasidharan
bdfa667a22 Add docstrings to storage test helpers 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
7e26dd42e9 Remove redundant render_json() method 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
6379601722 Wrap renderer results in tags 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
0af744610f Avoid using nevow FakeRequest in storage test.
Use twisted.web.server.Request instead, with a DummyChannel.

There's still one line of inevitable nevow now, because of code in
web/common.py; but that should be easily replaceable once we switch
that over.
2020-07-09 16:05:30 -04:00
Sajith Sasidharan
de5d04ab79 Remove an extraneous directive
`t:data` is not really a Twisted template directive.  Added my
mistake, removing now.
2020-07-09 16:05:30 -04:00
Sajith Sasidharan
a056f18ca9 Remove StorageStatus.renderHTTP
This was added to please the test suite. Pleased to remove it!
2020-07-09 16:05:30 -04:00
Sajith Sasidharan
a6e6c5cee0 Get rid of WebRenderingMixin in storage test 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
8d31791940 Use a helper to exercise render() in storage test cases 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
7126d3247c Prefix member variable with "_" 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
0d9ec2b206 Use slots to render storage stats table 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
9dd9d98b8c Give the suite the precise string it wants 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
1469af0f3b Use BeautifulSoup to check favicon in storage page 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
56e2fa3f24 Use <t:transparent> to render node nickname and id
CI did not like the old way, but it passed in my system.  Odd.
2020-07-09 16:05:30 -04:00
Sajith Sasidharan
0bd386384e Mark format_recovered as static method 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
bc8a86e106 Use Unicode strings to render space 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
0b4c235fbd Remove redundant None-checks on self.storage
When no storage is up, `storage_running()` renderer will return a big
honking `no storage server running` message, and no further renderers
will be invoked.  Therefore the extra defense is probably not
required.

(I tested this hypothesis.  The extra defense is not required, unless
there's something I have not seen.)
2020-07-09 16:05:30 -04:00
Sajith Sasidharan
db0e6407dc Use successResultOf in renderSynchronously
Get rid of [].append trick when dealing with the deferred.
2020-07-09 16:05:30 -04:00
Sajith Sasidharan
ee8e730727 Move renderSynchronously to test suite 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
92f6e4bfe5 Use explicit None-check on self.storage 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
affe10b3e9 Return result from renderHTTP
Bogus renderHTTP, but test failures are now down to three. We just
need to handle requests for JSON now.
2020-07-09 16:05:30 -04:00
Sajith Sasidharan
6b5e530cb3 Add a docstring 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
abb8834be1 Rename function for clarity 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
e67fa7cd95 Add docstrings to StorageStatusElement 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
ac9a73eddb Use parentheses in test suite's import statement 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
62a997ce20 Use parentheses in import statement 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
1be736e4d1 Fix test_storage.WebStatus.test_no_server failure 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
8dd4029428 Use <t:transparent /> within table cells 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
6ccb9d29cb Use render_space methods to render space 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
dbc6b2afa0 Drop unused ctx argument from render_space methods 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
d5af7c0d2e Refactor so that test_util pass 2020-07-09 16:05:30 -04:00
Sajith Sasidharan
923219e54a Use right syntax for twisted.web.template tags 2020-07-09 16:05:29 -04:00
Sajith Sasidharan
42c3e276a3 Check storage server status before using it 2020-07-09 16:05:29 -04:00
Sajith Sasidharan
d1f17e1019 Second version of renderSynchronously 2020-07-09 16:05:29 -04:00
Sajith Sasidharan
805b880c2e Add missing flattenString import 2020-07-09 16:05:29 -04:00
Sajith Sasidharan
75488c4aff Add StorageStatus::renderSynchronously
Related to ticket:3247

test_storage.py wants a `StorageStatus::renderSynchronously()` method
and a `StorageStatus::renderHTTP()` method.  Let us begin with the
goofy first-cut.

Both these methods are not only wrong, but they will also not please
the test suite.  However error messages produced in CI can be shared,
and that way I can hopefully get unstuck.
2020-07-09 16:05:29 -04:00
Sajith Sasidharan
aad3557d2b Use twisted.web.template in web/storage.py
Related to ticket:3247.  Nevow usage has been removed, and generated
page looks the same as its former self, but tests are failing because
test_storage.py assumes that we're using nevow.
2020-07-09 16:05:29 -04:00
meejah
7a37eeee67 assert -> Exception 2020-07-09 16:05:29 -04:00
meejah
5cfb350771 streap -> stream 2020-07-09 16:05:29 -04:00
meejah
1f4b619fda unused imports 2020-07-09 16:05:29 -04:00
meejah
77a2f11694 more-testtools-y asserts 2020-07-09 16:05:29 -04:00
meejah
1ce760b237 testtool's asserts 2020-07-09 16:05:29 -04:00
meejah
26d7a3a957 Get rid of ?replace= handling entirely and more-correctly support /uri variants 2020-07-09 16:05:29 -04:00
meejah
e0287a7bfe use attr.s 2020-07-09 16:05:29 -04:00
meejah
af70911e2f embetter docstring 2020-07-09 16:05:29 -04:00
meejah
d91996aa82 better docstring 2020-07-09 16:05:29 -04:00