Skip to content

Commit

Permalink
Improve test for Magic Folder statistics and move it from test_system…
Browse files Browse the repository at this point in the history
….py to test_magic_folder.py.
  • Loading branch information
daira committed Feb 16, 2016
1 parent 73e9cfe commit e3a27ed
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
29 changes: 28 additions & 1 deletion src/allmydata/test/test_magic_folder.py
@@ -1,6 +1,6 @@

import os, sys
import shutil
import shutil, simplejson

from twisted.trial import unittest
from twisted.internet import defer, task
Expand Down Expand Up @@ -1340,6 +1340,33 @@ def cleanup(res):
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."""

Expand Down
16 changes: 0 additions & 16 deletions src/allmydata/test/test_system.py
Expand Up @@ -718,22 +718,6 @@ def mangle_uri(self, gooduri):
# 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
Expand Down

0 comments on commit e3a27ed

Please sign in to comment.