Example #1
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)
Example #2
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)
Example #3
0
 def _maybe_create_download_node(self):
     if not self._download_status:
         ds = DownloadStatus(self._verifycap.storage_index,
                             self._verifycap.size)
         if self._history:
             self._history.add_download(ds)
         self._download_status = ds
     if self._node is None:
         self._node = DownloadNode(self._verifycap, self._storage_broker,
                                   self._secret_holder, self._terminator,
                                   self._history, self._download_status)