Ejemplo n.º 1
0
  def test_do_upload(self, host):
    fn = os.path.join(athenad.ROOT, 'qlog.bz2')
    Path(fn).touch()

    item = athenad.UploadItem(path=fn, url="http://localhost:1238", headers={}, created_at=int(time.time()*1000), id='')
    with self.assertRaises(requests.exceptions.ConnectionError):
      athenad._do_upload(item)

    item = athenad.UploadItem(path=fn, url=f"{host}/qlog.bz2", headers={}, created_at=int(time.time()*1000), id='')
    resp = athenad._do_upload(item)
    self.assertEqual(resp.status_code, 201)
Ejemplo n.º 2
0
    def test_do_upload(self):
        fn = os.path.join(athenad.ROOT, 'qlog.bz2')
        Path(fn).touch()

        try:
            item = athenad.UploadItem(path=fn,
                                      url="http://localhost:1238",
                                      headers={},
                                      created_at=int(time.time() * 1000),
                                      id='')
            try:
                athenad._do_upload(item)
            except requests.exceptions.ConnectionError:
                pass

            item = athenad.UploadItem(path=fn,
                                      url="http://localhost:44444/qlog.bz2",
                                      headers={},
                                      created_at=int(time.time() * 1000),
                                      id='')
            resp = athenad._do_upload(item)
            self.assertEqual(resp.status_code, 201)
        finally:
            os.unlink(fn)