autopep8 et upload files

This commit is contained in:
Julien Duponchelle committed 2015-02-23 17:21:39 +01:00
1 parent 259f6249e2
commit c9314ec509
16 files changed
+99 -24

No files matched your search

+1 -1
View File
@@ -49,7 +49,7 @@ class Query:
return "http://{}:{}{}".format(self._host, self._port, path)
return "http://{}:{}/v{}{}".format(self._host, self._port, version, path)
def _fetch(self, method, path, body=None, api_version = 1, **kwargs):
def _fetch(self, method, path, body=None, api_version=1, **kwargs):
"""Fetch an url, parse the JSON and return response
Options:
+21 -5
View File
@@ -15,17 +15,33 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
This test suite check /version endpoint
It's also used for unittest the HTTP implementation.
"""
import aiohttp
import os
from unittest.mock import patch
from gns3server.version import __version__
def test_version_index_upload(server):
def test_index_upload(server):
response = server.get('/upload', api_version=None)
assert response.status == 200
html = response.html
assert "GNS3 Server" in html
assert "Select & Upload" in html
def test_upload(server, tmpdir):
with open(str(tmpdir / "test"), "w+") as f:
f.write("TEST")
body = aiohttp.FormData()
body.add_field("file", open(str(tmpdir / "test"), "rb"), content_type="application/iou", filename="test2")
with patch("gns3server.config.Config.get_section_config", return_value={"image_directory": str(tmpdir)}):
response = server.post('/upload', api_version=None, body=body, raw=True)
with open(str(tmpdir / "test2")) as f:
assert f.read() == "TEST"
assert "test2" in response.body.decode("utf-8")