示例#1
0
 def test_simple(self, http):
     recent_items = active_items = [
         UploadStatus(),
         DownloadStatus("abcd", 12345),
         PublishStatus(),
         RetrieveStatus(),
         UpdateStatus(),
         FakeStatus(),
     ]
     values = [
         StringIO(json.dumps({
             "active": list(
                 marshal_json(item)
                 for item
                 in active_items
             ),
             "recent": list(
                 marshal_json(item)
                 for item
                 in recent_items
             ),
         })),
         StringIO(json.dumps({
             "counters": {
                 "bytes_downloaded": 0,
             },
             "stats": {
                 "node.uptime": 0,
             }
         })),
     ]
     http.side_effect = lambda *args, **kw: values.pop(0)
     do_status(self.options)
示例#2
0
    def test_simple(self):
        recent_items = active_items = [
            UploadStatus(),
            DownloadStatus(b"abcd", 12345),
            PublishStatus(),
            RetrieveStatus(),
            UpdateStatus(),
            FakeStatus(),
        ]
        values = [
            BytesIO(
                json.dumps({
                    "active":
                    list(marshal_json(item) for item in active_items),
                    "recent":
                    list(marshal_json(item) for item in recent_items),
                }).encode("utf-8")),
            BytesIO(
                json.dumps({
                    "counters": {
                        "bytes_downloaded": 0,
                    },
                    "stats": {
                        "node.uptime": 0,
                    }
                }).encode("utf-8")),
        ]

        def do_http(*args, **kw):
            return values.pop(0)

        do_status(self.options, do_http)
示例#3
0
 def test_simple(self, http):
     recent_items = active_items = [
         UploadStatus(),
         DownloadStatus("abcd", 12345),
         PublishStatus(),
         RetrieveStatus(),
         UpdateStatus(),
         FakeStatus(),
     ]
     values = [
         StringIO(json.dumps({
             "active": list(
                 marshal_json(item)
                 for item
                 in active_items
             ),
             "recent": list(
                 marshal_json(item)
                 for item
                 in recent_items
             ),
         })),
         StringIO(json.dumps({
             "counters": {
                 "bytes_downloaded": 0,
             },
             "stats": {
                 "node.uptime": 0,
             }
         })),
     ]
     http.side_effect = lambda *args, **kw: values.pop(0)
     do_status(self.options)
示例#4
0
 def test_no_operations(self, http):
     values = [
         StringIO(json.dumps({
             "active": [],
             "recent": [],
         })),
         StringIO(json.dumps({
             "counters": {
                 "bytes_downloaded": 0,
             },
             "stats": {
                 "node.uptime": 0,
             }
         })),
     ]
     http.side_effect = lambda *args, **kw: values.pop(0)
     do_status(self.options)
示例#5
0
 def test_no_operations(self, http):
     values = [
         StringIO(json.dumps({
             "active": [],
             "recent": [],
         })),
         StringIO(json.dumps({
             "counters": {
                 "bytes_downloaded": 0,
             },
             "stats": {
                 "node.uptime": 0,
             }
         })),
     ]
     http.side_effect = lambda *args, **kw: values.pop(0)
     do_status(self.options)
示例#6
0
    def test_no_operations(self):
        values = [
            StringIO(ensure_text(json.dumps({
                "active": [],
                "recent": [],
            }))),
            StringIO(
                ensure_text(
                    json.dumps({
                        "counters": {
                            "bytes_downloaded": 0,
                        },
                        "stats": {
                            "node.uptime": 0,
                        }
                    }))),
        ]

        def do_http(*args, **kw):
            return values.pop(0)

        do_status(self.options, do_http)
示例#7
0
 def test_simple(self, http):
     values = [
         StringIO(json.dumps({
             "active": [
                 {
                     "progress": 0.5,
                     "storage-index-string": "index0",
                     "status": "foo",
                 },
                 {
                     "progress-hash": 1.0,
                     "progress-ciphertext": 1.0,
                     "progress-encode-push": 0.5,
                     "storage-index-string": "index1",
                     "status": "bar",
                 }
             ],
             "recent": [
                 {
                     "type": "download",
                     "total-size": 12345,
                     "storage-index-string": "index1",
                     "status": "bar",
                 },
             ]
         })),
         StringIO(json.dumps({
             "counters": {
                 "bytes_downloaded": 0,
             },
             "stats": {
                 "node.uptime": 0,
             }
         })),
     ]
     http.side_effect = lambda *args, **kw: values.pop(0)
     do_status(self.options)
示例#8
0
    def test_fetch_error(self, http):

        def boom(*args, **kw):
            raise RuntimeError("boom")
        http.side_effect = boom
        do_status(self.options)
示例#9
0
def status(options):
    from allmydata.scripts import tahoe_status
    return tahoe_status.do_status(options)
示例#10
0
    def test_fetch_error(self):
        def do_http(*args, **kw):
            raise RuntimeError("boom")

        do_status(self.options, do_http)
示例#11
0
    def test_fetch_error(self, http):

        def boom(*args, **kw):
            raise RuntimeError("boom")
        http.side_effect = boom
        do_status(self.options)
示例#12
0
def status(options):
    from allmydata.scripts import tahoe_status
    return tahoe_status.do_status(options)