mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-08 19:34:18 +00:00
Improve test for Magic Folder statistics and move it from test_system.py to test_magic_folder.py.
This commit is contained in:
parent
dd0597f869
commit
37d22efaea
@ -1,6 +1,6 @@
|
||||
|
||||
import os, sys
|
||||
import shutil
|
||||
import shutil, simplejson
|
||||
|
||||
from twisted.trial import unittest
|
||||
from twisted.internet import defer, task
|
||||
@ -1340,6 +1340,33 @@ class MockTest(MagicFolderTestMixin, unittest.TestCase):
|
||||
d.addCallback(cleanup)
|
||||
return d
|
||||
|
||||
def test_statistics(self):
|
||||
self.set_up_grid()
|
||||
self.local_dir = abspath_expanduser_unicode(u"test_statistics", base=self.basedir)
|
||||
self.mkdir_nonascii(self.local_dir)
|
||||
|
||||
d = self.create_invite_join_magic_folder(u"Alice\u0101", self.local_dir)
|
||||
d.addCallback(self._restart_client)
|
||||
|
||||
# Write something short enough for a LIT file.
|
||||
d.addCallback(lambda ign: self._check_file(u"short", "test"))
|
||||
|
||||
# test magic-folder statistics
|
||||
d.addCallback(lambda res: self.GET("statistics"))
|
||||
def _got_stats(res):
|
||||
self.failUnlessIn("Operational Statistics", res)
|
||||
self.failUnlessIn("Magic Folder", res)
|
||||
d.addCallback(_got_stats)
|
||||
d.addCallback(lambda res: self.GET("statistics?t=json"))
|
||||
def _got_stats_json(res):
|
||||
data = simplejson.loads(res)
|
||||
print data["counters"]
|
||||
self.failUnlessEqual(data["counters"]["magic_folder.uploader.files_uploaded"], 1)
|
||||
d.addCallback(_got_stats_json)
|
||||
d.addBoth(self.cleanup)
|
||||
return d
|
||||
|
||||
|
||||
class RealTest(MagicFolderTestMixin, unittest.TestCase):
|
||||
"""This is skipped unless both Twisted and the platform support inotify."""
|
||||
|
||||
|
@ -697,22 +697,6 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
# the key, which should cause the download to fail the post-download
|
||||
# plaintext_hash check.
|
||||
|
||||
def test_statistics_for_magic_folder(self):
|
||||
self.basedir = "system/SystemTest/test_statistics_for_magic_folder"
|
||||
d = self.set_up_nodes()
|
||||
# see if the statistics page exists
|
||||
d.addCallback(lambda res: self.GET("statistics"))
|
||||
def _got_stats(res):
|
||||
self.failUnlessIn("Operational Statistics", res)
|
||||
self.failUnlessIn("Magic Folder", res)
|
||||
d.addCallback(_got_stats)
|
||||
d.addCallback(lambda res: self.GET("statistics?t=json"))
|
||||
def _got_stats_json(res):
|
||||
data = simplejson.loads(res)
|
||||
#self.failUnlessEqual(data["counters"]["uploader.files_uploaded"], 0)
|
||||
d.addCallback(_got_stats_json)
|
||||
return d
|
||||
|
||||
def test_filesystem(self):
|
||||
self.basedir = "system/SystemTest/test_filesystem"
|
||||
self.data = LARGE_DATA
|
||||
|
Loading…
x
Reference in New Issue
Block a user