-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotebook_test_demo.py
More file actions
34 lines (28 loc) · 1.01 KB
/
notebook_test_demo.py
File metadata and controls
34 lines (28 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## this is a fake SDK for providing demo
## of notebook testing examples
import sys
import json
import jsonschema
from jsonschema import validate
class NotebookTestDemo(object):
def __init__(self):
pass
def slow_perf_endpoint(self):
total = 0
for i in range(1000):
for j in range(1000):
total += i * (-1) ** j
def email_search(self, name):
emails = {
"paul karayan": "paul@irregular.com"
}
return emails.get(name, 'No Email Found')
def validate_json_schema(self, schema, test_json_data):
print("Validating the input data using jsonschema:")
for idx, item in enumerate(test_json_data):
try:
validate(item, schema)
sys.stdout.write("Record #{}: OK\n".format(idx))
except jsonschema.exceptions.ValidationError as ve:
sys.stderr.write("Record #{}: ERROR\n".format(idx))
sys.stderr.write(str(ve) + "\n")