Skip to content

Commit 580815c

Browse files
committed
A simplistic class to parse ABE files in python
1 parent 7575651 commit 580815c

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

abe/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.1.0'

abe/mocks.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import json
2+
3+
from supermutes.dot import dotify
4+
5+
6+
class AbeMock(object):
7+
8+
def __init__(self, filename):
9+
"""
10+
Initialise an ABE mock from data.
11+
12+
filename is expected to be the path to an ABE file.
13+
14+
"""
15+
with open(filename, 'r') as f:
16+
data = json.load(f)
17+
18+
# map JSON fields to attributes
19+
self.__dict__ = data
20+
21+
# Make all example requests and reponses accessible via dot syntax
22+
# (e.g. mock["OK"].request.status)
23+
for k, v in self.examples.items():
24+
self.examples[k] = dotify(v)

0 commit comments

Comments
 (0)