Skip to content

Commit

Permalink
server_pwd code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepmanbc committed Jul 10, 2019
1 parent d1c965a commit 03f4e2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 3 additions & 5 deletions creopyson/server.py
Expand Up @@ -2,6 +2,7 @@

import requests
import json
import re


def pwd(client):
Expand All @@ -24,12 +25,9 @@ def pwd(client):
"function": "pwd",
}
# ask `http://localhost:9056/server` vs `http://localhost:9056/creoson`
list_adress = client.server.split('/')[:-1]
list_adress.append('server')
server_adress = "/".join(list_adress)
server_adress = client.server.replace("creoson", "server")
server_adress = re.sub(r'creoson$', 'server', client.server)
r = requests.post(server_adress, data=json.dumps(request))
json_result = json.loads(r.content)
json_result = r.json()
status = json_result["status"]["error"]

if not status:
Expand Down
10 changes: 4 additions & 6 deletions tests/test_server.py
Expand Up @@ -12,8 +12,7 @@ class Mk_post():
def __init__(self, *args, **kwargs):
pass

@property
def content(self):
def json(self):
results = {
"status": {
"error": False,
Expand All @@ -22,7 +21,7 @@ def content(self):
"dirname": "C:/CreosonServer-2.3.0-win64"
}
}
return json.dumps(results).encode()
return results

monkeypatch.setattr(requests, 'post', Mk_post)
c = creopyson.Client()
Expand All @@ -36,15 +35,14 @@ class Mk_post():
def __init__(self, *args, **kwargs):
pass

@property
def content(self):
def json(self):
results = {
"status": {
"error": True,
"message": "error message"
}
}
return json.dumps(results).encode()
return results

monkeypatch.setattr(requests, 'post', Mk_post)
c = creopyson.Client()
Expand Down

0 comments on commit 03f4e2d

Please sign in to comment.