Skip to content

Commit e66dd70

Browse files
committed
Some changes in model
1 parent 3265611 commit e66dd70

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

reportportal_client/model/response.py

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,45 @@
11
import json
22

33

4-
class EntryCreatedRS(object):
5-
def __init__(self, id=None, raw=None):
6-
super(EntryCreatedRS, self).__init__()
7-
self.id = id
4+
class RS(object):
5+
def __init__(self, raw):
6+
super(RS, self).__init__()
87
self.raw = raw
9-
if raw is not None:
10-
self.id = json.loads(raw)["id"]
8+
9+
10+
class EntryCreatedRS(RS):
11+
def __init__(self, raw):
12+
super(EntryCreatedRS, self).__init__(raw)
13+
14+
@property
15+
def id(self):
16+
try:
17+
return json.loads(self.raw)["id"]
18+
except KeyError:
19+
print("{0} object has no attribute 'id'".format(self.raw))
20+
return None
1121

1222
def as_dict(self):
13-
return {"id": self.id}
23+
try:
24+
return {"id": self.id}
25+
except KeyError:
26+
return json.loads(self.raw)
27+
1428

29+
class OperationCompletionRS(RS):
30+
def __init__(self, raw):
31+
super(OperationCompletionRS, self).__init__(raw)
1532

16-
class OperationCompletionRS(object):
17-
def __init__(self, msg=None, raw=None):
18-
super(OperationCompletionRS, self).__init__()
19-
self.msg = msg
20-
if raw is not None:
21-
self.msg = json.loads(raw)["msg"]
33+
@property
34+
def msg(self):
35+
try:
36+
return json.loads(self.raw)["msg"]
37+
except KeyError:
38+
print("{0} object has no attribute 'msg'".format(self.raw))
39+
return None
2240

2341
def as_dict(self):
24-
return {"msg": self.msg}
42+
try:
43+
return {"msg": json.loads(self.raw)["msg"]}
44+
except KeyError:
45+
return json.loads(self.raw)

0 commit comments

Comments
 (0)