Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
madhavipuliraju committed Feb 27, 2017
2 parents 0740e35 + 06f3fff commit 343e7ba
Show file tree
Hide file tree
Showing 2 changed files with 316 additions and 16 deletions.
164 changes: 153 additions & 11 deletions src/runtime/rest/api.org
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,37 @@ def get_lab():
msg = {"status": "failure",
"msg": err_str}
return jsonify(msg)

elif 'keyword_lab_name' in request.args:
keyword = request.args['keyword_lab_name']
try:
labs = SystemInterface.get_labs_by_keyword_lab_name(keyword)
return jsonify_list(labs)
except TypeError as e:
err_str = str(e)
msg = {"status": "failure",
"msg": err_str }
return jsonify(msg)

except StateError as e:
err_str = str(e)
msg = {"status": "failure",
"msg": err_str}
return jsonify(msg)

except NotFoundError as e:
err_str = str(e)
msg = {"status": "failure",
"status code": 404,
"msg": err_str}
return jsonify(msg)

except Exception as e:
err_str = str(e)
msg = {"status": "failure",
"msg": err_str}
return jsonify(msg)

else:
try:
labs = SystemInterface.get_labs()
Expand Down Expand Up @@ -731,6 +762,16 @@ class TestGetLab(TestCase):
response = self.client.post("/developers", data=json.dumps(payload),
headers=headers)

payload = {'hosting_status': 'hosted',
'hosted_url': 'http://cse14-iiith.vlabs.ac.in',
'hosted_on': 'cloud',
'key': KEY}

headers = {'Content-Type': 'application/json'}

response = self.client.post("/hostinginfos", data=json.dumps(payload),
headers=headers)

payload = {'lab_name': 'Data Structures',
'lab_id': 'cse01',
'overview' : 'overview',
Expand All @@ -740,24 +781,15 @@ class TestGetLab(TestCase):
'assets': ['vlabs.ac.in/images/static/logo.png'],
'key': KEY,
'experiments': ['exp1'],
'developers': ['abc@gmail.com']
'developers': ['abc@gmail.com'],
'hosting_infos':['http://cse14-iiith.vlabs.ac.in']
}

headers = {'Content-Type': 'application/json'}

response = self.client.post("/labs", data=json.dumps(payload),
headers=headers)

payload = {'hosting_status': 'hosted',
'hosted_url': 'http://cse14-iiith.vlabs.ac.in',
'hosted_on': 'cloud',
'key': KEY}

headers = {'Content-Type': 'application/json'}

response = self.client.post("/hostinginfos", data=json.dumps(payload),
headers=headers)

response = self.client.get("/labs", headers=headers)
self.assertEqual(response.status_code, 200)

Expand Down Expand Up @@ -1279,6 +1311,115 @@ class TestGetLabsbyAsset(TestCase):

#+END_SRC

**** TestGetLabbyLabNameKeyword
#+NAME: test_get_lab_by_labname_keyword
#+BEGIN_SRC python
class TestGetLabbyLabNameKeyWord(TestCase):
TESTING = True
def create_app(self):
app = create_app(config)
return app

def setUp(self):
db.create_all()

def tearDown(self):
db.session.remove()
db.drop_all()

def test_get_lab_by_labname_keyword(self):
print "test_get_lab_by_labname_keyword_in_rest"

payload = {'inst_name': 'IIT Kanpur',
'inst_id': 'IITK',
'key': KEY}

headers = {'Content-Type': 'application/json'}

response = self.client.post("/institutes", data=json.dumps(payload),
headers=headers)

payload = {'integration_level': 4,
'key': KEY}

headers = {'Content-Type': 'application/json'}

response = self.client.post("/integrationstatuss", data=json.dumps(payload),
headers=headers)

payload = {'dis_name': 'Computer Science',
'dis_id': 'CSE',
'key': KEY}

headers = {'Content-Type': 'application/json'}

response = self.client.post("/disciplines", data=json.dumps(payload),
headers=headers)

payload = {'asset_type': 'Image',
'path': 'vlabs.ac.in/images/static/logo.png',
'key': KEY}

headers = {'Content-Type': 'application/json'}

response = self.client.post("/assets", data=json.dumps(payload),
headers=headers)

payload = {'exp_name': 'arrays',
'exp_id': 'exp1',
'overview' : 'overview',
'sections': [],
'key': KEY}

headers = {'Content-Type': 'application/json'}

response = self.client.post("/experiments", data=json.dumps(payload),
headers=headers)

payload = {'hosting_status': 'hosted',
'hosted_url': 'http://cse14-iiith.vlabs.ac.in',
'hosted_on': 'cloud',
'key': KEY}

headers = {'Content-Type': 'application/json'}

response = self.client.post("/hostinginfos", data=json.dumps(payload),
headers=headers)


payload = {'name': 'Prof. Dharamaja',
'email': 'abc@gmail.com',
'key': KEY}

headers = {'Content-Type': 'application/json'}

response = self.client.post("/developers", data=json.dumps(payload),
headers=headers)

payload = {'lab_name': 'Data Structures',
'lab_id': 'cse01',
'overview' : 'overview',
'inst_id': 'IITK',
'integration_level': 4,
'dis_id': 'CSE',
'assets': ['vlabs.ac.in/images/static/logo.png'],
'key': KEY,
'experiments': ['exp1'],
'developers': ['abc@gmail.com'],
'hosted_url': 'http://cse14-iiith.vlabs.ac.in'
}

headers = {'Content-Type': 'application/json'}

response = self.client.post("/labs", data=json.dumps(payload),
headers=headers)


response = self.client.get("/labs?keyword_lab_name=data", headers=headers)
self.assertEqual(response.status_code, 200)

#+END_SRC


** Add Lab
*** API Designs
Expand Down Expand Up @@ -7196,6 +7337,7 @@ if __name__ == '__main__':
<<test_get_labs_by_institute>>
<<test_get_labs_by_lab_name>>
<<test_get_labs_by_discipline>>
<<test_get_lab_by_labname_keyword>>
<<test_get_exp_by_expid>>
<<test_get_discipline_by_disid>>
<<test_add_experiment>>
Expand Down
Loading

0 comments on commit 343e7ba

Please sign in to comment.