diff --git a/scripts/backup.sh b/scripts/backup.sh index 68c1970..0d075c5 100644 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -1,9 +1,9 @@ #!/bin/bash -DB_NAME="feedback" +DB_NAME="lds" DB_PASS="root" -OUT_FILE_NAME="feedbackbackup" +OUT_FILE_NAME="ldsbackup" VERSION="v1.0.0" OUT_FILE="$OUT_FILE_NAME-$VERSION.tar" diff --git a/scripts/labspec.json b/scripts/labspec.json deleted file mode 100644 index c5ee93a..0000000 --- a/scripts/labspec.json +++ /dev/null @@ -1,121 +0,0 @@ - -{ - "lab": { - "description": { - "name": "Feedback portal", - "id": "feedbackv2", - "status": "working code", - "discipline": [], - "type": "", - "server-side": true, - "integration_level": 6, - "developer": [ - { - "name": "Sripathi Kammari", - "title": "", - "role": "Project Engineer", - "organization": "VLEAD", - "institute": "IIIT Hyderabad", - "web": "", - "department": "Software Engg Research Lab (SERL)", - "contact": { - "email": "sripathi@vlabs.ac.in", - "alternate_email": "", - "mobile_number": "", - "office_number": "" - } - }, - { - "name": "Sripathi", - "title": "", - "role": "Software Engineer", - "organization": "VLEAD", - "institute": "IIIT Hyderabad", - "web": "", - "department": "Software Engg Research Lab (SERL)", - "contact": { - "email": "sripathi@vlabs.ac.in", - "alternate_email": "", - "mobile_number": "", - "office_number": "" - } - }, - { - "name": "Madhavi Puliraju", - "title": "", - "role": "Software Engineer", - "organization": "VLEAD", - "institute": "IIIT Hyderabad", - "web": "", - "department": "Software Engg Research Lab (SERL)", - "contact": { - "email": "madhavi@vlabs.ac.in", - "alternate_email": "", - "mobile_number": "", - "office_number": "" - } - } - ] - }, - "build_requirements": { - "platform": { - "os": "ubuntu", - "osVersion": "12", - "arch": "x64", - "service_pack": "", - "installer": [ - ], - "build_steps": { - "configure": [], - "pre_build": [], - "build": [ - "cd ../;make build" - ], - "post_build": [ - "cp -R ../build/code/* /var/www/", - "chmod -R 755 /var/www", - "mkdir /var/www/logs", - "chmod -R 777 /var/www/logs" - ], - "status": [] - } - } - }, - "runtime_requirements": { - "platform": { - "os": "ubuntu", - "osVersion": "12", - "arch": "x64", - "servicepack": "", - "hosting": "dedicated", - "memory": { - "max_required": "4gb", - "min_required": "2gb" - }, - "storage": { - "min_required": "10gb" - }, - "installer": [ - "bash /var/www/deployment/setup.sh", - "python /var/www/deployment/setup.py install", - "bash /var/www/deployment/configure.sh", - "PYTHONPATH=/var/www python /var/www/deployment/db_setup.py" - ], - "lab_actions": { - "init" : [], - "shutdown": [], - "pause" : [], - "resume" : [], - "start" : [], - "stop" : [], - "backup" : [], - "restore" : [], - "clean" : [], - "stats" : [], - "publish" : [] - } - } - } - }, - "template": "1.0" -} diff --git a/scripts/restore.sh b/scripts/restore.sh index ff95dea..c64259a 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -1,6 +1,6 @@ #!/bin/bash -DB_NAME="feedback" +DB_NAME="lds" DB_PASS="xxx" VERSION="v1.0.0" diff --git a/src/data-model/index.org b/src/data-model/index.org index c26ed42..7b1b67e 100755 --- a/src/data-model/index.org +++ b/src/data-model/index.org @@ -203,23 +203,30 @@ TYPE IntegrationStatus ;;; Relations with cardinality constraints -[developer, lab] : Developer + > Lab + -[discipline, lab] : Discipline + > Lab + -[institute, lab] : Institute ! > Lab + -[experiment, lab] : Experiment + > Lab ! -[experiment, section] : Experiment > Section -[lab, name] : Lab + > Name ! -[experiment name] : Experiment + > Name ! -[institute, name] : Institute ! > Name ! -[discipline, name] : Discipline ! > Name ! -[developer, name] : Developer + > Name ! -[developer, email] : Developer ! > Email ! -[hostinginfo, lab] : HostingInfo + > Lab ! -[asset, lab] : Asset + > Lab ! -[asset, discipline] : Asset + > Discipline + -[asset, experiment] : Asset + > Experiment ! -[asset, institute] : Asset + > Institute ! -[integrationstatus, lab] : IntegrationStatus ! > Lab * +[developer, lab] : Developer + > Lab + +[discipline, lab] : Discipline + > Lab + +[institute, lab] : Institute ! > Lab + +[experiment, lab] : Experiment + > Lab ! +[hostinginfo, lab] : HostingInfo + > Lab ! +[asset, lab] : Asset + > Lab ! +[integrationstatus, lab] : IntegrationStatus ! > Lab * + +[discipline, experiment] : Discipline + > Experiment + +[institute, experiment] : Institute ! > Experiment + +[experiment, section] : Experiment ! > Section + +[experiment, developer] : Experiment + > Developer + +[experiment, hostinginfo] : Experiment ! > HostingInfo + +[asset, experiment] : Asset + > Experiment ! +[experiment, integrationstatus] : Experiment * > IntegrationStatus ! + +[developer, name] : Developer + > Name ! +[developer, email] : Developer ! > Email ! +[developer, discipline] : Developer + > Discipline + +[developer, institute] : Developer + > Institute ! + +[asset, discipline] : Asset + > Discipline + +[asset, institute] : Asset + > Institute ! + #+END_SRC @@ -299,6 +306,7 @@ Sets lab-id-set : lab-set.lab_id ; set of all lab_ids in the system exp-name-set : experiment-set.exp_name ; set of all exp-names in the system exp-id-set : experiment-set.exp_id ; set of all exp_ids in the system + section-set : experiment-set.section ; set of all sections in the system inst-name-set : institute-set.inst_name ; set of all inst-names in the system inst-id-set : institute-set.inst_id ; set of all inst_ids in the system disc-name-set : discipline-set.disc_name ; set of all disc-names in the system @@ -318,13 +326,27 @@ Sets :CUSTOM_ID: referential_integrity_relations :END: #+BEGIN_SRC spec :tangle spec.txt -[disciplines, institutes] : institute-set + > discipline-set + -[developers, institutes] : institute-set ! > developer-set + -[developers, labs] : lab-set + > developer-set + -[experiments, labs] : lab-set ! > experiment-set + -[hostinginfo, labs] : lab-set + > hostinginfo-set + -[asset, labs] : lab-set ! > asset-set + -[integrationstatus, labs] : lab-set * > integrationstatus-set ! + +[developers, labs] : lab-set + > developer-set + +[discipline, labs] : lab-set + > discipline-set + +[institute, labs] : lab-set + > institute-set ! +[experiments, labs] : lab-set ! > experiment-set + +[hostinginfo, labs] : lab-set + > hostinginfo-set + +[asset, labs] : lab-set ! > asset-set + +[integrationstatus, labs] : lab-set * > integrationstatus-set ! +[discipline, experiments] : experiment-set + > discipline-set + +[institute, experiments] : experiment-set + > institute-set ! +[experiments, sections] : section-set + > experiment-set ! +[experiments, developers] : developer-set + > experiment-set + +[experiments, hostinginfos] : hostinginfo-set + > experiment-set ! +[asset, experiments] : experiment-set ! > asset-set + +[experiments, integrationstatus] : integrationstatus-set ! > experiment-set * +[developer, name] : name-set ! > developer-set + +[developer, email] : email-set ! > developer-set ! +[developer, discipline] : discipline-set + > developer-set + +[developers, institutes] : institute-set ! > developer-set + +[asset, discipline] : discipline-set + > asset-set + +[asset, institute] : institute-set ! > asset-set + #+END_SRC @@ -486,6 +508,114 @@ entity-set. The operation may take additional parameters. #+END_SRC +** Add Section + :PROPERTIES: + :CUSTOM_ID: add_section + :END: +*** Parameters + :PROPERTIES: + :CUSTOM_ID: parameters + :END: +#+BEGIN_SRC spec :tangle spec.txt + sec: Section, s: Session +#+END_SRC +*** Actor credentials + :PROPERTIES: + :CUSTOM_ID: actor_credentials + :END: +#+BEGIN_SRC spec :tangle spec.txt + s.key == system configured key +#+END_SRC +*** Referential Integrity + :PROPERTIES: + :CUSTOM_ID: referential_integrity + :END: +#+BEGIN_SRC spec :tangle spec.txt + sec: ~section-set +#+END_SRC +*** Effect + :PROPERTIES: + :CUSTOM_ID: effect + :END: +#+BEGIN_SRC spec :tangle spec.txt + sec = new section + section-set = section-set U {sec} +#+END_SRC + + + +** Add Name + :PROPERTIES: + :CUSTOM_ID: add_name + :END: +*** Parameters + :PROPERTIES: + :CUSTOM_ID: parameters + :END: +#+BEGIN_SRC spec :tangle spec.txt + n: Name, s: Session +#+END_SRC +*** Actor credentials + :PROPERTIES: + :CUSTOM_ID: actor_credentials + :END: +#+BEGIN_SRC spec :tangle spec.txt + s.key == system configured key +#+END_SRC +*** Referential Integrity + :PROPERTIES: + :CUSTOM_ID: referential_integrity + :END: +#+BEGIN_SRC spec :tangle spec.txt + l: ~lab-set +#+END_SRC +*** Effect + :PROPERTIES: + :CUSTOM_ID: effect + :END: +#+BEGIN_SRC spec :tangle spec.txt + n = new name + name-set = name-set U {n} +#+END_SRC + + + +** Add Email + :PROPERTIES: + :CUSTOM_ID: add_email + :END: +*** Parameters + :PROPERTIES: + :CUSTOM_ID: parameters + :END: +#+BEGIN_SRC spec :tangle spec.txt + e: Email, s: Session +#+END_SRC +*** Actor credentials + :PROPERTIES: + :CUSTOM_ID: actor_credentials + :END: +#+BEGIN_SRC spec :tangle spec.txt + s.key == system configured key +#+END_SRC +*** Referential Integrity + :PROPERTIES: + :CUSTOM_ID: referential_integrity + :END: +#+BEGIN_SRC spec :tangle spec.txt + e: ~email-set +#+END_SRC +*** Effect + :PROPERTIES: + :CUSTOM_ID: effect + :END: +#+BEGIN_SRC spec :tangle spec.txt + e = new email + email-set = email-set U {e} +#+END_SRC + + + ** Add Developer :PROPERTIES: :CUSTOM_ID: add_developer @@ -636,7 +766,7 @@ entity-set. The operation may take additional parameters. :CUSTOM_ID: update_lab_parameters :END: #+BEGIN_SRC spec :tangle spec.txt - n: lab_name, lid: lab_id, l: Lab, s: Session + n: lab_name, lid: lab_id, l: Lab, e: Experiment, i: Institute, d: Discipline, r: Developer, h: HostingInfo, a: Asset, is: IntegrationStatu, s: Session #+END_SRC *** Actor credentials :PROPERTIES: @@ -650,10 +780,17 @@ entity-set. The operation may take additional parameters. :CUSTOM_ID: update_lab_referential_integrity :END: #+BEGIN_SRC spec :tangle spec.txt - l : lab-set - s : session-set - n : lab-name-set - lid: ~lab-id-set + l : lab-set + s : session-set + n : lab-name-set + lid : ~lab-id-set + e : experiment-set + i : institute-set + d : discipline-set + r : developer-set + h : hostinginfo-set + a : asset-set + i : integrationstatus-set #+END_SRC *** Effect @@ -674,7 +811,7 @@ entity-set. The operation may take additional parameters. :CUSTOM_ID: update_experiment_parameters :END: #+BEGIN_SRC spec :tangle spec.txt - n: exp_name, eid: exp_id, e: Experiment, s: Session + n: exp_name, eid: exp_id, e: Experiment, i: Institute, d: Discipline, r: Developer, h: HostingInfo, a: Asset, is: IntegrationStatu, s: Session #+END_SRC *** Actor credentials :PROPERTIES: @@ -688,10 +825,16 @@ entity-set. The operation may take additional parameters. :CUSTOM_ID: update_experiment_referential_integrity :END: #+BEGIN_SRC spec :tangle spec.txt - e : experiment-set - s : session-set - n : ~exp-name-set - eid: ~exp-id-set + e : experiment-set + s : session-set + n : ~exp-name-set + eid : ~exp-id-set + i : institute-set + d : discipline-set + r : developer-set + h : hostinginfo-set + a : asset-set + is : integrationstatus-set #+END_SRC *** Effect @@ -712,7 +855,7 @@ entity-set. The operation may take additional parameters. :CUSTOM_ID: update_institute_parameters :END: #+BEGIN_SRC spec :tangle spec.txt - n: inst_name, iid: inst_id, i: Institute, s: Session + n: inst_name, iid: inst_id, i: Institute, a: Asset, s: Session #+END_SRC *** Actor credentials :PROPERTIES: @@ -726,10 +869,11 @@ entity-set. The operation may take additional parameters. :CUSTOM_ID: update_institute_referential_integrity :END: #+BEGIN_SRC spec :tangle spec.txt - i : institute-set - s : session-set - n : inst-name-set - iid: ~inst-id-set + i : institute-set + s : session-set + n : inst-name-set + iid : ~inst-id-set + a : asset-set #+END_SRC *** Effect @@ -750,7 +894,7 @@ entity-set. The operation may take additional parameters. :CUSTOM_ID: update_discipline_parameters :END: #+BEGIN_SRC spec :tangle spec.txt - n: disc_name, did: disc_id, d: Discipline, s: Session + n: disc_name, did: disc_id, d: Discipline, a: Asset, s: Session #+END_SRC *** Actor credentials :PROPERTIES: @@ -764,10 +908,11 @@ entity-set. The operation may take additional parameters. :CUSTOM_ID: update_discipline_referential_integrity :END: #+BEGIN_SRC spec :tangle spec.txt - d : discipline-set - s : session-set - n : disc-name-set - did: ~disc-id-set + d : discipline-set + s : session-set + n : disc-name-set + did: ~disc-id-set + a : asset-set #+END_SRC *** Effect @@ -788,7 +933,7 @@ entity-set. The operation may take additional parameters. :CUSTOM_ID: update_developer_parameters :END: #+BEGIN_SRC spec :tangle spec.txt - n: name, e: email_id, r: Developer, s: Session + n: name, e: email_id, r: Developer, i: Institute, d: Discipline, s: Session #+END_SRC *** Actor credentials :PROPERTIES: @@ -802,9 +947,11 @@ entity-set. The operation may take additional parameters. :CUSTOM_ID: update_developer_referential_integrity :END: #+BEGIN_SRC spec :tangle spec.txt - r : developer-set - n : name-set - e :~email-set + r : developer-set + n : name-set + e :~email-set + i : institute-set + d : discipline-set #+END_SRC *** Effect @@ -894,43 +1041,6 @@ entity-set. The operation may take additional parameters. #+END_SRC -** Update IntegrationStatus - :PROPERTIES: - :CUSTOM_ID: update_integrationstatus - :END: -*** Parameters - :PROPERTIES: - :CUSTOM_ID: update_integrationstatus_parameters - :END: -#+BEGIN_SRC spec :tangle spec.txt - i: IntegrationStatus, l:Level, s: Session -#+END_SRC -*** Actor credentials - :PROPERTIES: - :CUSTOM_ID: update_integrationstatus_actor_credentials - :END: -#+BEGIN_SRC spec :tangle spec.txt - s.key == system configured key -#+END_SRC -*** Referential Integrity - :PROPERTIES: - :CUSTOM_ID: update_integrationstatus_referential_integrity - :END: -#+BEGIN_SRC spec :tangle spec.txt - i : integrationstatus-set - s : session-set - l : ~level-set - -#+END_SRC -*** Effect - :PROPERTIES: - :CUSTOM_ID: update_integrationstatus_effect - :END: -#+BEGIN_SRC spec :tangle spec.txt - The Integration Status details are updated. -#+END_SRC - - ** Delete Lab :PROPERTIES: :CUSTOM_ID: delete_lab @@ -1079,6 +1189,117 @@ entity-set. The operation may take additional parameters. #+END_SRC +** Delete Section + :PROPERTIES: + :CUSTOM_ID: delete_section + :END: +*** Parameters + :PROPERTIES: + :CUSTOM_ID: delete_lab_parameters + :END: +#+BEGIN_SRC spec :tangle spec.txt + sec: Section, s: Session +#+END_SRC +*** Actor credentials + :PROPERTIES: + :CUSTOM_ID: delete_section_actor_credentials + :END: +#+BEGIN_SRC spec :tangle spec.txt + s.key == system configured key +#+END_SRC +*** Referential Integrity + :PROPERTIES: + :CUSTOM_ID: delete_section_referential_integrity + :END: +#+BEGIN_SRC spec :tangle spec.txt + sec : section-set + s : session-set + +#+END_SRC +*** Effect + :PROPERTIES: + :CUSTOM_ID: delete_section_effect + :END: +#+BEGIN_SRC spec :tangle spec.txt + section-set = section-set - {sec} + +#+END_SRC + + +** Delete Name + :PROPERTIES: + :CUSTOM_ID: delete_name + :END: +*** Parameters + :PROPERTIES: + :CUSTOM_ID: delete_name_parameters + :END: +#+BEGIN_SRC spec :tangle spec.txt + n: Name, s: Session +#+END_SRC +*** Actor credentials + :PROPERTIES: + :CUSTOM_ID: delete_name_actor_credentials + :END: +#+BEGIN_SRC spec :tangle spec.txt + s.key == system configured key +#+END_SRC +*** Referential Integrity + :PROPERTIES: + :CUSTOM_ID: delete_name_referential_integrity + :END: +#+BEGIN_SRC spec :tangle spec.txt + n : name-set + s : session-set + +#+END_SRC +*** Effect + :PROPERTIES: + :CUSTOM_ID: delete_name_effect + :END: +#+BEGIN_SRC spec :tangle spec.txt + name-set = name-set - {n} + +#+END_SRC + + +** Delete Email + :PROPERTIES: + :CUSTOM_ID: delete_email + :END: +*** Parameters + :PROPERTIES: + :CUSTOM_ID: delete_email_parameters + :END: +#+BEGIN_SRC spec :tangle spec.txt + e: Email, s: Session +#+END_SRC +*** Actor credentials + :PROPERTIES: + :CUSTOM_ID: delete_email_actor_credentials + :END: +#+BEGIN_SRC spec :tangle spec.txt + s.key == system configured key +#+END_SRC +*** Referential Integrity + :PROPERTIES: + :CUSTOM_ID: delete_email_referential_integrity + :END: +#+BEGIN_SRC spec :tangle spec.txt + e : email-set + s : session-set + +#+END_SRC +*** Effect + :PROPERTIES: + :CUSTOM_ID: delete_email_effect + :END: +#+BEGIN_SRC spec :tangle spec.txt + email-set = email-set - {e} + +#+END_SRC + + ** Delete Developer :PROPERTIES: :CUSTOM_ID: delete_developer @@ -1198,7 +1419,7 @@ entity-set. The operation may take additional parameters. :CUSTOM_ID: delete_integrationstatus_parameters :END: #+BEGIN_SRC spec :tangle spec.txt - i: IntegrationStatus, s: Session + is: IntegrationStatus, s: Session #+END_SRC *** Actor credentials :PROPERTIES: @@ -1212,7 +1433,7 @@ entity-set. The operation may take additional parameters. :CUSTOM_ID: delete_integrationstatus_referential_integrity :END: #+BEGIN_SRC spec :tangle spec.txt - i : integrationstatus-set + is : integrationstatus-set s : session-set #+END_SRC diff --git a/src/deployment/index.org b/src/deployment/index.org index 90da63d..5ca0677 100755 --- a/src/deployment/index.org +++ b/src/deployment/index.org @@ -46,116 +46,110 @@ from runtime.config.system_config import KEY def populate(): session_cls = System.delegate.entities['session'] - lab_cls = System.delegate.entities['lab'] - experiment_cls = System.delegate.entities['experiment'] - section_cls = System.delegate.entities['section'] - - exp_name = "arrays" - exp_id = "cse02" - overview = "overview" - experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, overview=overview) - - lab_name1="Computer Programming" - lab_id1="CSE01" - key = KEY - overview = "overview" - session = session_cls(key=key) - lab = lab_cls(lab_id=lab_id1, lab_name=lab_name1, \ - overview=overview, experiments=[experiment]) - - lab.save() - name = "Theory" - section = section_cls(name=name) - section.save() - name = "Introduction" - section = section_cls(name=name) - section.save() - name = "Procedure" - section = section_cls(name=name) - section.save() - name = "Simulation" - section = section_cls(name=name) - section.save() - name = "Quiz" - section = section_cls(name=name) - section.save() - name = "Aim" - section = section_cls(name=name) - section.save() - + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] + integration_status_cls = System.delegate.entities['integration_status'] + + inst1 = institute_cls(inst_name="Amrita University", inst_id="amrita", + assets=[]) + inst1.save() + inst2 = institute_cls(inst_name="College of Engineering, Pune", + inst_id="coep", assets=[]) + inst2.save() + inst3 = institute_cls(inst_name="Dayalbagh Educational institute_cls", + inst_id="dei", assets=[]) + inst3.save() + inst4 = institute_cls(inst_name="IIT Bombay", inst_id="iitb", assets=[]) + inst4.save() + inst5 = institute_cls(inst_name="IIT Delhi", inst_id="iitd", assets=[]) + inst5.save() + inst6 = institute_cls(inst_name="IIT Guwahati", inst_id="iitg", assets=[]) + inst6.save() + inst7 = institute_cls(inst_name="IIIT Hyderabad", inst_id="iiith", + assets=[]) + inst7.save() + inst8 = institute_cls(inst_name="IIT Kanpur", inst_id="iitk", assets=[]) + inst8.save() + inst9 = institute_cls(inst_name="IIT Kharagpur", inst_id="iitkgp", + assets=[]) + inst9.save() + inst10 = institute_cls(inst_name="IIT Madras", inst_id="iitm", assets=[]) + inst10.save() + inst11 = institute_cls(inst_name="IIT Roorkee", inst_id="iitr", assets=[]) + inst11.save() + inst12 = institute_cls(inst_name="NIT Surathkal", inst_id="nitk", + assets=[]) + inst12.save() + + dis1 = discipline_cls(dis_name="Aerospace Engineering", dis_id="aero", + assets=[]) + dis1.save() + dis2 = discipline_cls(dis_name="Biotechnology and Biomedical Engineering", + dis_id="biotech", assets=[]) + dis2.save() + dis3 = discipline_cls(dis_name="Chemical Engineering", + dis_id="chem-engg", assets=[]) + dis3.save() + dis4 = discipline_cls(dis_name="Chemical Sciences", + dis_id="chem", assets=[]) + dis4.save() + dis5 = discipline_cls(dis_name="Civil Engineering", + dis_id="civil", assets=[]) + dis5.save() + dis6 = discipline_cls(dis_name="Computer Science and Engineering", + dis_id="cse", assets=[]) + dis6.save() + dis7 = discipline_cls(dis_name="Electrical Engineering", + dis_id="ee", assets=[]) + dis7.save() + dis8 = discipline_cls(dis_name="Electronics and Communication", + dis_id="ece", assets=[]) + dis8.save() + dis9 = discipline_cls(dis_name="Humanities", dis_id="hmt", assets=[]) + dis9.save() + dis10 = discipline_cls(dis_name="Mechanical Engineering", + dis_id="mech", assets=[]) + dis10.save() + dis11 = discipline_cls(dis_name="Physical Sciences", + dis_id="phy-sc", assets=[]) + dis11.save() + dis12 = discipline_cls(dis_name="Textile Engineering", + dis_id="tex-engg", assets=[]) + dis12.save() + dis13 = discipline_cls(dis_name="Design Engineering", + dis_id="dsgn-engg", assets=[]) + dis13.save() + dis14 = discipline_cls(dis_name="Material Sciences", + dis_id="mat-sc", assets=[]) + dis14.save() + + integration_status0 = integration_status_cls(integration_level=0) + integration_status0.save() + + integration_status1 = integration_status_cls(integration_level=1) + integration_status1.save() + + integration_status2 = integration_status_cls(integration_level=2) + integration_status2.save() + + integration_status3 = integration_status_cls(integration_level=3) + integration_status3.save() + + integration_status4 = integration_status_cls(integration_level=4) + integration_status4.save() + + integration_status5 = integration_status_cls(integration_level=5) + integration_status5.save() + + integration_status6 = integration_status_cls(integration_level=6) + integration_status6.save() if __name__ == "__main__": db.create_all(app=create_app(config)) -# populate() + populate() #+END_SRC -* Program to migrate the data -#+BEGIN_SRC python :tangle migrate.py :eval no -import requests -import json -import yaml - -data_url = "http://data.vlabs.ac.in/feedback" -data_by_id = data_url+"/" -fb_url = "http://localhost:5000/feedback" - -fbs = requests.get(data_url).json() -questions = ['feedback_about_experiment', 'feedback_about_lab', - 'how_useful_are_labs', 'suggestions_about_experiment', - 'suggestions_about_lab', 'suggestions_in_general'] - -for index in range(1, len(fbs)): - a_url = data_by_id + str(index) - fb = requests.get(a_url).json() - fb_x = yaml.safe_load(json.dumps(fb)) - gateway_ip = fb_x['ip'] - user_id = fb_x['user_name'] - print index - if fb_x['lab'] is None: - lab_name = "Null" - else: - lab_name = fb_x['lab']['name'] - - if fb_x['experiment'] is None: - exp_name = "Null" - else: - exp_name = fb_x['experiment']['name'] - print exp_name - - responses = [] - for question in questions: - if fb_x[question] is None or\ - fb_x[question] is '': - answer = "Null" - response = {'name': question, - 'answers':[answer] } - responses.append(response) - else: - answer = fb_x[question] - response = {'name': question, - 'answers':[answer] } - responses.append(response) - - version = "virtual-labs-feedback-v1.0" - payload = {'lab_name': lab_name, - 'exp_name': exp_name, - 'key' : 'defaultkey', - 'responses': responses, - 'gateway_ip': gateway_ip, - 'user_id': user_id, - 'version': version - } - - print payload - - headers = {'Content-Type': 'application/json'} - - response = requests.post(fb_url, data=json.dumps(payload), - headers=headers) - print response.status_code - -#+END_SRC * Install all dependencies and setup the software Install all dependencies, including the OS related packages, Python packages, setup the database, configure the webserver, and finally deploy the @@ -292,8 +286,8 @@ update_app_config () { } update_apache_config() { - PROC_NAME="feedback" - WSGI_SCRIPT="feedback.wsgi" + PROC_NAME="lds" + WSGI_SCRIPT="lds.wsgi" APACHE_VHOST_FILE="/etc/apache2/sites-available/default" sed -i "/<\/VirtualHost>/i \ @@ -343,7 +337,7 @@ exit 0; * Deploying the application -#+BEGIN_SRC python :tangle feedback.wsgi :eval no +#+BEGIN_SRC python :tangle lds.wsgi :eval no import sys, os diff --git a/src/deployment/run-lds-in-development-environment.org b/src/deployment/run-lds-in-development-environment.org index 48dca71..8806e28 100755 --- a/src/deployment/run-lds-in-development-environment.org +++ b/src/deployment/run-lds-in-development-environment.org @@ -15,9 +15,9 @@ #+BEGIN_EXAMPLE show databases; #+END_EXAMPLE - - If database is not present, create it + - If database is not present, create it #+BEGIN_EXAMPLE - create database lds + create database lds; #+END_EXAMPLE Exit out of the mysql console @@ -37,11 +37,12 @@ * Setting up dependencies - Install all the dependencies for running the =feedback= applciation. + Install all the dependencies for running the =lds= applciation. The =setup.py= script is in the =build/code/deployment/= directory #+BEGIN_EXAMPLE cd build/code/deployment/ python setup.py install + #+END_EXAMPLE Note :- If you found error something like =error: Couldn't find a setup script in /tmp/easy_install-oTRjpD/oursql-0.9.3.2.linux-i686.tar.gz= please @@ -91,6 +92,7 @@ python setup.py install The application is accessed at =http://localhost:5000= + * API Documentation URL : [https://github.com/vlead/lab-data-service/blob/master/src/runtime/rest/api.org] diff --git a/src/design/index.org b/src/design/index.org index 4896ffb..1db94e3 100644 --- a/src/design/index.org +++ b/src/design/index.org @@ -970,7 +970,6 @@ Not yet implemented [[http://localhost:5000/save_lab_spec_data][example url]] - * Specification Every experiment and a lab has a specification. The specification provides a unique ID, name, contents of an experiment and other meta information of @@ -987,18 +986,18 @@ Not yet implemented integration status, assets etc. #+begin_src -{"experiment": {"id": "e99847", +{ +"experiment": {"id": "e99847", "name": "Parallel and distributed processing", - "discipline": "Computer Science and Engineering", - "institute": "IIIT-Hyderabad", - "developers": [{"Dinesh Malviya", "xyz@gmail.com"}, - {"Ashish Ahuja", "abc@gmail.com"}], - "hostinginfos": [{"hosted", "cloud", "http://cse14-iiith.vlabs.ac.in"}, - {"hosted", "college-cloud", "http://cse14-iiith.ac.in"}], - "integrationstatus": "4", - "assets": [{"Images", "vlabs.ac.in/images/static/logo.png"}, - {"Videos", "vlabs.ac.in/video/abc.mkv"}], - "overview": "This deals with eliciting how parallel and distributed processing is done", + "discipline_id": "CSE", + "institute_id": "IIITH", + "developers": [{"name":"Dinesh Malviya", "email": "xyz@gmail.com"}, + {"name": "Ashish Ahuja", "email":"abc@gmail.com"}], + "hosting_info": [{"hosting_status": "hosted", "hosted_on": "cloud", "hosted_url": "http://cse14-iiith.vlabs.ac.in"}, + {"hosting_status": "hosted", "hosted_on": "college-cloud", "hosted_url": "http://cse14-iiith.ac.in"}], + "integration_level": "4", + "assets": [{"asset_type": "Images", "path": "vlabs.ac.in/images/static/logo.png"}, + {"asset_type": "Videos", "path": "vlabs.ac.in/video/abc.mkv"}], "sections" : ["Introduction", "Objective", "Tutorial", @@ -1009,6 +1008,7 @@ Not yet implemented "Assignment", "References"] } +} #+end_src ** Lab Specification @@ -1020,23 +1020,41 @@ Not yet implemented #+begin_src {"lab": {"id": "cse02", "name": "Computer Programming", - "discipline": "Computer Science and Engineering", - "institute": "IIIT-Hyderabad", - "developers": [{"Dinesh Malviya", "xyz@gmail.com"}, - {"Ashish Ahuja", "abc@gmail.com"}], - "hostinginfos": [{"hosted", "cloud", "http://cse14-iiith.vlabs.ac.in"}, - {"hosted", "college-cloud", "http://cse14-iiith.ac.in"}], - "integrationstatus": "4", - "assets": [{"Images", "vlabs.ac.in/images/static/logo.png"}, - {"Videos", "vlabs.ac.in/video/abc.mkv"}], + "discipline_id": "CSE", + "institute_id": "IIITH", + "developers": [{"name":"Dinesh Malviya", "email": "xyz@gmail.com"}, + {"name": "Ashish Ahuja", "email":"abc@gmail.com"}], + "hosting_info": [{"hosting_status": "hosted", "hosted_on": "cloud", "hosted_url": "http://cse14-iiith.vlabs.ac.in"}, + {"hosting_status": "hosted", "hosted_on": "college-cloud", "hosted_url": "http://cse14-iiith.ac.in"}], + "integration_level": "4", + "assets": [{"asset_type": "Images", "path": "vlabs.ac.in/images/static/logo.png"}, + {"asset_type": "Videos", "path": "vlabs.ac.in/video/abc.mkv"}], "overview": "This lab deals with computer programming", - "sections" : [{"name": "Introduction"}, - {"experiments": [e100, e200, ....]}] + "experiments": [e100, e200, ....] } } #+end_src +** Institute Specification + Each =Institute= is identified by a unique =inst_id=. +#+BEGIN_SRC +{ +"inst_id": "IIITH", +"inst_name": "IIIT Hyderabad" +} +#+END_SRC +** Discipline Specification + Each =Discipline= is identified by a unique =dis_id=. +#+BEGIN_SRC +{ + "dis_id": "CSE", + "dis_name": "Computer Science and Engineering" +} + +#+END_SRC + + * Design diagram :PROPERTIES: :CUSTOM_ID: design_diagram @@ -1047,7 +1065,7 @@ Not yet implemented

lab data service design diagram

#+END_HTML - To edit the feedback relations image [[https://docs.google.com/drawings/d/1TAaHpf0UiCLvLRP_XfBBQki7pU624oWXRduxyz6e1NA/edit?ts=58415ec0][click here]] + To edit the lds relations image [[https://docs.google.com/drawings/d/1TAaHpf0UiCLvLRP_XfBBQki7pU624oWXRduxyz6e1NA/edit?ts=58415ec0][click here]] ** Process *** Get the lab's meta data :PROPERTIES: diff --git a/src/plan-for-april.org b/src/plan-for-april.org index eb1ad22..606a393 100644 --- a/src/plan-for-april.org +++ b/src/plan-for-april.org @@ -53,7 +53,7 @@ |------+--------------------------+-----------------+-----------------+---------------+-------------+-----------------------------| | 5. | Implementation Review | [[https://github.com/vlead/lab-data-service/issues/12][#12]] | 3 Days | 2 Days | Done | Thirumal, Sripathi, Madhavi | |------+--------------------------+-----------------+-----------------+---------------+-------------+-----------------------------| -| 6. | Testing and Deployment | [[https://github.com/vlead/lab-data-service/issues/20][#20]] | 3 Days | In Progress | In Progress | Madhavi | +| 6. | Testing and Deployment | [[https://github.com/vlead/lab-data-service/issues/20][#20]] | 3 Days | 2.5 Days | Done | Madhavi | |------+--------------------------+-----------------+-----------------+---------------+-------------+-----------------------------| * Implementation includes end to end implementation across all layers, CRUD @@ -95,27 +95,32 @@ :PROPERTIES: :CUSTOM_ID: plan :END: -|------+--------------------------+---------------+-----------------+---------------+-------------+--------------------| -| S.NO | Tasks | Github Issues | Expected Effort | Actual Effort | Status | Assignee | -|------+--------------------------+---------------+-----------------+---------------+-------------+--------------------| -| 1. | Requirements Gathering | [[https://github.com/vlead/lab-data-service/issues/1][#1]] | 1 Day | 1 Day | Done | Madhavi,Sanchita | -|------+--------------------------+---------------+-----------------+---------------+-------------+--------------------| -| 2. | Data Model Design | [[https://github.com/vlead/lab-data-service/issues/3][#3]] | 1 Day | In Progress | In progress | Mrudhvika,Sanchita | -|------+--------------------------+---------------+-----------------+---------------+-------------+--------------------| -| 3. | Implementation | | 1 Week | In Progress | In Progress | Development Team | -| | 3.1. Discipline | [[https://github.com/vlead/lab-data-service/issues/19][#19]] | 2 Days | In Progress | In Progress | Sanchita | -| | 3.2. Developer | [[https://github.com/vlead/lab-data-service/issues/16][#16]] | 2 Days | In Progress | In Progress | Reena | -| | 3.3. Institute | [[https://github.com/vlead/lab-data-service/issues/18][#18]] | 2 Days | In Progress | In Progress | Sanchita | -| | 3.4. Asset | [[https://github.com/vlead/lab-data-service/issues/15][#15]] | 2 Days | In Progress | In Progress | Mrudhvika | -| | 3.5. Hosting Information | [[https://github.com/vlead/lab-data-service/issues/17][#17]] | 2 Days | In Progress | In Progress | Reena | -| | 3.6. Integration Status | [[https://github.com/vlead/lab-data-service/issues/14][#14]] | 2 Days | In Progress | In Progress | Mrudhvika | -|------+--------------------------+---------------+-----------------+---------------+-------------+--------------------| -| 4. | Data Model Review | [[https://github.com/vlead/lab-data-service/issues/12][#12]] | 0.5 Day | Not started | Not started | Madhavi | -|------+--------------------------+---------------+-----------------+---------------+-------------+--------------------| -| 5. | Implementation Review | [[https://github.com/vlead/lab-data-service/issues/12][#12]] | 2 Days | Not Started | Not started | Madhavi | -|------+--------------------------+---------------+-----------------+---------------+-------------+--------------------| -| 6. | Testing and Deployment | [[https://github.com/vlead/lab-data-service/issues/20][#20]] | 3 Days | Not Started | Not Started | Madhavi | -|------+--------------------------+---------------+-----------------+---------------+-------------+--------------------| +|------+------------------------------+-------------------------+-----------------+---------------+-------------+--------------------| +| S.NO | Tasks | Github Issues | Expected Effort | Actual Effort | Status | Assignee | +|------+------------------------------+-------------------------+-----------------+---------------+-------------+--------------------| +| 1. | Requirements Gathering | [[https://github.com/vlead/lab-data-service/issues/1][#1]] | 1 Day | 1 Day | Done | Madhavi,Sanchita | +|------+------------------------------+-------------------------+-----------------+---------------+-------------+--------------------| +| 2. | Data Model Design | [[https://github.com/vlead/lab-data-service/issues/3][#3]] | 1 Day | 1 Day | Done | Mrudhvika,Sanchita | +|------+------------------------------+-------------------------+-----------------+---------------+-------------+--------------------| +| 3. | API Design | [[https://github.com/vlead/lab-data-service/issues/13][#13]] | In Progress | In Progress | In Progress | Development Team | +|------+------------------------------+-------------------------+-----------------+---------------+-------------+--------------------| +| 4. | Implementation | | 2 Weeks | In Progress | In Progress | Development Team | +| | 3.1. Lab | [[https://github.com/vlead/lab-data-service/issues/21][#21]] [[https://github.com/vlead/lab-data-service/issues/34][#34]] [[https://github.com/vlead/lab-data-service/issues/35][#35]] [[https://github.com/vlead/lab-data-service/issues/36][#36]] [[https://github.com/vlead/lab-data-service/issues/40][#40]] [[https://github.com/vlead/lab-data-service/issues/46][#46]] | 5 Days | Done | Done | Madhavi, Reena | +| | 3.2. Experiment | [[https://github.com/vlead/lab-data-service/issues/37][#37]] [[https://github.com/vlead/lab-data-service/issues/38][#38]] [[https://github.com/vlead/lab-data-service/issues/15][#39]] [[https://github.com/vlead/lab-data-service/issues/41][#41]] [[https://github.com/vlead/lab-data-service/issues/46][#46]] | 5 Days | Done | Done | Mrudhvika | +| | 3.3. Institute | [[https://github.com/vlead/lab-data-service/issues/18][#18]] [[https://github.com/vlead/lab-data-service/issues/42][#42]] | 5 Days | In Progress | In Progress | Sanchita | +| | 3.4. Asset | [[https://github.com/vlead/lab-data-service/issues/15][#15]] [[https://github.com/vlead/lab-data-service/issues/22][#22]] [[https://github.com/vlead/lab-data-service/issues/27][#27]] [[https://github.com/vlead/lab-data-service/issues/28][#28]] | 4 Days | Done | 4 Days | Sanchita | +| | 3.5. Hosting Information | [[https://github.com/vlead/lab-data-service/issues/17][#17]] [[https://github.com/vlead/lab-data-service/issues/33][#33]] | 3 Days | Done | 2 Days | Reena, Mrudhvika | +| | 3.6. Integration Status | [[https://github.com/vlead/lab-data-service/issues/14][#14]] [[https://github.com/vlead/lab-data-service/issues/33][#33]] | 3 Days | Done | 2 Days | Mrudhvika | +| | 3.7. Discipline | [[https://github.com/vlead/lab-data-service/issues/19][#19]] [[https://github.com/vlead/lab-data-service/issues/43][#43]] | 3 Days | In Progress | In Progress | Sanchita | +| | 3.8. Developer | [[https://github.com/vlead/lab-data-service/issues/16][#16]] [[https://github.com/vlead/lab-data-service/issues/25][#25]] [[https://github.com/vlead/lab-data-service/issues/26][#26]] [[https://github.com/vlead/lab-data-service/issues/44][#44]] | 4 Days | In Progress | In Progress | Reena | +| | 3.9. LDS Database Population | [[https://github.com/vlead/lab-data-service/issues/31][#31]] | 3 Days | In Progress | In Progress | Madhavi | +|------+------------------------------+-------------------------+-----------------+---------------+-------------+--------------------| +| 5. | Data Model Review | [[https://github.com/vlead/lab-data-service/issues/12][#12]] | 1 Day | In Progress | In Progress | Madhavi | +|------+------------------------------+-------------------------+-----------------+---------------+-------------+--------------------| +| 6. | Implementation Review | [[https://github.com/vlead/lab-data-service/issues/12][#12]] | 4 Days | In Progress | In Progress | Madhavi | +|------+------------------------------+-------------------------+-----------------+---------------+-------------+--------------------| +| 7. | Testing and Deployment | [[https://github.com/vlead/lab-data-service/issues/20][#20]] [[https://github.com/vlead/lab-data-service/issues/29][#29]] [[https://github.com/vlead/lab-data-service/issues/32][#32]] | 5 Days | In Progress | In Progress | Madhavi, Mrudhvika | +|------+------------------------------+-------------------------+-----------------+---------------+-------------+--------------------| * Implementation includes end to end implementation across all layers, CRUD operations (Objects,persistence,system,REST), unit test cases, integration diff --git a/src/release-notes/Feedback-Portal.org b/src/release-notes/Feedback-Portal.org deleted file mode 100644 index 4bb9775..0000000 --- a/src/release-notes/Feedback-Portal.org +++ /dev/null @@ -1,18 +0,0 @@ -#+TITLE: Feedback Portal Version V2.0.0 -#+AUTHOR: VLEAD -#+DATE: [2016-10-19 Wed] - -* Introduction - This document will describes the release notes of =Feedback Portal= - version =v2.0.0=. -* Features - + Ability to serve different feedback for different scenarios. - - Users can give generic, lab level and experiment level feedback - + Flexibility to Add/Remove different type of questions (Radio, Checkbox, Text, TextArea). - + Ease of version tracking for all feedback questions/forms - + Has RESTfull API for following scenarios - - To get the feedback form data in json format basing on given version. - - To get the total count of online submitted feedback. - - To get the total dump of submitted feedback in json format -* Github issues - Ressolved hIssues : [[https://github.com/vlead/feedback-portal/issues/18][18]], [[https://github.com/vlead/feedback-portal/issues/16][16]], [[https://github.com/vlead/feedback-portal/issues/14][14]] diff --git a/src/requirements/index.org b/src/requirements/index.org index c0cb546..b0e74b6 100755 --- a/src/requirements/index.org +++ b/src/requirements/index.org @@ -60,3 +60,19 @@ :END: - Able to provide the Lab Integration status. +** Req9 + :PROPERTIES: + :CUSTOM_ID: req9 + :END: + - LDS should generate National Digital Library specification. Issue [[https://github.com/vlead/lab-data-service/issues/45][#45]] +** Req10 + :PROPERTIES: + :CUSTOM_ID: req10 + :END: + - Add 'keywords' Attribute in lab and experiment entities. Issue [[https://github.com/vlead/lab-data-service/issues/46][#46]] +** Req11 + :PROPERTIES: + :CUSTOM_ID: req11 + :END: + - LDS need to capture the metadata for google crawling. Issue [[https://github.com/vlead/lab-data-service/issues/47][#47]] + diff --git a/src/runtime/config/config.org b/src/runtime/config/config.org index bf88fe6..aef47ab 100755 --- a/src/runtime/config/config.org +++ b/src/runtime/config/config.org @@ -11,111 +11,6 @@ This holds the application's configuration parameters. -* Feedback Forms - The feedback service can work with multiple feedback forms. The set of - questions and meta data about questions like type of a question - whether it - is a =textbox= or a =radiobutton= or a =checkbox= along with the options that - a user can select for each question are captured as key value pairs. This - information is rendered on the client dynamically when a feedback form is - requested. -#+NAME: feedback_forms -#+BEGIN_SRC python - - - -feedback_forms = [ - {'version': 'open-edx-virtual-labs-v2.0_for_experiment', - 'questions': [ - {'id' : '1', 'name': 'Designation', 'type': 'radio', - 'options': ["Student", "Instructor", "Others"],'driver' : [], 'mandatory' : 'Yes'}, - {'id' : '2', 'name':'Did you attempt the experiment?', 'type':'radio', - 'options':['Yes', 'No'], 'driver' : [3,4,7], 'mandatory' : 'Yes'}, - {'id' : '3','name':'Did the experiment work?', 'type':'radio', - 'options': ['Yes', 'No', 'Not applicable'],'mandatory' : 'Yes'}, - {'id' : '4','name': 'Did you find any bugs in the experiment?', 'type': 'radio', - 'options': ["Yes", "No", "Not applicable"],'linked_answer' : 'Yes', 'mandatory' : 'Yes'}, - {'id' : '5','name': 'How much did you know about the experiment before doing it in Virtual Labs?', 'type': 'radio', - 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],'mandatory' : 'Yes'}, - {'id' : '6','name': 'Is this experiment part of your curriculum?', 'type': 'radio', - 'options': ["Yes", "No", "Don't know", "Not applicable"],'mandatory' : 'Yes'}, - {'id' : '7','name': 'Did this experiment help you understand the concept better?', 'type': 'radio', - 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Not applicable"],'mandatory' : 'Yes'}, - {'id' : '8','name': 'Will you recommend this experiment to others?', 'type': 'radio', - 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],'mandatory' : 'Yes'}, - {'id' : '9', 'name': 'Please provide any other feedback about this experiment', 'type': 'textarea', - 'options': ["Yes"],'mandatory' : 'No'} - ]}, - {'version': 'open-edx-virtual-labs-v2.0_for_lab', - 'questions': [ - {'id' : '1', 'name': 'Designation', 'type': 'radio', - 'options': ["Student", "Instructor", "Others"],'driver' : [], 'mandatory' : 'Yes'}, - {'id' : '2', 'name': 'How much did you know about the lab?', 'type': 'radio', - 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],'driver' : [], 'mandatory' : 'Yes'}, - {'id' : '3', 'name': 'Is this lab part of your curriculum?', 'type': 'radio', - 'options': ["Yes", "No", "Don't know", "Not applicable"],'mandatory' : 'Yes'}, - {'id' : '4','name': "Did you find any bugs in the lab?", 'type': 'radio', 'linked_answer' : 'Yes', 'options': ["Yes", "No"],'mandatory' : 'Yes'}, - {'id' : '5','name': 'Did this lab help you understand the concept better?', 'type': 'radio', - 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],'linked_answer' : 'No','mandatory' : 'Yes'}, - {'id' : '6','name': 'Will you recommend this lab to others?', 'type': 'radio', - 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],'mandatory' : 'Yes'}, - {'id' : '7','name': 'Please provide any other feedback about this lab', 'type': 'textarea', - 'options': ["Yes"],'mandatory' : 'No'} -]}, - - {'version': 'generic-feedback-v2.0', - 'questions': [ - {'id' : '1', 'name': 'Designation', 'type': 'radio', - 'options': ["Student", "Instructor", "Others"],'driver' : [], 'mandatory' : 'Yes'}, - {'id' : '2', 'name': 'Did you attempt any experiments ?', 'driver' : [], 'type': 'radio', - 'options': ["Yes", "No"],'mandatory' : 'Yes'}, - {'id' : '3','name': "Please rate your experience", 'type': 'radio', 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],'mandatory' : 'Yes'}, - {'id' : '4','name': 'Please provide any other feedback about Virtual Labs', 'type': 'textarea', - 'options': ["Yes"],'linked_answer' : 'No','mandatory' : 'No'}, - ]}, - - {'version': 'generic-exp-feedback-v2.0', - 'questions': [ - {'id' : '1', 'name': 'Designation', 'type': 'radio', - 'options': ["Student", "Instructor", "Others"],'driver' : [], 'mandatory' : 'Yes'}, - {'id' : '2', 'name':'Did you attempt the experiment?', 'type':'radio', - 'options':['Yes', 'No'], 'driver' : [3,4,7], 'mandatory' : 'Yes'}, - {'id' : '3','name':'Did the experiment work?', 'type':'radio', - 'options': ['Yes', 'No', 'Not applicable'],'mandatory' : 'Yes'}, - {'id' : '4','name': 'Did you find any bugs in the experiment?', 'type': 'radio', - 'options': ["Yes", "No", "Not applicable"],'linked_answer' : 'Yes', 'mandatory' : 'Yes'}, - {'id' : '5','name': 'How much did you know about the experiment before doing it in Virtual Labs?', 'type': 'radio', - 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],'mandatory' : 'Yes'}, - {'id' : '6','name': 'Is this experiment part of your curriculum?', 'type': 'radio', - 'options': ["Yes", "No", "Don't know", "Not applicable"],'mandatory' : 'Yes'}, - {'id' : '7','name': 'Did this experiment help you understand the concept better?', 'type': 'radio', - 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Not applicable"],'mandatory' : 'Yes'}, - {'id' : '8','name': 'Will you recommend this experiment to others?', 'type': 'radio', - 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],'mandatory' : 'Yes'}, - {'id' : '9', 'name': 'Please provide any other feedback about this experiment', 'type': 'textarea', - 'options': ["Yes"],'mandatory' : 'No'} - ]}, - {'version': 'generic-lab-feedback-v2.0', - 'questions': [ - {'id' : '1', 'name': 'Designation', 'type': 'radio', - 'options': ["Student", "Instructor", "Others"],'driver' : [], 'mandatory' : 'Yes'}, - {'id' : '2', 'name': 'How much did you know about the lab?', 'type': 'radio', - 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],'driver' : [], 'mandatory' : 'Yes'}, - {'id' : '3', 'name': 'Is this lab part of your curriculum?', 'type': 'radio', - 'options': ["Yes", "No", "Don't know", "Not applicable"],'mandatory' : 'Yes'}, - {'id' : '4','name': "Did you find any bugs in the lab?", 'type': 'radio', 'linked_answer' : 'Yes', 'options': ["Yes", "No"],'mandatory' : 'Yes'}, - {'id' : '5','name': 'Did this lab help you understand the concept better?', 'type': 'radio', - 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],'linked_answer' : 'No','mandatory' : 'Yes'}, - {'id' : '6','name': 'Will you recommend this lab to others?', 'type': 'radio', - 'options': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],'mandatory' : 'Yes'}, - {'id' : '7','name': 'Please provide any other feedback about this lab', 'type': 'textarea', - 'options': ["Yes"],'mandatory' : 'No'} -]} - -] - -#+END_SRC - - * Flask Application Configuration Configuration for the flask application. #+NAME: flask_app_config @@ -141,7 +36,7 @@ WHITELIST_IPS = ["127.0.0.1"] # Configure your log paths LOG_FILE_DIRECTORY = 'logs' -LOG_FILE = 'feedback.log' +LOG_FILE = 'lds.log' # Log level for the application #10=DEBUG, 20=INFO, 30=WARNING, 40=ERROR, 50=CRITICAL", @@ -160,12 +55,6 @@ KEY="defaultkey" * Tangling :boilerplate: -** feedback_forms -#+BEGIN_SRC python :tangle feedback_forms.py :eval no :noweb yes -<> -#+end_src - - ** flask_app_config #+BEGIN_SRC python :tangle flask_app_config.py :eval no :noweb yes <> diff --git a/src/runtime/objects/entities.org b/src/runtime/objects/entities.org index 3c8df7a..bb83563 100755 --- a/src/runtime/objects/entities.org +++ b/src/runtime/objects/entities.org @@ -171,11 +171,11 @@ def are_disciplines(disciplies): return ret_val -is_hostinginfo = is_inst(HostingInfo) -check_hostinginfo = check_pred(is_hostinginfo) +is_hosting_info = is_inst(HostingInfo) +check_hosting_info = check_pred(is_hosting_info) -is_integrationstatus = is_inst(IntegrationStatus) -check_hostinginfo = check_pred(is_integrationstatus) +is_integration_status = is_inst(IntegrationStatus) +check_hosting_info = check_pred(is_integration_status) is_asset = is_inst(Asset) check_asset = check_pred(is_asset) @@ -191,6 +191,17 @@ def are_assets(assets): return ret_val +def are_hosting_info(hosting_info): + ret_val = True + if is_list(hosting_info): + for hosting_info in hosting_info: + if not is_hosting_info(hosting_info): + ret_val = False + else: + ret_val = False + + return ret_val + #+END_SRC @@ -204,10 +215,10 @@ Lab.add_attributes(lab_name=is_str, institute=is_institute, discipline=is_discipline, assets=are_assets, - integrationstatus=is_integrationstatus, + integration_status=is_integration_status, experiments=are_experiments, developers=are_developers, - hostinginfo=is_hostinginfo) + hosting_info=are_hosting_info) Lab.__eq__ = lambda self, other: \ isinstance(other, self.__class__) and \ @@ -217,10 +228,10 @@ Lab.__eq__ = lambda self, other: \ self.get("institute") == other.get("institute") and \ self.get("discipline") == other.get("discipline") and \ self.get("assets") == other.get("assets") and \ - self.get("integrationstatus") == other.get("integrationstatus") and \ + self.get("integration_status") == other.get("integration_status") and \ self.get("experiments") == other.get("experiments") and \ self.get("developers") == other.get("developers") and \ - self.get("hostinginfo") == other.get("hostinginfo") + self.get("hosting_info") == other.get("hosting_info") #+end_src @@ -235,32 +246,40 @@ class TestLab(TestCase): exp_id = "EE99777" overview = "This is array exp" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + inst_name = "IIIT Hyderabad" inst_id = "IIIT-H" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) - - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = Asset(asset_type=asset_type, path=path) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) + integration_status = IntegrationStatus(integration_level=\ + integration_level) dev_name = Name(name="Mohit Tahiliani") email_id = Email(email="mohit.tahiliani@gmail.com") - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, hosted_on=hosted_on) experiment = Experiment(exp_name=exp_name, exp_id=exp_id, \ - overview=overview, sections=[]) + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], developers=[dev], + hosting_info=[host]) lab_name = "Computer Programming" lab_id = "CSE01" @@ -268,22 +287,26 @@ class TestLab(TestCase): "and ques..etc" lab = Lab(lab_name=lab_name, lab_id=lab_id, overview=overview, institute=inst, discipline=discipline, assets=[asset], - integrationstatus=integrationstatus, developers=[dev], - hostinginfo=host, experiments=[experiment]) + integration_status=integration_status, developers=[dev], + hosting_info=[host], experiments=[experiment]) self.assertEqual(lab.get("lab_name"), lab_name) self.assertEqual(lab.get("lab_id"), lab_id) self.assertEqual(lab.get("overview"), overview) self.assertEqual(lab.get("institute").get("inst_name"), inst.get("inst_name")) + self.assertEqual(lab.get("discipline").get("dis_name"), + discipline.get("dis_name")) self.assertEqual(lab.get("assets")[0].get("asset_type"), asset.get("asset_type")) - self.assertEqual(lab.get("integrationstatus").get("integration_level"), - integrationstatus.get("integration_level")) + self.assertEqual(lab.get("integration_status").\ + get("integration_level"), integration_status.\ + get("integration_level")) self.assertEqual(lab.get("experiments")[0].get("exp_name"), experiment.get("exp_name")) - self.assertEqual(lab.get("developers")[0].get("email").get("email"), email_id.get("email")) - self.assertEqual(lab.get("hostinginfo").get("hosting_status"), + self.assertEqual(lab.get("developers")[0].get("email").get("email"), + email_id.get("email")) + self.assertEqual(lab.get("hosting_info")[0].get("hosting_status"), host.get("hosting_status")) #+END_SRC @@ -294,12 +317,14 @@ class TestLab(TestCase): #+NAME: class_Institute #+begin_src python Institute.add_attributes(inst_name=is_str, - inst_id=is_str) + inst_id=is_str, + assets=are_assets) Institute.__eq__ = lambda self, other: \ isinstance(other, self.__class__) and \ self.get("inst_name") == other.get("inst_name") and \ - self.get("inst_id") == other.get("inst_id") + self.get("inst_id") == other.get("inst_id") and \ + self.get("assets") == other.get("assets") #+end_src *** Test Institute @@ -309,12 +334,20 @@ class TestInstitute(TestCase): TESTING = True def test_object_institute(self): print "test_object_institute" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + inst_name = "IIIT Hyderabad" inst_id = "IIIT-H" - institute = Institute(inst_name=inst_name, inst_id=inst_id) + institute = Institute(inst_name=inst_name, inst_id=inst_id, + assets=[asset]) self.assertEqual(institute.get("inst_name"), inst_name) self.assertEqual(institute.get("inst_id"), inst_id) + self.assertEqual(institute.get("assets")[0].get("asset_type"), + asset.get("asset_type")) #+END_SRC @@ -323,14 +356,29 @@ class TestInstitute(TestCase): =Experiment= is an entity that has a field =exp_name= and =exp_id= which are string #+NAME: class_Experiment #+begin_src python -Experiment.add_attributes(exp_name=is_str, exp_id=is_str, overview=is_str, \ - sections=are_sections) +Experiment.add_attributes(exp_name=is_str, + exp_id=is_str, overview=is_str, \ + sections=are_sections, + discipline=is_discipline, + institute=is_institute, + integration_status=is_integration_status, + assets=are_assets, + developers=are_developers, + hosting_info=are_hosting_info) + Experiment.__eq__ = lambda self, other: \ isinstance(other, self.__class__) and \ self.get("exp_name") == other.get("exp_name") and \ self.get("exp_id") == other.get("exp_id") and \ - self.get("overview") == other.get("overview") and\ - self.get("sections") == other.get("sections") + self.get("overview") == other.get("overview") and \ + self.get("sections") == other.get("sections") and \ + self.get("discipline") == other.get("discipline") and \ + self.get("institute") == other.get("institute") and \ + self.get("integration_status") == other.\ + get("integration_status") and \ + self.get("assets") == other.get("assets") and \ + self.get("developers") == other.get("developers") and \ + self.get("hosting_info") == other.get("hosting_info") #+end_src @@ -342,15 +390,63 @@ class TestExperiment(TestCase): def test_object_experiment(self): print "test_object_experiment" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + + inst_name = "IIIT Hyderabad" + inst_id = "IIIT-H" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + exp_name = "Number Systems" exp_id = "EE99777" overview = "This is linked list experiment" - experiment = Experiment(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) + + integration_level = 4 + integration_status = IntegrationStatus(integration_level=\ + integration_level) + + dev_name = Name(name="Mohit Tahiliani") + email_id = Email(email="mohit.tahiliani@gmail.com") + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, hosted_on=hosted_on) + + experiment = Experiment(exp_name=exp_name, exp_id=exp_id, + institute=inst, discipline=discipline, + overview=overview, + integration_status=integration_status, + sections=[], assets=[asset], + developers=[dev], hosting_info=[host]) + self.assertEqual(experiment.get("exp_name"), exp_name) self.assertEqual(experiment.get("overview"), overview) + self.assertEqual(experiment.get("integration_status").\ + get("integration_level"), \ + integration_status.get("integration_level")) + self.assertEqual(experiment.get("assets")[0].get("asset_type"), + asset.get("asset_type")) self.assertEqual(experiment.get("exp_id"), exp_id) self.assertEqual(experiment.get("sections"), []) + self.assertEqual(experiment.get("institute").get("inst_name"), + inst.get("inst_name")) + self.assertEqual(experiment.get("discipline").get("dis_name"), + discipline.get("dis_name")) + self.assertEqual(experiment.get("developers")[0].get("email").\ + get("email"), email_id.get("email")) + self.assertEqual(experiment.get("hosting_info")[0].\ + get("hosting_status"), host.get("hosting_status")) #+END_SRC @@ -479,11 +575,15 @@ class TestEmail(TestCase): #+NAME: class_Discipline #+begin_src python -Discipline.add_attributes(dis_name=is_str, dis_id=is_str) +Discipline.add_attributes(dis_name=is_str, + dis_id=is_str, + assets=are_assets) Discipline.__eq__ = lambda self, other: \ isinstance(other, self.__class__) and \ self.get("dis_name") == other.get("dis_name") and \ - self.get("dis_id") == other.get("dis_id") + self.get("dis_id") == other.get("dis_id") and \ + self.get("assets") == other.get("assets") + #+end_src @@ -494,11 +594,20 @@ class TestDiscipline(TestCase): TESTING = True def test_object_discipline(self): print "test_object_discipline" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + dis_name = "IIT Delhi" dis_id = "ECE08" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + self.assertEqual(discipline.get("dis_name"), dis_name) self.assertEqual(discipline.get("dis_id"), dis_id) + self.assertEqual(discipline.get("assets")[0].get("asset_type"), + asset.get("asset_type")) #+END_SRC @@ -508,12 +617,17 @@ class TestDiscipline(TestCase): #+NAME: class_Developer #+begin_src python -Developer.add_attributes(name=is_name, email=is_email) +Developer.add_attributes(name=is_name, + email=is_email, + discipline=is_discipline, + institute=is_institute) Developer.__eq__ = lambda self, other: \ isinstance(other, self.__class__) and \ self.get("name") == other.get("name") and\ - self.get("email") == other.get("email") + self.get("email") == other.get("email") and \ + self.get("discipline") == other.get("discipline") and \ + self.get("institute") == other.get("institute") #+end_src *** Test Developer @@ -523,11 +637,33 @@ class TestDev(TestCase): TESTING = True def test_object_dev(self): print "test_object_dev" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + + inst_name = "IIIT Hyderabad" + inst_id = "IIIT-H" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + dev_name = Name(name="Mohit Tahiliani") email_id = Email(email="mohit.tahiliani@gmail.com") - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + self.assertEqual(dev.get("name").get("name"), dev_name.get("name")) self.assertEqual(dev.get("email").get("email"), email_id.get("email")) + self.assertEqual(dev.get("institute").get("inst_name"), + inst.get("inst_name")) + self.assertEqual(dev.get("discipline").get("dis_name"), + discipline.get("dis_name")) + + #+END_SRC @@ -541,7 +677,8 @@ Asset.add_attributes(path=is_str, Asset.__eq__ = lambda self, other: \ isinstance(other, self.__class__) and \ self.get("path") == other.get("path") and \ - self.get("asset_type") == other.get("asset_type") + self.get("asset_type") == other.get("asset_type") + #+end_src *** Test Asset @@ -551,12 +688,15 @@ class TestAsset(TestCase): TESTING = True def test_object_asset(self): print "test_object_asset" + path = "vlabs.ac.in/static/images/logo.png" asset_type = "Image" + asset = Asset(path=path, asset_type=asset_type) self.assertEqual(asset.get("path"), path) self.assertEqual(asset.get("asset_type"), asset_type) + #+end_src @@ -570,7 +710,8 @@ HostingInfo.add_attributes(hosting_status=is_str, HostingInfo.__eq__ = lambda self, other: \ isinstance(other, self.__class__) and \ - self.get("hosting_status") == other.get("hosting_status") and \ + self.get("hosting_status") ==\ + other.get("hosting_status") and \ self.get("hosted_url") == other.get("hosted_url") and \ self.get("hosted_on") == other.get("hosted_on") #+end_src @@ -580,16 +721,18 @@ HostingInfo.__eq__ = lambda self, other: \ #+BEGIN_SRC python class TestHostingInfo(TestCase): TESTING = True - def test_object_hostinginfo(self): - print "test_object_hostinginfo" + def test_object_hosting_info(self): + print "test_object_hosting_info" hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - hostinginfo = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + hosting_info = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) - self.assertEqual(hostinginfo.get("hosting_status"), hosting_status) - self.assertEqual(hostinginfo.get("hosted_url"), hosted_url) - self.assertEqual(hostinginfo.get("hosted_on"), hosted_on) + self.assertEqual(hosting_info.get("hosting_status"), hosting_status) + self.assertEqual(hosting_info.get("hosted_url"), hosted_url) + self.assertEqual(hosting_info.get("hosted_on"), hosted_on) #+END_SRC @@ -603,7 +746,8 @@ IntegrationStatus.add_attributes(integration_level=is_int) IntegrationStatus.__eq__ = lambda self, other: \ isinstance(other, self.__class__) and \ - self.get("integration_level") == other.get("integration_level") + self.get("integration_level") == other.\ + get("integration_level") #+end_src *** Test IntegrationStatus @@ -612,12 +756,12 @@ IntegrationStatus.__eq__ = lambda self, other: \ class TestIntegrationStatus(TestCase): TESTING = True - def test_object_integrationstatus(self): - print "test_object_integrationstatus" + def test_object_integration_status(self): + print "test_object_integration_status" integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) + integration_status = IntegrationStatus(integration_level=integration_level) - self.assertEqual(integrationstatus.get("integration_level"), integration_level) + self.assertEqual(integration_status.get("integration_level"), integration_level) #+END_SRC diff --git a/src/runtime/persistence/entities.org b/src/runtime/persistence/entities.org index 29bc5bd..7ee6d17 100755 --- a/src/runtime/persistence/entities.org +++ b/src/runtime/persistence/entities.org @@ -34,6 +34,12 @@ lab_developers = db.Table('lab_developers', db.Column('developer_id', db.Integer, db.ForeignKey('developer.id'))) +lab_hosting_info = db.Table('lab_hosting_info', + db.Column('labid', db.Integer, + db.ForeignKey('lab.id')), + db.Column('hosting_infoid', db.Integer, + db.ForeignKey('hosting_info.id'))) + #+END_SRC #+NAME: class_Lab @@ -53,24 +59,27 @@ args = {"__tablename__": "lab", "discipline_id": db.Column(db.Integer, db.ForeignKey('discipline.id'), unique=False, nullable=False), - "integrationstatus_id": db.Column(db.Integer, db.ForeignKey('integrationstatus.id'), - unique=False, nullable=False), + "integration_status_id": db.Column(db.Integer, + db.ForeignKey\ + ('integration_status.id'), + unique=False, nullable=False), "assets": db.relationship('Asset', secondary=lab_assets, backref='labs'), "developers": db.relationship('Developer', secondary=lab_developers, backref='labs'), - "hostinginfo_id": db.Column(db.Integer, db.ForeignKey('hostinginfo.id'), - unique=False, nullable=False) - } + "hosting_info": db.relationship('HostingInfo', + secondary=lab_hosting_info, + backref='labs') + } Lab = ClassPersistenceTemplate.mk_persistent(Lab, ['lab_id'],\ - **args) + ,**args) #+end_src -*** Test Lab +** Test Lab #+NAME: class_TestLab #+BEGIN_SRC python class TestPersistentLab(TestCase): @@ -90,54 +99,65 @@ class TestPersistentLab(TestCase): def test_create_lab(self): print "test_persistent_lab" - exp_name = "Number Systems" - exp_id = "EE99777" - overview = "This is linked list experiment" - experiment = Experiment(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) - experiment.save() + asset_type = "Image" + path = "vlabs.ac.in/images/static/icon.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) discipline.save() integration_level = 4 intstatus = IntegrationStatus(integration_level=integration_level) intstatus.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/icon.png" - asset = Asset(asset_type=asset_type, path=path) - asset.save() + exp_name = "Number Systems" + exp_id = "EE99777" + overview = "This is linked list experiment" dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, hosted_on=hosted_on) host.save() + exp_name = "Number Systems" + exp_id = "EE99777" + overview = "This is linked list experiment" + experiment = Experiment(exp_name=exp_name, exp_id=exp_id, + overview=overview, sections=[], + integration_status=intstatus, + hosting_info=[host], assets=[asset], + institute=inst, discipline=discipline, + developers=[dev]) + experiment.save() + lab_name1="Computer Programming" lab_id1="CSE01" overview1 = "This is data structures lab which deals about array,stack" " and ques..etc" lab1 = Lab(lab_name=lab_name1, lab_id=lab_id1, overview=overview1, experiments=[experiment], institute=inst, - integrationstatus=intstatus, + integration_status=intstatus, assets=[asset], discipline=discipline, - developers=[dev], hostinginfo=host) + developers=[dev], hosting_info=[host]) lab1.save() lab_name2="Data Structures" @@ -147,8 +167,8 @@ class TestPersistentLab(TestCase): lab2 = Lab(lab_name=lab_name2, lab_id=lab_id2, overview=overview2, experiments=[], institute=inst, discipline=discipline, - developers=[], hostinginfo=host, assets=[asset], - integrationstatus=intstatus) + developers=[], hosting_info=[host], assets=[asset], + integration_status=intstatus) lab2.save() lab1 = Lab.get_by_id(1) @@ -166,13 +186,14 @@ class TestPersistentLab(TestCase): asset.get("asset_type")) self.assertEqual(lab1.get("experiments")[0].get("exp_name"), experiment.get("exp_name")) - self.assertEqual(lab1.get("integrationstatus").get("integration_level"), + self.assertEqual(lab1.get("integration_status").\ + get("integration_level"), intstatus.get("integration_level")) self.assertEqual(lab1.get("developers")[0].get("email").get("email"), email_id.get("email")) - self.assertEqual(lab1.get("hostinginfo").get("hosting_status"), + self.assertEqual(lab1.get("hosting_info")[0].get("hosting_status"), host.get("hosting_status")) self.assertEqual(lab2.get("lab_name"), lab_name2) @@ -182,13 +203,14 @@ class TestPersistentLab(TestCase): inst.get("inst_name")) self.assertEqual(lab2.get("discipline").get("dis_name"), discipline.get("dis_name")) - self.assertEqual(lab2.get("hostinginfo").get("hosting_status"), + self.assertEqual(lab2.get("hosting_info")[0].get("hosting_status"), host.get("hosting_status")) self.assertEqual(lab2.get("experiments"), []) self.assertEqual(lab2.get("assets")[0].get("asset_type"), asset.get("asset_type")) - self.assertEqual(lab2.get("integrationstatus").get("integration_level"), + self.assertEqual(lab2.get("integration_status").\ + get("integration_level"), intstatus.get("integration_level")) self.assertEqual(lab2.get("developers"), []) @@ -209,6 +231,24 @@ experiments_sections = db.Table('experiments_sections', db.Column('section_id', db.Integer, db.ForeignKey('section.id'))) +experiments_assets = db.Table('experiments_assets', + db.Column('experimentid', db.Integer, + db.ForeignKey('experiment.id')), + db.Column('assetid', db.Integer, + db.ForeignKey('asset.id'))) + +experiments_developers = db.Table('experiments_developers', + db.Column('experiment_id', db.Integer, + db.ForeignKey('experiment.id')), + db.Column('developer_id', db.Integer, + db.ForeignKey('developer.id'))) + +experiments_hosting_info = db.Table('experiments_hosting_info', + db.Column('experimentid', db.Integer, + db.ForeignKey('experiment.id')), + db.Column('hosting_infoid', db.Integer, + db.ForeignKey('hosting_info.id'))) + #+END_SRC #+NAME: class_Experiment @@ -218,17 +258,35 @@ args = {"__tablename__": "experiment", "exp_name": db.Column(db.String(255), unique=False, nullable=True), "exp_id": db.Column(db.String(255), unique=True, nullable=False), "overview": db.Column(db.String(1000), unique=False, nullable=True), + "intstatus_id": db.Column(db.Integer, db.ForeignKey\ + ('integration_status.id'), + unique=False, nullable=False), + "assets": db.relationship('Asset', + secondary=experiments_assets, + backref='experiments'), "lb_id": db.Column(db.Integer, db.ForeignKey('lab.id'), unique=False), "sections": db.relationship('Section', secondary=experiments_sections, - backref='experiments') + backref='experiments'), + "institute_id": db.Column(db.Integer, db.ForeignKey('institute.id'), + unique=False, nullable=False), + "discipline_id": db.Column(db.Integer, db.ForeignKey('discipline.id'), + unique=False, nullable=False), + + "developers": db.relationship('Developer', + secondary=experiments_developers, + backref='experiments'), + "hosting_info": db.relationship('HostingInfo', + secondary=experiments_hosting_info, + backref='experiments') } -Experiment = ClassPersistenceTemplate.mk_persistent(Experiment, ['exp_id'], **args) +Experiment = ClassPersistenceTemplate.mk_persistent(Experiment, ['exp_id'], + ,**args) #+end_src @@ -251,17 +309,72 @@ class TestPersistenceExperiment(TestCase): def test_create_experiment(self): print "test_persistance_experiment" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/icon.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + + dev_name = Name(name="Mohit Tahiliani") + dev_name.save() + email_id = Email(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, hosted_on=hosted_on) + host.save() + exp_name = "Number Systems" exp_id = "EE99777" overview = "This is linked list experiment" - exp = Experiment(exp_name=exp_name, exp_id=exp_id, overview=overview, sections=[]) + + integration_level = 4 + intstatus = IntegrationStatus(integration_level=integration_level) + intstatus.save() + + exp = Experiment(exp_name=exp_name, exp_id=exp_id, overview=overview, + integration_status=intstatus, assets=[asset], + sections=[], developers=[dev], hosting_info=[host], + institute=inst, discipline=discipline) exp.save() + experiment = Experiment.get_by_id(1) experiment1 = Experiment.get_by_id(2) self.assertEqual(experiment.get("exp_name"), exp_name) self.assertEqual(experiment.get("exp_id"), exp_id) self.assertEqual(experiment.get("overview"), overview) + self.assertEqual(experiment.get("institute").get("inst_name"), + inst.get("inst_name")) + self.assertEqual(experiment.get("discipline").get("dis_name"), + discipline.get("dis_name")) + self.assertEqual(experiment.get("integration_status").\ + get("integration_level"), + intstatus.get("integration_level")) + self.assertEqual(experiment.get("assets")[0].get("asset_type"), + asset.get("asset_type")) self.assertEqual(experiment1,None) + self.assertEqual(experiment.get("developers")[0].get("email").\ + get("email"), email_id.get("email")) + self.assertEqual(experiment.get("hosting_info")[0].\ + get("hosting_status"), + host.get("hosting_status")) #+END_SRC @@ -278,6 +391,12 @@ institutes_labs = db.Table('institutes_labs', db.Column('lab_id', db.Integer, db.ForeignKey('lab.id'))) +institutes_assets = db.Table('institutes_assets', + db.Column('institute_id', db.Integer, + db.ForeignKey('institute.id')), + db.Column('assetid', db.Integer, + db.ForeignKey('asset.id'))) + #+END_SRC #+NAME: class_Institute #+begin_src python @@ -285,10 +404,17 @@ args = {"__tablename__": "institute", "id": db.Column(db.Integer, primary_key=True), "inst_name": db.Column(db.String(255), unique=False, nullable=True), "inst_id": db.Column(db.String(255), unique=True, nullable=False), - "labs": db.relationship('Lab', backref=db.backref('institute')) + "labs": db.relationship('Lab', backref=db.backref('institute')), + "experiments": db.relationship('Experiment', backref=\ + db.backref('institute')), + "assets": db.relationship('Asset', secondary=institutes_assets, + backref='institutes'), + "developers": db.relationship('Developer', backref=\ + db.backref('institute')) } -Institute = ClassPersistenceTemplate.mk_persistent(Institute, ['inst_id'], **args) +Institute = ClassPersistenceTemplate.mk_persistent(Institute, ['inst_id'],\ + ,**args) #+end_src @@ -311,31 +437,58 @@ class TestPersistenceInstitute(TestCase): def test_create_institute(self): print "test_persistance_institute" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() institute = Institute.get_by_id(1) institute1 = Institute.get_by_id(2) self.assertEqual(institute.get("inst_name"), inst_name) - self.assertEqual(institute.get("inst_id"), inst_id) + self.assertEqual(institute.get("inst_id"), inst_id) + self.assertEqual(institute.get("assets")[0].get("asset_type"), + asset.get("asset_type")) self.assertEqual(institute1,None) #+END_SRC * Discipline - =Discipline= is a class with attributes =dis_name= and =dis_id= of type =is_email_str=. + =Discipline= is a class with attributes =dis_name= and =dis_id= of type + =is_email_str=. + +#+NAME: class_asset_association_Table +#+BEGIN_SRC python +disciplines_assets = db.Table('disciplines_assets', + db.Column('discipline_id', db.Integer, + db.ForeignKey('discipline.id')), + db.Column('assetid', db.Integer, + db.ForeignKey('asset.id'))) + +#+end_src + #+NAME: class_Discipline #+begin_src python args = {"__tablename__": "discipline", "id": db.Column(db.Integer, primary_key=True), "dis_name": db.Column(db.String(255), unique=False, nullable=True), "dis_id": db.Column(db.String(255), unique=True, nullable=False), - "labs": db.relationship('Lab', backref=db.backref('discipline')) + "labs": db.relationship('Lab', backref=db.backref('discipline')), + "experiments": db.relationship('Experiment', backref=\ + db.backref('discipline')), + "assets": db.relationship('Asset', secondary=disciplines_assets, + backref='disciplines'), + "developers": db.relationship('Developer', backref=\ + db.backref('discipline')) } -Discipline = ClassPersistenceTemplate.mk_persistent(Discipline, ['dis_id'], **args) +Discipline = ClassPersistenceTemplate.mk_persistent(Discipline, ['dis_id'],\ + ,**args) #+end_src @@ -357,16 +510,24 @@ class TestPersistenceDiscipline(TestCase): db.session.remove() db.drop_all() - def test_create_discipline(self): print "test_persistance_discipline" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + dis_name = "IIT Delhi" dis_id = "ECE08" - dis = Discipline(dis_name=dis_name, dis_id=dis_id) + dis = Discipline(dis_name=dis_name, dis_id=dis_id, assets=[asset]) dis.save() + discipline = Discipline.get_by_id(1) self.assertEqual(discipline.get("dis_name"), dis_name) self.assertEqual(discipline.get("dis_id"), dis_id) + self.assertEqual(discipline.get("assets")[0].get("asset_type"), + asset.get("asset_type")) #+END_SRC @@ -476,7 +637,6 @@ args = {"__tablename__": "email", "email": db.Column(db.String(255), unique=True, nullable=False), "developers": db.relationship('Developer', backref=db.backref('email')) - } Email = ClassPersistenceTemplate.mk_persistent(Email, ['email'], **args) @@ -516,6 +676,22 @@ class TestPersistentEmail(TestCase): * Developer =Developer= is a class with an attribute =name= of type alphabetic string and =email= of alphabetic string. +#+NAME: class_exp_association_Table +#+BEGIN_SRC python +developers_institutes = db.Table('developers_institutes', + db.Column('developer_id', db.Integer, + db.ForeignKey('developer.id')), + db.Column('institute_id', db.Integer, + db.ForeignKey('institute.id'))) + +developers_disciplines = db.Table('developers_disciplines', + db.Column('developer_id', db.Integer, + db.ForeignKey('developer.id')), + db.Column('discipline_id', db.Integer, + db.ForeignKey('discipline.id'))) + +#+END_SRC + #+NAME: class_Developer #+begin_src python args = {"__tablename__": "developer", @@ -523,7 +699,11 @@ args = {"__tablename__": "developer", "name_id": db.Column(db.Integer, db.ForeignKey('name.id'), nullable=False), "email_id": db.Column(db.Integer,db.ForeignKey('email.id'), - unique=True, nullable=False) + unique=True, nullable=False), + "institute_id": db.Column(db.Integer, db.ForeignKey('institute.id'), + unique=False, nullable=False), + "discipline_id": db.Column(db.Integer, db.ForeignKey('discipline.id'), + unique=False, nullable=False) } Developer = ClassPersistenceTemplate.mk_persistent(Developer, [], **args) @@ -548,17 +728,39 @@ class TestPersistentDeveloper(TestCase): def test_create_dev(self): print "test_persistent_dev" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() dev = Developer.get_by_id(1) self.assertEqual(dev.get("name").get("name"), dev_name.get("name")) self.assertEqual(dev.get("email").get("email"), email_id.get("email")) + self.assertEqual(dev.get("institute").get("inst_name"), + inst.get("inst_name")) + self.assertEqual(dev.get("discipline").get("dis_name"), + discipline.get("dis_name")) #+END_SRC @@ -569,15 +771,17 @@ class TestPersistentDeveloper(TestCase): #+NAME: class_HostingInfo #+begin_src python -args = {"__tablename__": "hostinginfo", +args = {"__tablename__": "hosting_info", "id": db.Column(db.Integer, primary_key=True), - "hosting_status": db.Column(db.String(255), unique=False, nullable=True), + "hosting_status": db.Column(db.String(255), unique=False,\ + nullable=True), "hosted_url": db.Column(db.String(255), unique=True, nullable=False), "hosted_on": db.Column(db.String(255), unique=False, nullable=True), - "labs": db.relationship('Lab', backref=db.backref('hostinginfo')) } -HostingInfo = ClassPersistenceTemplate.mk_persistent(HostingInfo, ['hosted_url'], **args) +HostingInfo = ClassPersistenceTemplate.mk_persistent(HostingInfo,\ + ['hosted_url'],\ + ,**args) #+end_src @@ -598,19 +802,19 @@ class TestPersistenceHostingInfo(TestCase): db.session.remove() db.drop_all() - def test_create_hostinginfo(self): - print "test_persistent_hostinginfo" + def test_create_hosting_info(self): + print "test_persistent_hosting_info" hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) host.save() - hostinginfo = HostingInfo.get_by_id(1) - hostinginfo1 = HostingInfo.get_by_id(2) - self.assertEqual(hostinginfo.get("hosting_status"), hosting_status) - self.assertEqual(hostinginfo.get("hosted_url"), hosted_url) - self.assertEqual(hostinginfo.get("hosted_on"), hosted_on) - self.assertEqual(hostinginfo1,None) + hosting_info = HostingInfo.get_by_id(1) + hosting_info1 = HostingInfo.get_by_id(2) + self.assertEqual(hosting_info.get("hosting_status"), hosting_status) + self.assertEqual(hosting_info.get("hosted_url"), hosted_url) + self.assertEqual(hosting_info.get("hosted_on"), hosted_on) + self.assertEqual(hosting_info1,None) #+END_SRC @@ -622,9 +826,8 @@ class TestPersistenceHostingInfo(TestCase): #+begin_src python args = {"__tablename__": "asset", "id": db.Column(db.Integer, primary_key=True), - "asset_type": db.Column(db.String(255), unique=False, nullable=True), - "path": db.Column(db.String(255), unique=True, nullable=False), -# "labs": db.relationship('Lab', backref=db.backref('asset')) + "asset_type": db.Column(db.String(255), unique=False, nullable=True), + "path": db.Column(db.String(255), unique=True, nullable=False) } Asset = ClassPersistenceTemplate.mk_persistent(Asset, ['path'], **args) @@ -650,10 +853,12 @@ class TestPersistenceAsset(TestCase): def test_create_asset(self): print "test_persistance_asset" + path = "vlabs.ac.in/static/images/logo.png" asset_type = "Image" asset = Asset(path=path, asset_type=asset_type) asset.save() + asset = asset.get_by_id(1) asset1 = asset.get_by_id(2) self.assertEqual(asset.get("path"), path) @@ -669,11 +874,18 @@ class TestPersistenceAsset(TestCase): #+NAME: class_IntegrationStatus #+begin_src python -args = {"__tablename__": "integrationstatus", +args = {"__tablename__": "integration_status", "id": db.Column(db.Integer, primary_key=True), + "integration_level": db.Column(db.Integer, unique=True,\ + nullable=False), + "labs": db.relationship('Lab', backref=\ + db.backref('integration_status')), + "experiments": db.relationship('Experiment', backref=\ + db.backref('integration_status')), "integration_level": db.Column(db.Integer, unique=True, nullable=False), - "labs": db.relationship('Lab', backref=db.backref('integrationstatus')) + "labs": db.relationship('Lab', backref=\ + db.backref('integration_status')) } IntegrationStatus = ClassPersistenceTemplate.mk_persistent(IntegrationStatus, @@ -698,15 +910,16 @@ class TestPersistenceIntegrationStatus(TestCase): db.session.remove() db.drop_all() - def test_create_integrationstatus(self): - print "test_persistance_integrationstatus" + def test_create_integration_status(self): + print "test_persistance_integration_status" integration_level = 4 intstatus = IntegrationStatus(integration_level=integration_level) intstatus.save() - integrationstatus = IntegrationStatus.get_by_id(1) - integrationstatus1 = IntegrationStatus.get_by_id(2) - self.assertEqual(integrationstatus.get("integration_level"), integration_level) - self.assertEqual(integrationstatus1,None) + integration_status = IntegrationStatus.get_by_id(1) + integration_status1 = IntegrationStatus.get_by_id(2) + self.assertEqual(integration_status.get("integration_level"),\ + integration_level) + self.assertEqual(integration_status1,None) #+END_SRC @@ -759,6 +972,7 @@ if __name__ == '__main__': <> <> <> +<> <> <> <> diff --git a/src/runtime/rest/api.org b/src/runtime/rest/api.org index 1c0dcf5..7d0e59e 100755 --- a/src/runtime/rest/api.org +++ b/src/runtime/rest/api.org @@ -12,7 +12,8 @@ :END: This document illustrates building of the REST API. - + + * REST ** Get Labs, Get Lab, Get Labs by institute, lab_name, discipline and asset and Get labs by passing lab_name as keyword @@ -35,62 +36,210 @@ #+BEGIN_EXAMPLE [ - { - "discipline": { - "dis_id": "cse", - "id": 1, - "dis_name": "Computer Science" - }, - "asset": { - "path": "vlabs.ac.in/images/static/logo.png", - "id": 1, - "asset_type": "Images" - }, - "lab_id": "cse09", - "institute": { - "inst_name": "IIIT Hyderabad", - "id": 1, - "inst_id": "iiith" - }, - "integrationstatus": { - "integration_level": 4, - "key": "" - }, - "hostinginfo": { - "hosting_status": "hosted", - "id": 1, - "hosted_url": "http://cse14-iiith.vlabs.ac.in", - "hosted_on": "cloud" - }, - "overview": "overview", - "lab_name": "Data Structures", - "experiments": [ - { + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "lab_id": "cse03", + "assets": [ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + }, + { + "path": "vlabs.ac.in/images/static/image.png", + "asset_type": "image", + "id": 2 + } + ], + "hosting_info": [ + { + "hosting_status": "hosted", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosted_on": "cloud", + "id": 4 + }, + { + "hosting_status": "hosted", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosted_on": "server", + "id": 5 + } + ], + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, "overview": "overview", - "exp_name": "arrays", - "sections": [ - { - "name": "Procedure", - "id": 2 - }, - { - "name": "Theory", - "id": 1 - } + "lab_name": "Data Structures", + "experiments": [ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "hosting_info": [ + { + "hosting_status": "hosted", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosted_on": "cloud", + "id": 4 + }, + { + "hosting_status": "hosted", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosted_on": "server", + "id": 5 + } + ], + "assets": [ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + }, + { + "path": "vlabs.ac.in/images/static/image.png", + "asset_type": "image", + "id": 2 + } + ], + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "exp_name": "stack", + "overview": "overview", + "exp_id": "cse02", + "developers": [ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 3, + "name": { + "name": "Prof. Dharamaja", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + } + }, + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 4, + "name": { + "name": "Prof. Pallavi Pawar", + "id": 7 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + } + } + ], + "sections": [ + { + "name": "Procedure", + "id": 3 + }, + { + "name": "Theory", + "id": 2 + } + ], + "id": 3, + "integration_status": { + "integration_level": 4, + "id": 5 + } + } ], - "id": 1, - "exp_id": "exp9" - } - ], - "id": 1, - "developers": [ - { - "name": "Prof. Dharamaja", - "id": 1, - "email": "abc@gmail.com" - } - ] - } + "integration_status": { + "integration_level": 4, + "id": 5 + }, + "developers": [ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 3, + "name": { + "name": "Prof. Dharamaja", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + } + }, + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 4, + "name": { + "name": "Prof. Pallavi Pawar", + "id": 7 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + } + } + ], + "id": 1 + } ] #+END_EXAMPLE @@ -121,59 +270,208 @@ http://localhost:5000/labs #+BEGIN_EXAMPLE { - "assets": [ - { - "asset_type": "Image", - "id": 1, - "path": "vlabs.ac.in/images/static/logo.png" - } - ], - "developers": [ - { - "email": { - "email": "dharamrajuu@gmail.com", - "id": 3 - }, - "id": 3, - "name": { - "id": 3, - "name": "Prof. Dharamrajuu" - } - } - ], - "discipline": { - "dis_id": "cse", - "dis_name": "Computer Science", - "id": 1 - }, - "experiments": [ - { - "exp_id": "cse01", - "exp_name": "arrays", - "id": 1, - "overview": "overview", - "sections": [] - } - ], - "hostinginfo": { - "hosted_on": "cloud", - "hosted_url": "http://cse14-iiith.vlabs.ac.in", - "hosting_status": "hosted", - "id": 1 - }, - "id": 6, - "institute": { - "id": 1, - "inst_id": "iiith", - "inst_name": "IIIT Hyderabad" - }, - "integrationstatus": { - "id": 2, - "integration_level": 4 - }, - "lab_id": "cse04", - "lab_name": "Data Structures", - "overview": "overview" + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + }, + { + "asset_type": "image", + "id": 2, + "path": "vlabs.ac.in/images/static/image.png" + } + ], + "developers": [ + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + }, + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 6, + "name": "Prof. Dharamaja" + } + }, + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + }, + "id": 4, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 7, + "name": "Prof. Pallavi Pawar" + } + } + ], + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "experiments": [ + { + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + }, + { + "asset_type": "image", + "id": 2, + "path": "vlabs.ac.in/images/static/image.png" + } + ], + "developers": [ + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + }, + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 6, + "name": "Prof. Dharamaja" + } + }, + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + }, + "id": 4, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 7, + "name": "Prof. Pallavi Pawar" + } + } + ], + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "exp_id": "cse02", + "exp_name": "stack", + "hosting_info": [ + { + "hosted_on": "cloud", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosting_status": "hosted", + "id": 4 + }, + { + "hosted_on": "server", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosting_status": "hosted", + "id": 5 + } + ], + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "integration_status": { + "id": 5, + "integration_level": 4 + }, + "overview": "overview", + "sections": [ + { + "id": 3, + "name": "Procedure" + }, + { + "id": 2, + "name": "Theory" + } + ] + } + ], + "hosting_info": [ + { + "hosted_on": "cloud", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosting_status": "hosted", + "id": 4 + }, + { + "hosted_on": "server", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosting_status": "hosted", + "id": 5 + } + ], + "id": 1, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "integration_status": { + "id": 5, + "integration_level": 4 + }, + "lab_id": "cse03", + "lab_name": "Data Structures", + "overview": "overview" } #+END_EXAMPLE @@ -205,7 +503,212 @@ http://localhost:5000/labs?lab_id=cse04 + Contents : #+BEGIN_EXAMPLE - +[ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "lab_id": "cse03", + "assets": [ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + }, + { + "path": "vlabs.ac.in/images/static/image.png", + "asset_type": "image", + "id": 2 + } + ], + "hosting_info": [ + { + "hosting_status": "hosted", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosted_on": "cloud", + "id": 4 + }, + { + "hosting_status": "hosted", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosted_on": "server", + "id": 5 + } + ], + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "overview": "overview", + "lab_name": "Data Structures", + "experiments": [ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "hosting_info": [ + { + "hosting_status": "hosted", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosted_on": "cloud", + "id": 4 + }, + { + "hosting_status": "hosted", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosted_on": "server", + "id": 5 + } + ], + "assets": [ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + }, + { + "path": "vlabs.ac.in/images/static/image.png", + "asset_type": "image", + "id": 2 + } + ], + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "exp_name": "stack", + "overview": "overview", + "exp_id": "cse02", + "developers": [ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 3, + "name": { + "name": "Prof. Dharamaja", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + } + }, + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 4, + "name": { + "name": "Prof. Pallavi Pawar", + "id": 7 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + } + } + ], + "sections": [ + { + "name": "Procedure", + "id": 3 + }, + { + "name": "Theory", + "id": 2 + } + ], + "id": 3, + "integration_status": { + "integration_level": 4, + "id": 5 + } + } + ], + "integration_status": { + "integration_level": 4, + "id": 5 + }, + "developers": [ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 3, + "name": { + "name": "Prof. Dharamaja", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + } + }, + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 4, + "name": { + "name": "Prof. Pallavi Pawar", + "id": 7 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + } + } + ], + "id": 1 + } +] #+END_EXAMPLE @@ -235,63 +738,211 @@ http://localhost:5000/labs?institute_name=IIIT Hyderabad + Contents : #+BEGIN_EXAMPLE -[ -{ - "assets": [ - { - "asset_type": "Image", - "id": 1, - "path": "vlabs.ac.in/images/static/logo.png" - } - ], - "developers": [ - { - "email": { - "email": "dharamrajuu@gmail.com", - "id": 3 - }, - "id": 3, - "name": { - "id": 3, - "name": "Prof. Dharamrajuu" - } - } - ], - "discipline": { - "dis_id": "cse", - "dis_name": "Computer Science", - "id": 1 - }, - "experiments": [ +[ { - "exp_id": "cse01", - "exp_name": "arrays", - "id": 1, - "overview": "overview", - "sections": [] + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "lab_id": "cse03", + "assets": [ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + }, + { + "path": "vlabs.ac.in/images/static/image.png", + "asset_type": "image", + "id": 2 + } + ], + "hosting_info": [ + { + "hosting_status": "hosted", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosted_on": "cloud", + "id": 4 + }, + { + "hosting_status": "hosted", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosted_on": "server", + "id": 5 + } + ], + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "overview": "overview", + "lab_name": "Data Structures", + "experiments": [ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "hosting_info": [ + { + "hosting_status": "hosted", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosted_on": "cloud", + "id": 4 + }, + { + "hosting_status": "hosted", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosted_on": "server", + "id": 5 + } + ], + "assets": [ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + }, + { + "path": "vlabs.ac.in/images/static/image.png", + "asset_type": "image", + "id": 2 + } + ], + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "exp_name": "stack", + "overview": "overview", + "exp_id": "cse02", + "developers": [ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 3, + "name": { + "name": "Prof. Dharamaja", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + } + }, + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 4, + "name": { + "name": "Prof. Pallavi Pawar", + "id": 7 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + } + } + ], + "sections": [ + { + "name": "Procedure", + "id": 3 + }, + { + "name": "Theory", + "id": 2 + } + ], + "id": 3, + "integration_status": { + "integration_level": 4, + "id": 5 + } + } + ], + "integration_status": { + "integration_level": 4, + "id": 5 + }, + "developers": [ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 3, + "name": { + "name": "Prof. Dharamaja", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + } + }, + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 4, + "name": { + "name": "Prof. Pallavi Pawar", + "id": 7 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + } + } + ], + "id": 1 } - ], - "hostinginfo": { - "hosted_on": "cloud", - "hosted_url": "http://cse14-iiith.vlabs.ac.in", - "hosting_status": "hosted", - "id": 1 - }, - "id": 6, - "institute": { - "id": 1, - "inst_id": "iiith", - "inst_name": "IIIT Hyderabad" - }, - "integrationstatus": { - "id": 2, - "integration_level": 4 - }, - "lab_id": "cse04", - "lab_name": "Data Structures", - "overview": "overview" -} - ] #+END_EXAMPLE @@ -323,62 +974,210 @@ http://localhost:5000/labs?discipline_name=Computer Science #+BEGIN_EXAMPLE [ -{ - "assets": [ - { - "asset_type": "Image", - "id": 1, - "path": "vlabs.ac.in/images/static/logo.png" - } - ], - "developers": [ - { - "email": { - "email": "dharamrajuu@gmail.com", - "id": 3 - }, - "id": 3, - "name": { - "id": 3, - "name": "Prof. Dharamrajuu" - } - } - ], - "discipline": { - "dis_id": "cse", - "dis_name": "Computer Science", - "id": 1 - }, - "experiments": [ { - "exp_id": "cse01", - "exp_name": "arrays", - "id": 1, - "overview": "overview", - "sections": [] + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + }, + { + "asset_type": "image", + "id": 2, + "path": "vlabs.ac.in/images/static/image.png" + } + ], + "developers": [ + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + }, + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 6, + "name": "Prof. Dharamaja" + } + }, + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + }, + "id": 4, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 7, + "name": "Prof. Pallavi Pawar" + } + } + ], + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "experiments": [ + { + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + }, + { + "asset_type": "image", + "id": 2, + "path": "vlabs.ac.in/images/static/image.png" + } + ], + "developers": [ + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + }, + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 6, + "name": "Prof. Dharamaja" + } + }, + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + }, + "id": 4, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 7, + "name": "Prof. Pallavi Pawar" + } + } + ], + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "exp_id": "cse02", + "exp_name": "stack", + "hosting_info": [ + { + "hosted_on": "cloud", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosting_status": "hosted", + "id": 4 + }, + { + "hosted_on": "server", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosting_status": "hosted", + "id": 5 + } + ], + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "integration_status": { + "id": 5, + "integration_level": 4 + }, + "overview": "overview", + "sections": [ + { + "id": 3, + "name": "Procedure" + }, + { + "id": 2, + "name": "Theory" + } + ] + } + ], + "hosting_info": [ + { + "hosted_on": "cloud", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosting_status": "hosted", + "id": 4 + }, + { + "hosted_on": "server", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosting_status": "hosted", + "id": 5 + } + ], + "id": 1, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "integration_status": { + "id": 5, + "integration_level": 4 + }, + "lab_id": "cse03", + "lab_name": "Data Structures", + "overview": "overview" } - ], - "hostinginfo": { - "hosted_on": "cloud", - "hosted_url": "http://cse14-iiith.vlabs.ac.in", - "hosting_status": "hosted", - "id": 1 - }, - "id": 6, - "institute": { - "id": 1, - "inst_id": "iiith", - "inst_name": "IIIT Hyderabad" - }, - "integrationstatus": { - "id": 2, - "integration_level": 4 - }, - "lab_id": "cse04", - "lab_name": "Data Structures", - "overview": "overview" -} - ] #+END_EXAMPLE @@ -427,7 +1226,7 @@ http://localhost:5000/labs?lab_name=Data Structures "id": 1, "inst_id": "iiith" }, - "integrationstatus": { + "integration_status": { "integration_level": 4, "key": "" }, @@ -482,62 +1281,212 @@ http://localhost:5000/labs?asset_type=image + Contents : #+BEGIN_EXAMPLE -{ - "assets": [ - { - "asset_type": "Image", - "id": 1, - "path": "vlabs.ac.in/images/static/logo.png" - } - ], - "developers": [ - { - "email": { - "email": "dharamrajuu@gmail.com", - "id": 3 - }, - "id": 3, - "name": { - "id": 3, - "name": "Prof. Dharamrajuu" - } - } - ], - "discipline": { - "dis_id": "cse", - "dis_name": "Computer Science", - "id": 1 - }, - "experiments": [ +[ { - "exp_id": "cse01", - "exp_name": "arrays", - "id": 1, - "overview": "overview", - "sections": [] + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "lab_id": "cse03", + "assets": [ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + }, + { + "path": "vlabs.ac.in/images/static/image.png", + "asset_type": "image", + "id": 2 + } + ], + "hosting_info": [ + { + "hosting_status": "hosted", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosted_on": "cloud", + "id": 4 + }, + { + "hosting_status": "hosted", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosted_on": "server", + "id": 5 + } + ], + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "overview": "overview", + "lab_name": "Data Structures", + "experiments": [ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "hosting_info": [ + { + "hosting_status": "hosted", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosted_on": "cloud", + "id": 4 + }, + { + "hosting_status": "hosted", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosted_on": "server", + "id": 5 + } + ], + "assets": [ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + }, + { + "path": "vlabs.ac.in/images/static/image.png", + "asset_type": "image", + "id": 2 + } + ], + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "exp_name": "stack", + "overview": "overview", + "exp_id": "cse02", + "developers": [ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 3, + "name": { + "name": "Prof. Dharamaja", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + } + }, + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 4, + "name": { + "name": "Prof. Pallavi Pawar", + "id": 7 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + } + } + ], + "sections": [ + { + "name": "Procedure", + "id": 3 + }, + { + "name": "Theory", + "id": 2 + } + ], + "id": 3, + "integration_status": { + "integration_level": 4, + "id": 5 + } + } + ], + "integration_status": { + "integration_level": 4, + "id": 5 + }, + "developers": [ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 3, + "name": { + "name": "Prof. Dharamaja", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + } + }, + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 4, + "name": { + "name": "Prof. Pallavi Pawar", + "id": 7 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + } + } + ], + "id": 1 } - ], - "hostinginfo": { - "hosted_on": "cloud", - "hosted_url": "http://cse14-iiith.vlabs.ac.in", - "hosting_status": "hosted", - "id": 1 - }, - "id": 6, - "institute": { - "id": 1, - "inst_id": "iiith", - "inst_name": "IIIT Hyderabad" - }, - "integrationstatus": { - "id": 2, - "integration_level": 4 - }, - "lab_id": "cse04", - "lab_name": "Data Structures", - "overview": "overview" -} - +] #+END_EXAMPLE @@ -566,26 +1515,26 @@ def get_lab(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) elif 'lab_name' in request.args: lab_name = request.args['lab_name'] @@ -597,26 +1546,26 @@ def get_lab(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) elif 'institute_name' in request.args: institute_name = request.args['institute_name'] @@ -628,26 +1577,26 @@ def get_lab(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) elif 'discipline_name' in request.args: discipline_name = request.args['discipline_name'] @@ -659,26 +1608,26 @@ def get_lab(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) elif 'asset_type' in request.args: asset_type = request.args['asset_type'] @@ -689,26 +1638,26 @@ def get_lab(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) elif 'keyword_lab_name' in request.args: keyword = request.args['keyword_lab_name'] @@ -719,26 +1668,26 @@ def get_lab(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) else: try: @@ -748,26 +1697,26 @@ def get_lab(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -792,8 +1741,18 @@ class TestGetLab(TestCase): def test_get_labs(self): print "test_get_labs_in_rest" + 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 = {'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -806,11 +1765,12 @@ class TestGetLab(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/integration_status", data=json.dumps(payload), headers=headers) payload = {'dis_name': 'Computer Science', 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -818,43 +1778,55 @@ class TestGetLab(TestCase): response = self.client.post("/disciplines", data=json.dumps(payload), headers=headers) - payload = {'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png', + 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("/assets", data=json.dumps(payload), + response = self.client.post("/hosting_info", 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 = {'name': 'Prof. Dharamaja', 'email': 'abc@gmail.com', - 'key': KEY} + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} headers = {'Content-Type': 'application/json'} 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} - + payload = {'exp_name': 'arrays', + 'exp_id': 'exp1', + 'overview' : 'overview', + 'sections': [], + 'inst_id': 'IITK', + 'integration_level': 4, + 'dis_id': 'CSE', + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}]} headers = {'Content-Type': 'application/json'} - response = self.client.post("/hostinginfos", data=json.dumps(payload), + response = self.client.post("/experiments", data=json.dumps(payload), headers=headers) payload = {'lab_name': 'Data Structures', @@ -863,11 +1835,24 @@ class TestGetLab(TestCase): 'inst_id': 'IITK', 'integration_level': 4, 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'key': KEY, - 'experiments': ['exp1'], - 'developers': ['abc@gmail.com'], - 'hosting_infos':['http://cse14-iiith.vlabs.ac.in'] + 'experiments': ['exp1'] } headers = {'Content-Type': 'application/json'} @@ -899,8 +1884,18 @@ class TestGetLabbyLabId(TestCase): def test_get_lab_by_labid(self): print "test_get_lab_by_labid_in_rest" + 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 = {'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -913,11 +1908,12 @@ class TestGetLabbyLabId(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/integration_status", data=json.dumps(payload), headers=headers) payload = {'dis_name': 'Computer Science', 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -925,26 +1921,6 @@ class TestGetLabbyLabId(TestCase): 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', @@ -952,30 +1928,75 @@ class TestGetLabbyLabId(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/hostinginfos", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), headers=headers) payload = {'name': 'Prof. Dharamaja', 'email': 'abc@gmail.com', - 'key': KEY} + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} headers = {'Content-Type': 'application/json'} response = self.client.post("/developers", data=json.dumps(payload), headers=headers) + payload = {'exp_name': 'arrays', + 'exp_id': 'exp1', + 'overview' : 'overview', + 'sections': [], + 'inst_id': 'IITK', + 'integration_level': 4, + 'dis_id': 'CSE', + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] + } + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/experiments", 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'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'key': KEY, - 'experiments': ['exp1'], - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'experiments': ['exp1'] } headers = {'Content-Type': 'application/json'} @@ -1008,8 +2029,18 @@ class TestGetLabsbyInstitute(TestCase): def test_get_labs_by_institute(self): print "test_get_labs_by_institute_in_rest" + 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 = {'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -1022,64 +2053,88 @@ class TestGetLabsbyInstitute(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/integration_status", data=json.dumps(payload), headers=headers) payload = {'dis_name': 'Computer Science', 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} - 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} - - - 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} - - response = self.client.post("/hostinginfos", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), headers=headers) payload = {'name': 'Prof. Dharamaja', 'email': 'abc@gmail.com', - 'key': KEY} + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} headers = {'Content-Type': 'application/json'} response = self.client.post("/developers", data=json.dumps(payload), headers=headers) + payload = {'exp_name': 'arrays', + 'exp_id': 'exp1', + 'overview' : 'overview', + 'sections': [], + 'inst_id': 'IITK', + 'integration_level': 4, + 'dis_id': 'CSE', + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}]} + + response = self.client.post("/experiments", 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'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'key': KEY, - 'experiments': ['exp1'], - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'experiments': ['exp1'] } @@ -1111,8 +2166,18 @@ class TestGetLabsbyDiscipline(TestCase): def test_get_labs_by_discipline(self): print "test_get_labs_by_discipline_in_rest" + 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 = {'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -1125,39 +2190,22 @@ class TestGetLabsbyDiscipline(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/integration_status", data=json.dumps(payload), headers=headers) payload = {'dis_name': 'Computer Science', 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} 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 = {'name': 'Prof. Dharamaja', 'email': 'abc@gmail.com', - 'key': KEY} + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} headers = {'Content-Type': 'application/json'} @@ -1170,7 +2218,37 @@ class TestGetLabsbyDiscipline(TestCase): 'key': KEY} - response = self.client.post("/hostinginfos", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), + headers=headers) + + payload = {'exp_name': 'arrays', + 'exp_id': 'exp1', + 'overview' : 'overview', + 'sections': [], + 'inst_id': 'IITK', + 'integration_level': 4, + 'dis_id': 'CSE', + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}]} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/experiments", data=json.dumps(payload), headers=headers) payload = {'lab_name': 'Data Structures', @@ -1179,11 +2257,24 @@ class TestGetLabsbyDiscipline(TestCase): 'inst_id': 'IITK', 'integration_level': 4, 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'key': KEY, - 'experiments': ['exp1'], - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'experiments': ['exp1'] } response = self.client.post("/labs", data=json.dumps(payload), @@ -1215,8 +2306,19 @@ class TestGetLabsbyLabName(TestCase): def test_get_labs_by_lab_name(self): print "test_get_labs_by_lab_name_in_rest" + 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 = {'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -1229,39 +2331,22 @@ class TestGetLabsbyLabName(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/integration_status", data=json.dumps(payload), headers=headers) payload = {'dis_name': 'Computer Science', 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} - 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} - - - response = self.client.post("/experiments", data=json.dumps(payload), - headers=headers) - payload = {'name': 'Prof. Dharamaja', 'email': 'abc@gmail.com', - 'key': KEY} + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} headers = {'Content-Type': 'application/json'} @@ -1273,8 +2358,35 @@ class TestGetLabsbyLabName(TestCase): 'hosted_on': 'cloud', 'key': KEY} + response = self.client.post("/hosting_info", data=json.dumps(payload), + headers=headers) + + payload = {'exp_name': 'arrays', + 'exp_id': 'exp1', + 'overview' : 'overview', + 'sections': [], + 'inst_id': 'IITK', + 'integration_level': 4, + 'dis_id': 'CSE', + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}]} - response = self.client.post("/hostinginfos", data=json.dumps(payload), + response = self.client.post("/experiments", data=json.dumps(payload), headers=headers) payload = {'lab_name': 'Data Structures', @@ -1283,11 +2395,24 @@ class TestGetLabsbyLabName(TestCase): 'inst_id': 'IITK', 'integration_level': 4, 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'key': KEY, - 'experiments': ['exp1'], - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'experiments': ['exp1'] } @@ -1319,8 +2444,19 @@ class TestGetLabsbyAsset(TestCase): def test_get_labs_by_discipline(self): print "test_get_labs_by_discipline_in_rest" + 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 = {'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -1333,42 +2469,63 @@ class TestGetLabsbyAsset(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/integration_status", data=json.dumps(payload), headers=headers payload = {'dis_name': 'Computer Science', 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], '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} + + payload = {'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} headers = {'Content-Type': 'application/json'} - response = self.client.post("/assets", data=json.dumps(payload), + response = self.client.post("/developers", data=json.dumps(payload), headers=headers) - payload = {'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png', + 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("/assets", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), headers=headers) payload = {'exp_name': 'arrays', 'exp_id': 'exp1', 'overview': 'overview', 'sections': [], - 'key': KEY} - + 'inst_id': 'IITK', + 'integration_level': 4, + 'dis_id': 'CSE', + 'key': KEY} + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}]} headers = {'Content-Type': 'application/json'} response = self.client.post("/experiments", data=json.dumps(payload), @@ -1380,7 +2537,22 @@ class TestGetLabsbyAsset(TestCase): 'inst_id': 'IITK', 'integration_level': 4, 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'key': KEY, 'experiments': ['exp1'] } @@ -1415,8 +2587,18 @@ class TestGetLabbyLabNameKeyWord(TestCase): def test_get_lab_by_labname_keyword(self): print "test_get_lab_by_labname_keyword_in_rest" + 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 = {'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -1429,11 +2611,12 @@ class TestGetLabbyLabNameKeyWord(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/integration_status", data=json.dumps(payload), headers=headers) payload = {'dis_name': 'Computer Science', 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -1441,15 +2624,6 @@ class TestGetLabbyLabNameKeyWord(TestCase): 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', @@ -1468,13 +2642,15 @@ class TestGetLabbyLabNameKeyWord(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/hostinginfos", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), headers=headers) payload = {'name': 'Prof. Dharamaja', 'email': 'abc@gmail.com', - 'key': KEY} + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} headers = {'Content-Type': 'application/json'} @@ -1487,11 +2663,24 @@ class TestGetLabbyLabNameKeyWord(TestCase): 'inst_id': 'IITK', 'integration_level': 4, 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'key': KEY, - 'experiments': ['exp1'], - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'experiments': ['exp1'] } headers = {'Content-Type': 'application/json'} @@ -1521,17 +2710,23 @@ class TestGetLabbyLabNameKeyWord(TestCase): - Payload :: #+BEGIN_EXAMPLE {"lab_name": "Data Structures", - "lab_id": "cse03", - "inst_id": "iiith", - "dis_id": "cse", - "assets":["vlabs.ac.in/images/static/logo.png"], - "overview" : "overview", - "experiments":["cse01"], - "developers":["dharamrajuu@gmail.com"], - "hosted_url":"http://cse14-iiith.vlabs.ac.in", - "integration_level": 4, - "key": "defaultkey" - } +"lab_id": "cse03", +"inst_id": "iiith", +"dis_id": "cse", +"assets": [{"path":"vlabs.ac.in/images/static/logo.png","asset_type": "image"}, +{"path":"vlabs.ac.in/images/static/image.png", "asset_type": "image"}], +"developers": [{"name":"Prof. Dharamaja", "email": "abc@gmail.com", +"inst_id": "IITK", "dis_id": "CSE"}, {"name":"Prof. Pallavi Pawar", +"email": "pallavi.pawar@gmail.com", "inst_id": "IITK", "dis_id": "CSE"}], +"hosting_info": [{"hosted_url":"http://cse14-iiith.vlabs.ac.in", +"hosting_status": "hosted", "hosted_on": "cloud"}, +{"hosted_url":"http://iitkgp.vlab.co.in/", "hosting_status": "hosted", +"hosted_on": "server"}], +"overview" : "overview", +"experiments":["cse02"], +"integration_level": 4, +"key": "" +} #+END_EXAMPLE @@ -1540,61 +2735,209 @@ class TestGetLabbyLabNameKeyWord(TestCase): + Content: #+BEGIN_EXAMPLE { - "assets": [ - { - "asset_type": "Image", - "id": 1, - "path": "vlabs.ac.in/images/static/logo.png" - } - ], - "developers": [ - { - "email": { - "email": "dharamrajuu@gmail.com", - "id": 3 - }, - "id": 3, - "name": { - "id": 3, - "name": "Prof. Dharamrajuu" - } - } - ], - "discipline": { - "dis_id": "cse", - "dis_name": "Computer Science", - "id": 1 - }, - "experiments": [ - { - "exp_id": "cse01", - "exp_name": "arrays", - "id": 1, - "overview": "overview", - "sections": [] - } - ], - "hostinginfo": { - "hosted_on": "cloud", - "hosted_url": "http://cse14-iiith.vlabs.ac.in", - "hosting_status": "hosted", - "id": 1 - }, - "id": 6, - "institute": { - "id": 1, - "inst_id": "iiith", - "inst_name": "IIIT Hyderabad" - }, - "integrationstatus": { - "id": 2, - "integration_level": 4 - }, - "lab_id": "cse04", - "lab_name": "Data Structures", - "overview": "overview" + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + }, + { + "asset_type": "image", + "id": 2, + "path": "vlabs.ac.in/images/static/image.png" + } + ], + "developers": [ + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + }, + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 6, + "name": "Prof. Dharamaja" + } + }, + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + }, + "id": 4, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 7, + "name": "Prof. Pallavi Pawar" + } + } + ], + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "experiments": [ + { + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + }, + { + "asset_type": "image", + "id": 2, + "path": "vlabs.ac.in/images/static/image.png" + } + ], + "developers": [ + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + }, + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 6, + "name": "Prof. Dharamaja" + } + }, + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + }, + "id": 4, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 7, + "name": "Prof. Pallavi Pawar" + } + } + ], + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "exp_id": "cse02", + "exp_name": "stack", + "hosting_info": [ + { + "hosted_on": "cloud", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosting_status": "hosted", + "id": 4 + }, + { + "hosted_on": "server", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosting_status": "hosted", + "id": 5 + } + ], + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "integration_status": { + "id": 5, + "integration_level": 4 + }, + "overview": "overview", + "sections": [ + { + "id": 3, + "name": "Procedure" + }, + { + "id": 2, + "name": "Theory" + } + ] + } + ], + "hosting_info": [ + { + "hosted_on": "cloud", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosting_status": "hosted", + "id": 4 + }, + { + "hosted_on": "server", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosting_status": "hosted", + "id": 5 + } + ], + "id": 1, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "integration_status": { + "id": 5, + "integration_level": 4 + }, + "lab_id": "cse03", + "lab_name": "Data Structures", + "overview": "overview" } - #+END_EXAMPLE - Error Response: @@ -1620,39 +2963,43 @@ def add_lab(): try: lab = SystemInterface.add_lab(data_dict) - return jsonify(lab) + return_data = {} + return_data["data"] = lab + return_data["status"] = "success" + return_data["status_code"] = 200 + return jsonify(return_data) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -1677,8 +3024,18 @@ class TestAddLab(TestCase): def test_add_lab(self): print "test_add_lab_in_rest" + 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 = {'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -1691,11 +3048,12 @@ class TestAddLab(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/integration_status", data=json.dumps(payload), headers=headers) payload = {'dis_name': 'Computer Science', 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -1703,33 +3061,55 @@ class TestAddLab(TestCase): 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} + payload = {'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} headers = {'Content-Type': 'application/json'} - response = self.client.post("/assets", data=json.dumps(payload), + response = self.client.post("/developers", data=json.dumps(payload), headers=headers) - payload = {'exp_name': 'arrays', - 'exp_id': 'exp1', - 'overview' : 'overview', - 'sections': [], + 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("/experiments", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), headers=headers) - payload = {'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com', - 'key': KEY} + payload = {'exp_name': 'arrays', + 'exp_id': 'exp1', + 'overview' : 'overview', + 'sections': [], + 'inst_id': 'IITK', + 'integration_level': 4, + 'dis_id': 'CSE', + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}],} headers = {'Content-Type': 'application/json'} - response = self.client.post("/developers", data=json.dumps(payload), + response = self.client.post("/experiments", data=json.dumps(payload), headers=headers) payload = {'lab_name': 'Data Structures', @@ -1738,10 +3118,24 @@ class TestAddLab(TestCase): 'inst_id': 'IITK', 'integration_level': 4, 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'overview' : 'overview', - 'experiments': ['exp1'], - 'developers': ['abc@gmail.com'] + 'experiments': ['exp1'] } headers = {'Content-Type': 'application/json'} @@ -1749,16 +3143,6 @@ class TestAddLab(TestCase): 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) - self.assertEqual(response.status_code, 200) @@ -1784,7 +3168,92 @@ class TestAddLab(TestCase): + Contents : #+BEGIN_EXAMPLE -[{"inst_name": "IIIT Hyderabad", "id": 1, "inst_id": "iiith"}] +[ + { + "id": 1, + "inst_name": "Amrita University", + "assets": [], + "inst_id": "amrita" + }, + { + "id": 2, + "inst_name": "College of Engineering, Pune", + "assets": [], + "inst_id": "coep" + }, + { + "id": 3, + "inst_name": "Dayalbagh Educational institute_cls", + "assets": [], + "inst_id": "dei" + }, + { + "id": 4, + "inst_name": "IIT Bombay", + "assets": [], + "inst_id": "iitb" + }, + { + "id": 5, + "inst_name": "IIT Delhi", + "assets": [], + "inst_id": "iitd" + }, + { + "id": 6, + "inst_name": "IIT Guwahati", + "assets": [], + "inst_id": "iitg" + }, + { + "id": 7, + "inst_name": "IIIT Hyderabad", + "assets": [], + "inst_id": "iiith" + }, + { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + { + "id": 9, + "inst_name": "IIT Kharagpur", + "assets": [], + "inst_id": "iitkgp" + }, + { + "id": 10, + "inst_name": "IIT Madras", + "assets": [], + "inst_id": "iitm" + }, + { + "id": 11, + "inst_name": "IIT Roorkee", + "assets": [], + "inst_id": "iitr" + }, + { + "id": 12, + "inst_name": "NIT Surathkal", + "assets": [], + "inst_id": "nitk" + }, + { + "id": 13, + "inst_name": "IIT Hyderabad", + "assets": [ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + } + ], + "inst_id": " IITH" + } +] #+END_EXAMPLE @@ -1814,7 +3283,18 @@ http://localhost:5000/institutes + Contents : #+BEGIN_EXAMPLE -{"inst_name": "IIIT Hyderabad", "id": 1, "inst_id": "iiith"} +{ + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + } + ], + "id": 14, + "inst_id": "IITH", + "inst_name": "IIT Hyderabad" +} #+END_EXAMPLE @@ -1844,26 +3324,26 @@ def get_institute(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) else: @@ -1875,26 +3355,26 @@ def get_institute(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -1918,8 +3398,18 @@ class TestGetInstitute(TestCase): def test_get_institutes(self): print "test_get_institutes_in_rest" + 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 = {'inst_name': 'IIIT Hyderabad', 'inst_id': 'IIITH', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -1951,8 +3441,18 @@ class TestGetInstitute(TestCase): def test_get_institute_by_instituteid(self): print "test_get_institute_by_instituteid_in_rest" + 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 = {'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY } @@ -1981,9 +3481,10 @@ class TestGetInstitute(TestCase): - Payload :: #+BEGIN_EXAMPLE { -"inst_id": "iiith", -"inst_name": "IIIT Hyderabad", -"key": "" +"inst_id": " IITH", +"inst_name": "IIT Hyderabad", +"key": "", +"assets": ["vlabs.ac.in/images/static/logo.png"] } #+END_EXAMPLE @@ -1992,11 +3493,17 @@ class TestGetInstitute(TestCase): + Content: #+BEGIN_EXAMPLE { - "id": 1, - "inst_id": "iiith", - "inst_name": "IIIT Hyderabad" + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + } + ], + "id": 13, + "inst_id": " IITH", + "inst_name": "IIT Hyderabad" } - #+END_EXAMPLE - Error Response: @@ -2005,7 +3512,7 @@ class TestGetInstitute(TestCase): - Example: #+BEGIN_EXAMPLE -http://localhost:5000/disciplines +http://localhost:5000/institutes #+END_EXAMPLE *** Implementation @@ -2030,32 +3537,32 @@ def add_institute(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -2078,8 +3585,19 @@ class TestAddInstitute(TestCase): def test_add_institute(self): print "test_add_institute_in_rest" + + 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 = {'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -2112,11 +3630,102 @@ class TestAddInstitute(TestCase): #+BEGIN_EXAMPLE [ -{ - "dis_id": "cse", - "dis_name": "Computer Science and Engineering", - "id": 1 -} + { + "dis_id": "aero", + "assets": [], + "dis_name": "Aerospace Engineering", + "id": 1 + }, + { + "dis_id": "biotech", + "assets": [], + "dis_name": "Biotechnology and Biomedical Engineering", + "id": 2 + }, + { + "dis_id": "chem-engg", + "assets": [], + "dis_name": "Chemical Engineering", + "id": 3 + }, + { + "dis_id": "chem", + "assets": [], + "dis_name": "Chemical Sciences", + "id": 4 + }, + { + "dis_id": "civil", + "assets": [], + "dis_name": "Civil Engineering", + "id": 5 + }, + { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + { + "dis_id": "ee", + "assets": [], + "dis_name": "Electrical Engineering", + "id": 7 + }, + { + "dis_id": "ece", + "assets": [], + "dis_name": "Electronics and Communication", + "id": 8 + }, + { + "dis_id": "hmt", + "assets": [], + "dis_name": "Humanities", + "id": 9 + }, + { + "dis_id": "mech", + "assets": [], + "dis_name": "Mechanical Engineering", + "id": 10 + }, + { + "dis_id": "phy-sc", + "assets": [], + "dis_name": "Physical Sciences", + "id": 11 + }, + { + "dis_id": "tex-engg", + "assets": [], + "dis_name": "Textile Engineering", + "id": 12 + }, + { + "dis_id": "dsgn-engg", + "assets": [], + "dis_name": "Design Engineering", + "id": 13 + }, + { + "dis_id": "mat-sc", + "assets": [], + "dis_name": "Material Sciences", + "id": 14 + }, + { + "dis_id": "ab", + "assets": [ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + } + ], + "dis_name": "Auto Mobiles", + "id": 15 + } ] #+END_EXAMPLE @@ -2148,9 +3757,16 @@ http://localhost:5000/disciplines #+BEGIN_EXAMPLE { - "dis_id": "cse", - "dis_name": "Computer Science and Engineering", - "id": 1 + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + } + ], + "dis_id": "ab", + "dis_name": "Auto Mobiles", + "id": 15 } #+END_EXAMPLE @@ -2181,26 +3797,26 @@ def get_discipline(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) else: @@ -2213,26 +3829,26 @@ def get_discipline(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases @@ -2255,17 +3871,27 @@ class TestGetDiscipline(TestCase): def test_get_disciplines(self): print "test_get_discipline_in_rest" - payload = {'dis_name': 'IIT Delhi', - 'dis_id': 'EEE10', + payload = {'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png', 'key': KEY} headers = {'Content-Type': 'application/json'} - response = self.client.post("/disciplines", data=json.dumps(payload), + response = self.client.post("/assets", data=json.dumps(payload), headers=headers) - response = self.client.get("/disciplines", headers=headers) - self.assertEqual(response.status_code, 200) + payload = {'dis_name': 'IIT Delhi', + 'dis_id': 'EEE10', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/disciplines", data=json.dumps(payload), + headers=headers) + + response = self.client.get("/disciplines", headers=headers) + self.assertEqual(response.status_code, 200) #+END_SRC @@ -2288,8 +3914,18 @@ class TestGetDisciplineByDisId(TestCase): def test_get_discipline_by_disid(self): print "test_get_discipline_by_disid_in_rest" + 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 = {'dis_name': 'IIT Delhi', 'dis_id': 'EEE10', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -2319,9 +3955,10 @@ class TestGetDisciplineByDisId(TestCase): - Payload :: #+BEGIN_EXAMPLE { -"dis_id": "cse", -"dis_name": "Computer Science", - "key": "" +"dis_id": "ab", +"assets": ["vlabs.ac.in/images/static/logo.png"], +"dis_name": "Auto Mobiles", +"key": "" } #+END_EXAMPLE @@ -2330,9 +3967,16 @@ class TestGetDisciplineByDisId(TestCase): + Content: #+BEGIN_EXAMPLE { - "dis_id": "cse", - "dis_name": "Computer Science", - "id": 1 + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + } + ], + "dis_id": "ab", + "dis_name": "Auto Mobiles", + "id": 15 } #+END_EXAMPLE @@ -2368,32 +4012,32 @@ def add_discipline(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -2416,8 +4060,19 @@ class TestAddDiscipline(TestCase): def test_add_discipline(self): print "test_add_discipline_in_rest" + + 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 = {'dis_name': 'IIT Delhi', 'dis_id': 'EEE10', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -2449,24 +4104,147 @@ class TestAddDiscipline(TestCase): + Contents : #+BEGIN_EXAMPLE - [ - { - "overview": "overview", - "exp_name": "arrays", - "sections": [ - { - "name": "Procedure", + { + "discipline": { + "dis_id": "cse", + "id": 1, + "dis_name": "Computer Science" + }, + "assets": [ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + } + ], + "institute": { + "inst_name": "IIIT Hyderabad", + "id": 1, + "inst_id": "iiith" + }, + "exp_name": "stack", + "hostinginfos": [ + { + "hosting_status": "hosted", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosted_on": "cloud", + "id": 1 + } + ], + "integrationstatus": { + "integration_level": 4, + "id": 1 + }, + "overview": "overview", + "exp_id": "ece01", + "developers": [ + { + "id": 1, + "name": { + "name": "Prof. Dharamraj", + "id": 4 + }, + "email": { + "email": "dharamraj@gmail.com", + "id": 4 + } + } + ], + "sections": [ + { + "name": "Procedure", + "id": 2 + }, + { + "name": "Theory", + "id": 1 + } + ], "id": 2 - }, - { - "name": "Theory", - "id": 1 - } - ], - "id": 1, - "exp_id": "exp9" - } + }, + { + "discipline": { + "dis_id": "cse", + "id": 1, + "dis_name": "Computer Science" + }, + "assets": [], + "institute": { + "inst_name": "IIIT Hyderabad", + "id": 1, + "inst_id": "iiith" + }, + "exp_name": "stack", + "hostinginfos": [], + "integrationstatus": { + "integration_level": 4, + "id": 1 + }, + "overview": "overview", + "exp_id": "ece02", + "developers": [], + "sections": [], + "id": 4 + }, + { + "discipline": { + "dis_id": "cse", + "id": 1, + "dis_name": "Computer Science" + }, + "assets": [ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + } + ], + "institute": { + "inst_name": "IIIT Hyderabad", + "id": 1, + "inst_id": "iiith" + }, + "exp_name": "stack", + "hostinginfos": [ + { + "hosting_status": "hosted", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosted_on": "cloud", + "id": 1 + } + ], + "integrationstatus": { + "integration_level": 4, + "id": 1 + }, + "overview": "overview", + "exp_id": "cse03", + "developers": [ + { + "id": 1, + "name": { + "name": "Prof. Dharamraj", + "id": 4 + }, + "email": { + "email": "dharamraj@gmail.com", + "id": 4 + } + } + ], + "sections": [ + { + "name": "Procedure", + "id": 2 + }, + { + "name": "Theory", + "id": 1 + } + ], + "id": 6 + } ] #+END_EXAMPLE @@ -2497,22 +4275,112 @@ http://localhost:5000/experiments + Contents : #+BEGIN_EXAMPLE - { - "overview": "overview", - "exp_name": "arrays", - "sections": [ - { - "name": "Procedure", - "id": 2 - }, - { - "name": "Theory", - "id": 1 - } +{ + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + }, + { + "asset_type": "image", + "id": 2, + "path": "vlabs.ac.in/images/static/image.png" + } + ], + "developers": [ + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + }, + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 6, + "name": "Prof. Dharamaja" + } + }, + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + }, + "id": 4, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 7, + "name": "Prof. Pallavi Pawar" + } + } + ], + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "exp_id": "cse01", + "exp_name": "stack", + "hosting_info": [ + { + "hosted_on": "cloud", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosting_status": "hosted", + "id": 4 + }, + { + "hosted_on": "server", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosting_status": "hosted", + "id": 5 + } ], "id": 1, - "exp_id": "exp9" - } + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "integration_status": { + "id": 5, + "integration_level": 4 + }, + "overview": "overview", + "sections": [ + { + "id": 3, + "name": "Procedure" + }, + { + "id": 2, + "name": "Theory" + } + ] +} #+END_EXAMPLE @@ -2544,26 +4412,26 @@ def get_experiment(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) else: try: experiments = SystemInterface.get_experiments() @@ -2574,32 +4442,32 @@ def get_experiment(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -2623,11 +4491,94 @@ class TestGetExperiment(TestCase): def test_get_experiments(self): print "test_get_experiments_in_rest" + 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 = {'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/institutes", data=json.dumps(payload), + headers=headers) + + payload = {'dis_name': 'Computer Science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY + } + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/disciplines", data=json.dumps(payload), + headers=headers) + + payload = {'integration_level': 4, + 'key': KEY + } + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/integration_status", data=json.dumps(payload), + headers=headers) + + payload = {'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE' + } + + headers = {'Content-Type': 'application/json'} + + 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("/hosting_info", data=json.dumps(payload), + headers=headers) + payload = {'exp_name': 'stack', 'exp_id': 'cse01', 'overview' : 'overview', 'sections' : [], - 'key': KEY} + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'integration_level': 4, + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] + } headers = {'Content-Type': 'application/json'} @@ -2657,22 +4608,99 @@ class TestGetExp(TestCase): def test_get_experiment_by_expid(self): print "test_get_experiment_by_expid_in_rest" + payload = {'integration_level': 4, + 'key': KEY + } + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/integration_status", 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 = {'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} + + headers = {'Content-Type': 'application/json'} + + 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("/hosting_info", data=json.dumps(payload), + headers=headers) + + payload = {'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/institutes", data=json.dumps(payload), + headers=headers) + + payload = {'dis_name': 'Computer Science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/disciplines", data=json.dumps(payload), + headers=headers) payload = {'exp_name': 'stack', 'exp_id': 'cse01', 'overview' : 'overview', 'sections' : [], - 'key': KEY} + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'key': KEY, + 'integration_level': 4, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] + } headers = {'Content-Type': 'application/json'} response = self.client.post("/experiments", data=json.dumps(payload), headers=headers) - response = self.client.get("/experiments?exp_id=cse01", \ - headers=headers) + response = self.client.get("/experiments", headers=headers) self.assertEqual(response.status_code, 200) + #+END_SRC @@ -2690,13 +4718,24 @@ class TestGetExp(TestCase): - Payload :: #+BEGIN_EXAMPLE -{ - "exp_id": "exp9", - "exp_name": "arrays", - "key":"", - "overview": "overview", - "sections": ["Theory", "Procedure"] -} +{"exp_name": "stack", +"exp_id": "cse02", +"inst_id": "iiith", +"dis_id": "cse", +"overview" : "overview", +"assets": [{"path":"vlabs.ac.in/images/static/logo.png","asset_type": "image"}, + {"path":"vlabs.ac.in/images/static/image.png", "asset_type": "image"}], +"developers": [{"name":"Prof. Dharamaja", "email": "abc@gmail.com", +"inst_id": "IITK", "dis_id": "CSE"}, {"name":"Prof. Pallavi Pawar", +"email": "pallavi.pawar@gmail.com", "inst_id": "IITK", "dis_id": "CSE"}], +"hosting_info": [{"hosted_url":"http://cse14-iiith.vlabs.ac.in", + "hosting_status": "hosted", "hosted_on": "cloud"}, + {"hosted_url":"http://iitkgp.vlab.co.in/", "hosting_status": "hosted", +"hosted_on": "server"}], +"sections": ["Theory", "Procedure"], +"integration_level": 4, +"key": "" +} #+END_EXAMPLE - Success Response @@ -2704,22 +4743,111 @@ class TestGetExp(TestCase): + Content: #+BEGIN_EXAMPLE { - "exp_id": "exp9", - "exp_name": "arrays", - "id": 1, - "overview": "overview", - "sections": [ - { - "id": 1, - "name": "Theory" - }, - { - "id": 2, - "name": "Procedure" - } - ] + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + }, + { + "asset_type": "image", + "id": 2, + "path": "vlabs.ac.in/images/static/image.png" + } + ], + "developers": [ + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + }, + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 6, + "name": "Prof. Dharamaja" + } + }, + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + }, + "id": 4, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 7, + "name": "Prof. Pallavi Pawar" + } + } + ], + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "exp_id": "cse02", + "exp_name": "stack", + "hosting_info": [ + { + "hosted_on": "cloud", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosting_status": "hosted", + "id": 4 + }, + { + "hosted_on": "server", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosting_status": "hosted", + "id": 5 + } + ], + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "integration_status": { + "id": 5, + "integration_level": 4 + }, + "overview": "overview", + "sections": [ + { + "id": 2, + "name": "Theory" + }, + { + "id": 3, + "name": "Procedure" + } + ] } - #+END_EXAMPLE - Error Response: @@ -2746,39 +4874,39 @@ def get_add_experiment(): try: exp = SystemInterface.add_experiment(data_dict) - return jsonify(exp) + return jsonify(exp.to_client()) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -2801,23 +4929,102 @@ class TestAddExperiment(TestCase): def test_add_experiment(self): print "test_add_experiment_in_rest" - payload = {'exp_name': 'arrays', - 'exp_id': 'cse01', - 'overview' : 'overview', - 'sections': [], + + payload = {'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png', 'key': KEY} headers = {'Content-Type': 'application/json'} - response = self.client.post("/experiments", data=json.dumps(payload), - headers=headers) + response = self.client.post("/assets", data=json.dumps(payload), + headers=headers) - self.assertEqual(response.status_code, 200) + payload = {'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} - #+END_SRC + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/institutes", data=json.dumps(payload), + headers=headers) + + payload = {'dis_name': 'Computer Science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/disciplines", data=json.dumps(payload), + headers=headers) + + payload = {'integration_level': 4, + 'key': KEY + } + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/integration_status", data=json.dumps(payload), + headers=headers) + + payload = {'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} + + headers = {'Content-Type': 'application/json'} + + 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("/hosting_info", data=json.dumps(payload), + headers=headers) + + payload = {'exp_name': 'stack', + 'exp_id': 'cse01', + 'overview' : 'overview', + 'sections' : [], + 'integration_level': 4, + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}]} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/experiments", data=json.dumps(payload), + headers=headers) + + response = self.client.get("/experiments", headers=headers) + self.assertEqual(response.status_code, 200) + + #+END_SRC -** Get Section +** Get Sections *** API Design **** Get all Sections :PROPERTIES: @@ -2847,11 +5054,11 @@ http://localhost:5000/sections #+END_EXAMPLE *** Implementation -REST API to get Section. -#+NAME: get_section +REST API to get Sections. +#+NAME: get_sections #+BEGIN_SRC python @api.route('/sections', methods=['GET']) -def get_section(): +def get_sections(): if request.method == 'GET': try: sections = SystemInterface.get_sections() @@ -2862,34 +5069,34 @@ def get_section(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases -**** TestGetSection - #+NAME: test_get_Section +**** TestGetSections + #+NAME: test_get_Sections #+BEGIN_SRC python -class TestGetSection(TestCase): +class TestGetSections(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -2902,15 +5109,15 @@ class TestGetSection(TestCase): db.session.remove() db.drop_all() - def test_get_section(self): - print "test_get_section_in_rest" + def test_get_sections(self): + print "test_get_sections_in_rest" payload = {'name': 'Theory', 'key': KEY} headers = {'Content-Type': 'application/json'} - response = self.client.post("/section", data=json.dumps(payload), + response = self.client.post("/sections", data=json.dumps(payload), headers=headers) response = self.client.get("/sections", headers=headers) @@ -2982,32 +5189,32 @@ def add_section(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -3028,7 +5235,7 @@ class TestAddSection(TestCase): db.session.remove() db.drop_all() - def test_add_experiment(self): + def test_add_section(self): print "test_add_section_in_rest" payload = {'name': 'Quiz', 'key': KEY} @@ -3043,13 +5250,13 @@ class TestAddSection(TestCase): #+END_SRC -** Get HostingInfos and Get HostingInfo +** Get Hosting_Info and Get HostingInfo *** API Design -**** Get all HostingInfos +**** Get all Hosting_Info :PROPERTIES: - :CUSTOM_ID: api_get_all_hostinginfos + :CUSTOM_ID: api_get_all_hosting_info :END: - - URL :: /hostinginfos + - URL :: /hosting_info - Method :: GET @@ -3072,96 +5279,130 @@ class TestAddSection(TestCase): - Example: #+BEGIN_EXAMPLE -http://localhost:5000/hostinginfos +http://localhost:5000/hosting_info #+END_EXAMPLE +**** Get Hosting_Info by hosted_url + :PROPERTIES: + :CUSTOM_ID: api_get_hosting_info_by_hosted_url + :END: + - URL :: /hosting_infos?hosted_url= + + - Method :: GET + + - URL Params :: None + + - Payload :: + + - Success Response + + Status_Code: 200 + + Contents : + +#+BEGIN_EXAMPLE +{ + "hosted_on": "cloud", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosting_status": "hosted", + "id": 1 +} +#+END_EXAMPLE + + + - Error Response: + + Contents : + {"status" : "error"} + + - Example: +#+BEGIN_EXAMPLE +http://localhost:5000/assets?path=http://cse14-iiith.vlabs.ac.in +#+END_EXAMPLE *** Implementation -REST API to get all hostinginfos. -#+NAME: get_hostinginfo +REST API to get all hosting_info. +#+NAME: get_hosting_info #+BEGIN_SRC python -@api.route('/hostinginfos', methods=['GET']) -def get_hostinginfo(): +@api.route('/hosting_info', methods=['GET']) +def get_hosting_info(): if request.method == 'GET': if 'hosted_url' in request.args: hosted_url = request.args['hosted_url'] try: - hostinginfo = SystemInterface.get_hostinginfo(hosted_url) - return jsonify(hostinginfo) + hosting_info = SystemInterface.get_hosting_info_by_hosted_url(hosted_url) + return jsonify(hosting_info) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) else: try: - hostinginfos = SystemInterface.get_hostinginfos() - return jsonify_list(hostinginfos) + hosting_info = SystemInterface.get_hosting_info() + return jsonify_list(hosting_info) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases -**** TestGetHostingInfo - #+NAME: test_get_HostingInfo +**** TestGetHosting_Info + #+NAME: test_get_Hosting_Info #+BEGIN_SRC python -class TestGetHostingInfo(TestCase): +class TestGetHosting_Info(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -3174,8 +5415,8 @@ class TestGetHostingInfo(TestCase): db.session.remove() db.drop_all() - def test_get_hostinginfos(self): - print "test_get_hostinginfos_in_rest" + def test_get_hosting_info(self): + print "test_get_hosting_info_in_rest" payload = {'hosting_status': 'hosted', 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', @@ -3184,22 +5425,56 @@ class TestGetHostingInfo(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/hostinginfos", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), headers=headers) - response = self.client.get("/hostinginfos", headers=headers) + response = self.client.get("/hosting_info", headers=headers) self.assertEqual(response.status_code, 200) #+END_SRC +**** TestGetHostingInfoByHostedURL + #+NAME: test_get_hosting_info_by_hosted_url + #+BEGIN_SRC python +class TestGetAssetByPath(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_asset_by_path(self): + print "test_get_hosting_info_by_hosted_url_in_rest" + + 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("/hosting_info", data=json.dumps(payload), + headers=headers) + + response = self.client.get("/hosting_info", headers=headers) + self.assertEqual(response.status_code, 200) + + #+END_SRC -** Add HostingInfo + +** Add Hosting_Info *** API Design -**** Add HostingInfo +**** Add Hosting_Info :PROPERTIES: - :CUSTOM_ID: api_add_hostinginfo + :CUSTOM_ID: api_add_hosting_info :END: - - URL :: /hostinginfos + - URL :: /hosting_info - Method :: POST @@ -3220,10 +5495,10 @@ class TestGetHostingInfo(TestCase): + Content: #+BEGIN_EXAMPLE { - "id": 1, + "hosted_on": "cloud", "hosted_url": "http://cse14-iiith.vlabs.ac.in", - "hosting_status": "hosted", - "hosted_on": "cloud" + "hosting_status": "hosted", + "id": 1 } #+END_EXAMPLE @@ -3234,15 +5509,15 @@ class TestGetHostingInfo(TestCase): - Example: #+BEGIN_EXAMPLE -http://localhost:5000/hostinginfos +http://localhost:5000/hosting_info #+END_EXAMPLE *** Implementation -REST API to add an hostinginfo. -#+NAME: add_hostinginfo +REST API to add an hosting_info. +#+NAME: add_hosting_info #+BEGIN_SRC python -@api.route('/hostinginfos', methods=['POST']) -def add_hostinginfo(): +@api.route('/hosting_info', methods=['POST']) +def add_hosting_info(): if request.method == 'POST': if request.is_json: data_json = json.dumps(request.get_json()) @@ -3251,48 +5526,48 @@ def add_hostinginfo(): abort(500, "the request does not contain data in json") try: - hostinginfo = SystemInterface.add_hostinginfo(data_dict) - return jsonify(hostinginfo) + hosting_info = SystemInterface.add_hosting_info(data_dict) + return jsonify(hosting_info) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases -**** TestAddHostingInfo - #+NAME: test_add_hostinginfo +**** TestAddHosting_Info + #+NAME: test_add_hosting_info #+BEGIN_SRC python -class TestAddHostingInfo(TestCase): +class TestAddHosting_Info(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -3305,8 +5580,8 @@ class TestAddHostingInfo(TestCase): db.session.remove() db.drop_all() - def test_add_hostinginfo(self): - print "test_add_hostinginfo_in_rest" + def test_add_hosting_info(self): + print "test_add_hosting_info_in_rest" payload = {'hosting_status': 'hosted', 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', 'hosted_on': 'cloud', @@ -3314,7 +5589,7 @@ class TestAddHostingInfo(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/hostinginfos", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), headers=headers) self.assertEqual(response.status_code, 200) @@ -3322,13 +5597,13 @@ class TestAddHostingInfo(TestCase): #+END_SRC -** Get IntegrationStatuss and Get IntegrationStatus +** Get Integration_Status and Get IntegrationStatus *** API Design -**** Get all IntegrationStatuss +**** Get all Integration_Status :PROPERTIES: - :CUSTOM_ID: api_get_all_integrationstatuss + :CUSTOM_ID: api_get_all_integration_status :END: - - URL :: /integrationstatuss + - URL :: /integration_status - Method :: GET @@ -3341,7 +5616,40 @@ class TestAddHostingInfo(TestCase): + Contents : #+BEGIN_EXAMPLE -[{"integration_level": 4, "id": 1}] +[ + { + "integration_level": 0, + "id": 1 + }, + { + "integration_level": 1, + "id": 2 + }, + { + "integration_level": 2, + "id": 3 + }, + { + "integration_level": 3, + "id": 4 + }, + { + "integration_level": 4, + "id": 5 + }, + { + "integration_level": 5, + "id": 6 + }, + { + "integration_level": 6, + "id": 7 + }, + { + "integration_level": 9, + "id": 8 + } +] #+END_EXAMPLE @@ -3351,97 +5659,98 @@ class TestAddHostingInfo(TestCase): - Example: #+BEGIN_EXAMPLE -http://localhost:5000/integrationstatuss +http://localhost:5000/integration_status #+END_EXAMPLE *** Implementation -REST API to get all integrationstatuss. -#+NAME: get_integrationstatus +REST API to get all integration_status. +#+NAME: get_integration_status #+BEGIN_SRC python -@api.route('/integrationstatuss', methods=['GET']) -def get_integrationstatus(): +@api.route('/integration_status', methods=['GET']) +def get_integration_status(): if request.method == 'GET': if 'integration_level' in request.args: integration_level = request.args['integration_level'] try: - integrationstatus = SystemInterface.get_integrationstatus(integration_level) - return jsonify(integrationstatus) + integration_status = SystemInterface.get_integration_status_by_IL\ + (integration_level) + return jsonify(integration_status.to_client()) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) else: try: - integrationstatuss = SystemInterface.get_integrationstatuss() - return jsonify_list(integrationstatuss) + integration_status = SystemInterface.get_integration_status() + return jsonify_list(integration_status) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases -**** TestGetIntegrationStatus - #+NAME: test_get_IntegrationStatus +**** TestGetIntegration_Status + #+NAME: test_get_Integration_Status #+BEGIN_SRC python -class TestGetIntegrationStatus(TestCase): +class TestGetIntegration_Status(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -3454,30 +5763,30 @@ class TestGetIntegrationStatus(TestCase): db.session.remove() db.drop_all() - def test_get_integrationstatuss(self): - print "test_get_integrationstatuss_in_rest" + def test_get_integration_status(self): + print "test_get_integration_status_in_rest" payload = {'integration_level': 4, 'key': KEY} headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/integration_status", data=json.dumps(payload), headers=headers) - response = self.client.get("/integrationstatuss", headers=headers) + response = self.client.get("/integration_status", headers=headers) self.assertEqual(response.status_code, 200) #+END_SRC -** Add IntegrationStatus +** Add Integration_Status *** API Design -**** Add IntegrationStatus +**** Add Integration_Status :PROPERTIES: - :CUSTOM_ID: api_add_integrationstatus + :CUSTOM_ID: api_add_integration_status :END: - - URL :: /integrationstatuss + - URL :: /integration_status - Method :: POST @@ -3486,7 +5795,7 @@ class TestGetIntegrationStatus(TestCase): - Payload :: #+BEGIN_EXAMPLE { -"integration_level": 4, +"integration_level": 9, "key": "" } #+END_EXAMPLE @@ -3508,15 +5817,15 @@ class TestGetIntegrationStatus(TestCase): - Example: #+BEGIN_EXAMPLE -http://localhost:5000/integrationstatuss +http://localhost:5000/integration_status #+END_EXAMPLE *** Implementation -REST API to add an integrationstatus. -#+NAME: add_integrationstatus +REST API to add an integration_status. +#+NAME: add_integration_status #+BEGIN_SRC python -@api.route('/integrationstatuss', methods=['POST']) -def add_integrationstatus(): +@api.route('/integration_status', methods=['POST']) +def add_integration_status(): if request.method == 'POST': if request.is_json: data_json = json.dumps(request.get_json()) @@ -3525,48 +5834,48 @@ def add_integrationstatus(): abort(500, "the request does not contain data in json") try: - integrationstatus = SystemInterface.add_integrationstatus(data_dict) - return jsonify(integrationstatus) + integration_status = SystemInterface.add_integration_status(data_dict) + return jsonify(integration_status) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases -**** TestAddIntegrationStatus - #+NAME: test_add_integrationstatus +**** TestAddIntegration_Status + #+NAME: test_add_integration_status #+BEGIN_SRC python -class TestAddIntegrationStatus(TestCase): +class TestAddIntegration_Status(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -3579,14 +5888,14 @@ class TestAddIntegrationStatus(TestCase): db.session.remove() db.drop_all() - def test_add_integrationstatus(self): - print "test_add_integrationstatus_in_rest" + def test_add_integration_status(self): + print "test_add_integration_status_in_rest" payload = {'integration_level': 4, 'key': KEY} headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/integration_status", data=json.dumps(payload), headers=headers) self.assertEqual(response.status_code, 200) @@ -3643,26 +5952,26 @@ def get_email(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) else: try: @@ -3673,26 +5982,26 @@ def get_email(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases @@ -3754,8 +6063,8 @@ class TestGetEmail(TestCase): + Content: #+BEGIN_EXAMPLE { - "id": 1, - "email": "dharamraj@gmail.com" + "email": "dharamraj@gmail.com", + "id": 1 } #+END_EXAMPLE @@ -3791,32 +6100,32 @@ def add_email(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -3852,11 +6161,11 @@ class TestAddEmail(TestCase): #+END_SRC -** Get Names and Get Name +** Get Names *** API Design -**** Get all Names +**** Get all names :PROPERTIES: - :CUSTOM_ID: api_get_all_names + :CUSTOM_ID: api_get_all_sections :END: - URL :: /names @@ -3869,12 +6178,9 @@ class TestAddEmail(TestCase): - Success Response + Status_Code: 200 + Contents : - #+BEGIN_EXAMPLE -[{"name": "Prof. Dharamraj", "id": 1}] -#+END_EXAMPLE - - +[{"name" : "Prof. Dharamraj", "id": 1}] +#+END_EXAMPLE - Error Response: + Contents : {"status" : "error"} @@ -3883,81 +6189,51 @@ class TestAddEmail(TestCase): #+BEGIN_EXAMPLE http://localhost:5000/names #+END_EXAMPLE - -*** Implementation -REST API to get all names. -#+NAME: get_name + +*** Implementation +REST API to get Names. +#+NAME: get_names #+BEGIN_SRC python @api.route('/names', methods=['GET']) -def get_name(): +def get_names(): if request.method == 'GET': - if 'name' in request.args: - name = request.args['name'] - try: - name = SystemInterface.get_name(name) - return jsonify(name) - - 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) + try: + names = SystemInterface.get_names() - except Exception as e: - err_str = str(e) - msg = {"status": "failure", - "msg": err_str} - return jsonify(msg) - - else: - try: - names = SystemInterface.get_names() - return jsonify_list(names) + return jsonify_list(names) - except TypeError as e: - err_str = str(e) - msg = {"status": "failure", + except TypeError as e: + err_str = str(e) + msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) - except StateError as e: - err_str = selftr(e) - msg = {"status": "failure", - "msg": err_str} - return jsonify(msg) + except StateError as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str} + abort(500, msg) - except NotFoundError as e: - err_str = str(e) - msg = {"status": "failure", - "status code": 404, - "msg": err_str} - return jsonify(msg) + except NotFoundError as e: + err_str = str(e) + msg = {"status": "failure", + "status code": 404, + "msg": err_str} + abort(404, msg) - except Exception as e: - err_str = str(e) - msg = {"status": "failure", - "msg": err_str} - return jsonify(msg) + except Exception as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str} + abort(500, msg) + #+END_SRC *** Test Cases -**** TestGetName - #+NAME: test_get_Name +**** TestGetNames + #+NAME: test_get_names #+BEGIN_SRC python -class TestGetName(TestCase): +class TestGetNames(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -3986,12 +6262,12 @@ class TestGetName(TestCase): #+END_SRC - + ** Add Name *** API Design -**** Add Name +**** Add names :PROPERTIES: - :CUSTOM_ID: api_add_name + :CUSTOM_ID: api_add_names :END: - URL :: /names @@ -4001,10 +6277,12 @@ class TestGetName(TestCase): - Payload :: #+BEGIN_EXAMPLE + { -"name": "Prof. Dharamraj", -"key": "" + "key": "", + "name" : "Prof. Dharamraj" } + #+END_EXAMPLE - Success Response @@ -4015,7 +6293,6 @@ class TestGetName(TestCase): "id": 1, "name": "Prof. Dharamraj" } - #+END_EXAMPLE - Error Response: @@ -4025,10 +6302,10 @@ class TestGetName(TestCase): - Example: #+BEGIN_EXAMPLE http://localhost:5000/names -#+END_EXAMPLE - -*** Implementation -REST API to add an name. +#+END_EXAMPLE + +*** Implementation +REST API to add Name. #+NAME: add_name #+BEGIN_SRC python @api.route('/names', methods=['POST']) @@ -4049,32 +6326,32 @@ def add_name(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -4129,7 +6406,54 @@ class TestAddName(TestCase): + Contents : #+BEGIN_EXAMPLE -[{"id": 1, "dev_name": "Prof. Dharamraj", "email_id": "dharamraj@gmail.com"}] +[ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 1, + "name": { + "name": "Prof. Dharamrajiiiiii", + "id": 4 + }, + "email": { + "email": "dharamrajiiiiii@gmail.com", + "id": 4 + } + }, + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 2, + "name": { + "name": "Prof. Dharam", + "id": 5 + }, + "email": { + "email": "dharam@gmail.com", + "id": 5 + } + } +] #+END_EXAMPLE @@ -4159,26 +6483,26 @@ def get_developer(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) else: try: @@ -4189,26 +6513,26 @@ def get_developer(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases @@ -4231,38 +6555,72 @@ class TestGetDeveloper(TestCase): def test_get_developers(self): print "test_get_developers_in_rest" - payload = {'dev_name': 'Prof. Dharamraj', - 'email_id': 'dharamraj@gmail.com', + payload = {'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png', 'key': KEY} headers = {'Content-Type': 'application/json'} - response = self.client.post("/developers", data=json.dumps(payload), - headers=headers) - - response = self.client.get("/developers", headers=headers) - self.assertEqual(response.status_code, 200) + response = self.client.post("/assets", data=json.dumps(payload), + headers=headers) - #+END_SRC - + payload = {'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} -** Add Developer -*** API Design -**** Add Developer - :PROPERTIES: - :CUSTOM_ID: api_add_developer - :END: - - URL :: /developers + headers = {'Content-Type': 'application/json'} - - Method :: POST + response = self.client.post("/institutes", data=json.dumps(payload), + headers=headers) + + payload = {'dis_name': 'Computer Science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/disciplines", data=json.dumps(payload), + headers=headers) + + payload = {'dev_name': 'Prof. Dharamraj', + 'email_id': 'dharamraj@gmail.com', + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/developers", data=json.dumps(payload), + headers=headers) + + response = self.client.get("/developers", headers=headers) + self.assertEqual(response.status_code, 200) + + #+END_SRC + + +** Add Developer +*** API Design +**** Add Developer + :PROPERTIES: + :CUSTOM_ID: api_add_developer + :END: + - URL :: /developers + + - Method :: POST - URL Params :: None - Payload :: #+BEGIN_EXAMPLE { -"name": "Prof. Dharamraj", -"email": "dharamraj@gmail.com", +"name": "Prof. Dharam", +"email": "dharam@gmail.com", +"inst_id": "IITK", +"dis_id": "cse", +"assets": ["vlabs.ac.in/static/images/logo.png"], "key": "" } #+END_EXAMPLE @@ -4271,11 +6629,54 @@ class TestGetDeveloper(TestCase): + Status_Code: 200 + Content: #+BEGIN_EXAMPLE -{ - "id": 1, - "name": "Prof. Dharamraj", - "email": "dharamraj@gmail.com" -} +[ + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 1, + "name": { + "name": "Prof. Dharamrajiiiiii", + "id": 4 + }, + "email": { + "email": "dharamrajiiiiii@gmail.com", + "id": 4 + } + }, + { + "discipline": { + "dis_id": "cse", + "assets": [], + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "institute": { + "id": 8, + "inst_name": "IIT Kanpur", + "assets": [], + "inst_id": "iitk" + }, + "id": 2, + "name": { + "name": "Prof. Dharam", + "id": 5 + }, + "email": { + "email": "dharam@gmail.com", + "id": 5 + } + } +] #+END_EXAMPLE @@ -4310,32 +6711,32 @@ def add_developer(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -4358,9 +6759,41 @@ class TestAddDeveloper(TestCase): def test_add_developer(self): print "test_add_developer_in_rest" + + 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 = {'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/institutes", data=json.dumps(payload), + headers=headers) + + payload = {'dis_name': 'Computer Science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/disciplines", data=json.dumps(payload), + headers=headers) + payload = {'name': 'Prof. Dharamraj', 'email': 'dharamraj@gmail.com', - 'key': KEY} + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} headers = {'Content-Type': 'application/json'} @@ -4388,14 +6821,24 @@ class TestAddDeveloper(TestCase): - Payload :: #+BEGIN_EXAMPLE {"lab_name": "Computer Programming", - "key": "defaultkey", - "overview" : "cp overview", - "inst_id": "IITK", - "integration_level": 4, - "dis_id": "CSE", - "assets": ["vlabs.ac.in/images/static/logo.png"], - "experiments":["exp1"] - } +"experiments":["exp1"], +"lab_id": "cse03", +"inst_id": "iiith", +"dis_id": "cse", +"assets": [{"path":"vlabs.ac.in/images/static/logo.png","asset_type": "image"}, +{"path":"vlabs.ac.in/images/static/image.png", "asset_type": "image"}], +"developers": [{"name":"Prof. Dharamaja", "email": "abc@gmail.com", +"inst_id": "IITK", "dis_id": "CSE"}, {"name":"Prof. Pallavi Pawar", +"email": "pallavi.pawar@gmail.com", "inst_id": "IITK", "dis_id": "CSE"}], +"hosting_info": [{"hosted_url":"http://cse14-iiith.vlabs.ac.in", +"hosting_status": "hosted", "hosted_on": "cloud"}, +{"hosted_url":"http://iitkgp.vlab.co.in/", "hosting_status": "hosted", +"hosted_on": "server"}], +"overview" : "overview", +"experiments":["cse01"], +"integration_level": 4, +"key": "" +} #+END_EXAMPLE - Success Response @@ -4417,7 +6860,7 @@ class TestAddDeveloper(TestCase): "id": 1 }, "experiments": [], - "hostinginfo": { + "hosting_info": { "hosted_on": "cloud", "hosted_url": "http://cse14-iiith.vlabs.ac.in", "hosting_status": "hosted", @@ -4429,7 +6872,7 @@ class TestAddDeveloper(TestCase): "inst_id": "iiith", "inst_name": "IIIT Hyderabad" }, - "integrationstatus": { + "integration_status": { "id": 2, "integration_level": 4 }, @@ -4476,32 +6919,32 @@ def update(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases @@ -4523,9 +6966,18 @@ class TestUpdateLab(TestCase): def test_update_lab(self): print "test_update_lab" + 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 = {'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -4538,84 +6990,156 @@ class TestUpdateLab(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/integration_status", data=json.dumps(payload), headers=headers) payload = {'dis_name': 'Computer Science', 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], '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', + payload = {'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} + + headers = {'Content-Type': 'application/json'} + + 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("/assets", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), headers=headers) payload = {'exp_name': 'arrays', 'exp_id': 'exp1', 'overview' : 'overview', 'sections': [], - 'key': KEY} + 'inst_id': 'IITK', + 'integration_level': 4, + 'dis_id': 'CSE', + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}],} + headers = {'Content-Type': 'application/json'} response = self.client.post("/experiments", data=json.dumps(payload), headers=headers) - payload = {'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com', - 'key': KEY} + payload = {'lab_name': 'Data Structures', + 'lab_id': 'cse01', + 'key': KEY, + 'inst_id': 'IITK', + 'integration_level': 4, + 'dis_id': 'CSE', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + 'overview' : 'overview', + 'experiments': ['exp1'] + } headers = {'Content-Type': 'application/json'} - response = self.client.post("/developers", data=json.dumps(payload), + 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', + + + payload1 = {'asset_type': 'Video', + 'path': 'vlabs.ac.in/images/video/icon.png', 'key': KEY} headers = {'Content-Type': 'application/json'} + response = self.client.post("/assets", data=json.dumps(payload1), + headers=headers) + + payload1 = {'inst_name': 'IIT Kharagpur', + 'inst_id': 'IITKgp', + 'assets': ['vlabs.ac.in/images/video/icon.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} - response = self.client.post("/hostinginfos", data=json.dumps(payload), + response = self.client.post("/institutes", data=json.dumps(payload1), 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'], - 'experiments':['exp1'], - 'key': KEY, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'key': KEY - } + payload1 = {'dis_name': 'Electronics & Comuunication Engg.', + 'dis_id': 'ECE', + 'assets': ['vlabs.ac.in/images/video/icon.png'], + 'key': KEY} + + + response = self.client.post("/disciplines", data=json.dumps(payload1), + headers=headers) payload1 = {'lab_name': 'Computer Programming', 'key': KEY, 'overview' : 'cp overview', - 'inst_id': 'IITK', + 'inst_id': 'IITKgp', 'integration_level': 4, - 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'dis_id': 'ECE', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse13-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitk.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments':['exp1'] } - response = self.client.post("/labs", data=json.dumps(payload), - headers=headers) - response = self.client.put("/labs?lab_id=cse01", data=json.dumps(payload1), headers=headers) @@ -4675,32 +7199,32 @@ def delete_lab(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -4724,8 +7248,18 @@ class TestDeleteLab(TestCase): def test_delete_lab(self): print "test_delete_lab" + 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 = {'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -4738,39 +7272,23 @@ class TestDeleteLab(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/integration_status", data=json.dumps(payload), headers=headers) payload = {'dis_name': 'Computer Science', 'dis_id': 'CSE', - 'key': KEY} - - - response = self.client.post("/disciplines", data=json.dumps(payload), - headers=headers) - - payload = {'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png', + 'assets': ['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} - - - response = self.client.post("/experiments", data=json.dumps(payload), + response = self.client.post("/disciplines", data=json.dumps(payload), headers=headers) payload = {'name': 'Prof. Dharamaja', 'email': 'abc@gmail.com', - 'key': KEY} + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} headers = {'Content-Type': 'application/json'} @@ -4784,24 +7302,64 @@ class TestDeleteLab(TestCase): headers = {'Content-Type': 'application/json'} - - response = self.client.post("/hostinginfos", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), headers=headers) + payload = {'exp_name': 'arrays', + 'exp_id': 'exp1', + 'overview' : 'overview', + 'integration_level': 4, + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'sections': [], + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}],} + + headers = {'Content-Type': 'application/json'} + response = self.client.post("/experiments", 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'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments':['exp1'], - 'key': KEY, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', 'key': KEY } - + headers = {'Content-Type': 'application/json'} response = self.client.post("/labs", data=json.dumps(payload), headers=headers) @@ -4827,10 +7385,23 @@ class TestDeleteLab(TestCase): - Payload :: #+BEGIN_EXAMPLE -{ - "exp_name": "2D arrays", - "key":"", - "overview": "2D Arrays overview" +{"exp_name": "2D Array", +"exp_id": "cse02", +"inst_id": "iiith", +"dis_id": "cse", +"overview" : "overview", +"assets": [{"path":"vlabs.ac.in/images/static/logo.png","asset_type": "image"}, + {"path":"vlabs.ac.in/images/static/image.png", "asset_type": "image"}], +"developers": [{"name":"Prof. Dharamaja", "email": "abc@gmail.com", +"inst_id": "IITK", "dis_id": "CSE"}, {"name":"Prof. Pallavi Pawar", +"email": "pallavi.pawar@gmail.com", "inst_id": "IITK", "dis_id": "CSE"}], +"hosting_info": [{"hosted_url":"http://cse14-iiith.vlabs.ac.in", + "hosting_status": "hosted", "hosted_on": "cloud"}, + {"hosted_url":"http://iitkgp.vlab.co.in/", "hosting_status": "hosted", +"hosted_on": "server"}], +"sections": ["Theory", "Procedure"], +"integration_level": 4, +"key":"" } #+END_EXAMPLE @@ -4840,22 +7411,111 @@ class TestDeleteLab(TestCase): + Contents : #+BEGIN_EXAMPLE { - "exp_id": "exp9", - "exp_name": "2D arrays", - "id": 1, - "overview": "2D Arrays overview", - "sections": [ - { - "id": 2, - "name": "Procedure" - }, - { - "id": 1, - "name": "Theory" - } - ] + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + }, + { + "asset_type": "image", + "id": 2, + "path": "vlabs.ac.in/images/static/image.png" + } + ], + "developers": [ + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "abc@gmail.com", + "id": 6 + }, + "id": 3, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 6, + "name": "Prof. Dharamaja" + } + }, + { + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "email": { + "email": "pallavi.pawar@gmail.com", + "id": 7 + }, + "id": 4, + "institute": { + "assets": [], + "id": 8, + "inst_id": "iitk", + "inst_name": "IIT Kanpur" + }, + "name": { + "id": 7, + "name": "Prof. Pallavi Pawar" + } + } + ], + "discipline": { + "assets": [], + "dis_id": "cse", + "dis_name": "Computer Science and Engineering", + "id": 6 + }, + "exp_id": "cse01", + "exp_name": "2D Array", + "hosting_info": [ + { + "hosted_on": "cloud", + "hosted_url": "http://cse14-iiith.vlabs.ac.in", + "hosting_status": "hosted", + "id": 4 + }, + { + "hosted_on": "server", + "hosted_url": "http://iitkgp.vlab.co.in/", + "hosting_status": "hosted", + "id": 5 + } + ], + "id": 1, + "institute": { + "assets": [], + "id": 7, + "inst_id": "iiith", + "inst_name": "IIIT Hyderabad" + }, + "integration_status": { + "id": 5, + "integration_level": 4 + }, + "overview": "overview", + "sections": [ + { + "id": 2, + "name": "Theory" + }, + { + "id": 3, + "name": "Procedure" + } + ] } - #+END_EXAMPLE - Error Response: @@ -4867,7 +7527,7 @@ class TestDeleteLab(TestCase): http://localhost:5000/experiments?exp_id=exp9 #+END_EXAMPLE -*** Implementation +*** Implementation #+NAME: update_experiment #+BEGIN_SRC python @api.route('/experiments', methods=['PUT']) @@ -4893,36 +7553,36 @@ def update_experiment(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases -**** TestUpdateExperiment +***** TestUpdateExperiment #+NAME: test_update_experiment #+BEGIN_SRC python class TestUpdateExperiment(TestCase): @@ -4940,152 +7600,146 @@ class TestUpdateExperiment(TestCase): def test_update_experiment(self): print "test_update_experiment" + + payload = {'integration_level': 4, + 'key': KEY + } + headers = {'Content-Type': 'application/json'} - payload = {'exp_name': 'Theory', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [], - 'key': KEY} + response = self.client.post("/integration_status", data=json.dumps(payload), + headers=headers) - payload1 = {'exp_name': 'Procedure', + payload = {'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png', 'key': KEY} - headers = {'Content-Type': 'application/json'} - response = self.client.post("/experiments", data=json.dumps(payload), - headers=headers) + response = self.client.post("/assets", data=json.dumps(payload), + headers=headers) - response = self.client.put("/experiments?exp_id=exp123", - data=json.dumps(payload1), - headers=headers) + payload = {'name': 'Theory', + 'key': KEY + } + headers = {'Content-Type': 'application/json'} - self.assertEqual(response.status_code, 200) + response = self.client.post("/sections", data=json.dumps(payload), + headers=headers) - #+END_SRC - + payload = {'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} -** Delete Experiment -*** API Design -**** Delete experiment by exp_id - :PROPERTIES: - :CUSTOM_ID: api_delete_experiment_by_exp_id - :END: - - URL :: /experiments?&key= + headers = {'Content-Type': 'application/json'} - - Method :: DELETE + response = self.client.post("/institutes", data=json.dumps(payload), + headers=headers) - - URL Params :: None + payload = {'dis_name': 'Computer Science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} - - Payload :: + headers = {'Content-Type': 'application/json'} - - Success Response - + Status_Code: 200 - + Contents : -#+BEGIN_EXAMPLE -{ - "status": "sucess" -} + response = self.client.post("/disciplines", data=json.dumps(payload), + headers=headers) -#+END_EXAMPLE - - - Error Response: - + Contents : - {"status" : "error"} - - - Example: -#+BEGIN_EXAMPLE -http://localhost:5000/experiments/2 -#+END_EXAMPLE + payload = {'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} -*** Implementation -#+NAME: delete_experiment -#+BEGIN_SRC python -@api.route('/experiments', methods=['DELETE']) -def delete_experiment(): - if request.method == 'DELETE': - if 'exp_id' in request.args and 'key' in request.args: - exp_id = request.args['exp_id'] - key = request.args['key'] - try: - exp_id = SystemInterface.delete_experiment(exp_id, key) - return jsonify({"status":"sucess"}) - - except NotAuthorizedError as e: - err_str = str(e) - msg = {"status": "failure", - "status code": 401, - "msg": err_str} - return jsonify(msg) - - 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) - - -#+END_SRC -*** Test Cases -**** TestDeleteExperiment - #+NAME: test_delete_experiment - #+BEGIN_SRC python -class TestDeleteExperiment(TestCase): - TESTING = True - def create_app(self): - app = create_app(config) - return app + headers = {'Content-Type': 'application/json'} - def setUp(self): - db.create_all() + response = self.client.post("/developers", data=json.dumps(payload), + headers=headers) - def tearDown(self): - db.session.remove() - db.drop_all() + payload = {'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key': KEY} - def test_delete_experiment(self): - print "test_delete_experiment" + headers = {'Content-Type': 'application/json'} - payload = {'exp_name': 'Theory', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [], - 'key': KEY - } + response = self.client.post("/hosting_info", data=json.dumps(payload), + headers=headers) + payload = {'exp_name': 'stack', + 'exp_id': 'cse01', + 'overview' : 'overview', + 'sections' : ['Theory', 'Procedure'], + 'integration_level': 4, + 'inst_id': 'IITKgp', + 'dis_id': 'ece', + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}]} headers = {'Content-Type': 'application/json'} response = self.client.post("/experiments", data=json.dumps(payload), headers=headers) + + payload = {'integration_level': 3, + 'key': KEY + } + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/integration_status", data=json.dumps(payload), + headers=headers) + + payload1 = {'exp_name': 'queue', + 'overview' : 'overview', + 'sections' : ['Theory', 'Procedure'], + 'integration_level': 3, + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}]} - response = self.client.delete("/experiments?exp_id=exp123&key=defaultkey", - headers=headers) + headers = {'Content-Type': 'application/json'} + response = self.client.put("/experiments?exp_id=cse01", + data=json.dumps(payload1), + headers=headers) self.assertEqual(response.status_code, 200) - #+END_SRC + +#+END_SRC -** Update and Delete Section +** Update, Delete and Get Section by ID *** API Design **** Update section by id :PROPERTIES: @@ -5101,7 +7755,7 @@ class TestDeleteExperiment(TestCase): #+BEGIN_EXAMPLE { - "key" : "", "name" : "Quiz" } @@ -5128,7 +7782,6 @@ class TestDeleteExperiment(TestCase): http://localhost:5000/sections/1 #+END_EXAMPLE - **** Delete section by id :PROPERTIES: :CUSTOM_ID: delete_section_by_id @@ -5144,7 +7797,12 @@ http://localhost:5000/sections/1 - Success Response + Status_Code: 200 + Contents : - { "status" : "success" } +#+BEGIN_EXAMPLE +{ + "status": "sucess" +} + +#+END_EXAMPLE - Error Response: + Contents : @@ -5152,7 +7810,39 @@ http://localhost:5000/sections/1 - Example: #+BEGIN_EXAMPLE -http://localhost:5000/experiments/2 +http://localhost:5000/sections/2 +#+END_EXAMPLE + +**** Get section by id + :PROPERTIES: + :CUSTOM_ID: api_get_section_by_id + :END: + - URL :: /sections/ + + - Method :: GET + + - URL Params :: None + + - Payload :: + - Success Response + + Status_Code: 200 + + Contents : + +#+BEGIN_EXAMPLE +{ + "id": 1, + "name": "Theory" +} +#+END_EXAMPLE + + + - Error Response: + + Contents : + {"status" : "error"} + + - Example: +#+BEGIN_EXAMPLE +http://localhost:5000/sections/1 #+END_EXAMPLE *** Implementation @@ -5170,32 +7860,32 @@ def update_and_delete_section(id): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) if request.method == 'PUT': if request.is_json: @@ -5214,32 +7904,32 @@ def update_and_delete_section(id): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) if request.method == 'DELETE': @@ -5252,32 +7942,32 @@ def update_and_delete_section(id): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases **** TestUpdateSection @@ -5350,6 +8040,40 @@ class TestDeleteSection(TestCase): #+END_SRC +**** TestGetSectionById + #+NAME: test_get_section_by_id + #+BEGIN_SRC python +class TestGetSectionbyid(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_section_by_id(self): + print "test_get_section_by_id" + + payload = {'name': 'Theory', + 'key': KEY + } + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/sections", data=json.dumps(payload), + headers=headers) + + response = self.client.delete("/sections/1", headers=headers) + + self.assertEqual(response.status_code, 200) + + #+END_SRC + ** Update Institute *** API Design @@ -5357,7 +8081,7 @@ class TestDeleteSection(TestCase): :PROPERTIES: :CUSTOM_ID: api_update_institutes_by_instid :END: - - URL :: /institutes/ + - URL :: /institutes? - Method :: PUT @@ -5366,8 +8090,9 @@ class TestDeleteSection(TestCase): - Payload :: #+BEGIN_EXAMPLE { -"inst_name": "IIIT H", - "key": "" +"inst_name": "IIIT Hydfdfdd", +"key": "defaultkey", +"assets" : ["vlabs.ac.in/images/static/logo.png"] } #+END_EXAMPLE @@ -5412,39 +8137,39 @@ def update_institute(): try: institute = SystemInterface.update_institute(data_dict) - return jsonify(institute) + return jsonify(institute.to_client()) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -5468,11 +8193,18 @@ class TestUpdateInstitute(TestCase): def test_update_institute(self): print "test_update_institute" - payload = {'inst_name': 'IIT Kharagpur', - 'inst_id': 'IITKgp', + payload = {'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png', 'key': KEY} - payload1 = {'inst_name': 'IIT Kanpur', + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/assets", data=json.dumps(payload), + headers=headers) + + payload = {'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -5480,7 +8212,22 @@ class TestUpdateInstitute(TestCase): response = self.client.post("/institutes", data=json.dumps(payload), headers=headers) - response = self.client.put("/institutes?inst_id=IITKgp", data=json.dumps(payload1), + payload1 = {'asset_type': 'Video', + 'path': 'vlabs.ac.in/images/video/icon.png', + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/assets", data=json.dumps(payload1), + headers=headers) + + payload1 = {'inst_name': 'IIT Kharagpur', + 'assets': ['vlabs.ac.in/images/video/icon.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.put("/institutes?inst_id=IITK", data=json.dumps(payload1), headers=headers) self.assertEqual(response.status_code, 200) @@ -5518,7 +8265,7 @@ class TestUpdateInstitute(TestCase): - Example: #+BEGIN_EXAMPLE -http://localhost:5000/institutes?inst_id=iiith&key=defaultkey +http://localhost:5000/institutes?inst_id=iiith&key= #+END_EXAMPLE *** Implementation @@ -5540,32 +8287,32 @@ def delete_institute(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -5589,8 +8336,18 @@ class TestDeleteInstitute(TestCase): def test_delete_institute(self): print "test_delete_institute" + 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 = {'inst_name': 'IIT Kharagpur', 'inst_id': 'IITKgp', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -5621,7 +8378,8 @@ class TestDeleteInstitute(TestCase): - Payload :: #+BEGIN_EXAMPLE { -"dis_name": "Computer Science and Engineering", +"dis_name": "Auto Mobiles and Engineering", +"assets": ["vlabs.ac.in/images/static/logo.png"], "key": "" } #+END_EXAMPLE @@ -5629,10 +8387,17 @@ class TestDeleteInstitute(TestCase): + Status_Code: 200 + Contents : #+BEGIN_EXAMPLE - { - "dis_id": "cse", - "dis_name": "Computer Science and Engineering", - "id": 1 +{ + "assets": [ + { + "asset_type": "Image", + "id": 1, + "path": "vlabs.ac.in/images/static/logo.png" + } + ], + "dis_id": "ab", + "dis_name": "Auto Mobiles and Engineering", + "id": 15 } #+END_EXAMPLE @@ -5666,39 +8431,39 @@ def update_discipline(): try: discipline = SystemInterface.update_discipline(data_dict) - return jsonify(discipline) + return jsonify(discipline.to_client()) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -5721,24 +8486,41 @@ class TestUpdateDiscipline(TestCase): def test_update_discipline(self): print "test_update_discipline" + + 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 = {'dis_name': 'Computer Science', 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} - - payload1 = {'dis_name': 'Computer Science and Engineering', - 'key': KEY} - headers = {'Content-Type': 'application/json'} response = self.client.post("/disciplines", data=json.dumps(payload), headers=headers) - + + payload1 = {'asset_type': 'Video', + 'path': 'vlabs.ac.in/images/video/icon.png', + 'key': KEY} + + response = self.client.post("/assets", data=json.dumps(payload1), + headers=headers) + """ + payload1 = {'dis_name': 'Computer Science and Engineering', + 'assests' : [], + 'key': KEY} + response = self.client.put("/disciplines?dis_id=CSE", data=json.dumps(payload1), headers=headers) - + """ self.assertEqual(response.status_code, 200) - + #+END_SRC @@ -5778,7 +8560,7 @@ class TestUpdateDiscipline(TestCase): *** Implementation #+NAME: delete_discipline #+BEGIN_SRC python -@api.route('/disciplines', methods=['PUT', 'DELETE']) +@api.route('/disciplines', methods=['DELETE']) def delete_discipline(): if request.method == 'DELETE': if 'dis_id' in request.args and 'key' in request.args: @@ -5794,32 +8576,32 @@ def delete_discipline(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -5844,8 +8626,18 @@ class TestDeleteDiscipline(TestCase): def test_delete_discipline(self): print "test_delete_discipline" + 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 = {'dis_name': 'Computer Science', 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key': KEY} headers = {'Content-Type': 'application/json'} @@ -5861,13 +8653,13 @@ class TestDeleteDiscipline(TestCase): #+END_SRC -** Update HostingInfo +** Update Hosting_Info *** API Design -**** Update hostinginfos by hosted_url +**** Update hosting_info by hosted_url :PROPERTIES: - :CUSTOM_ID: update_hostinginfos_by_hosted_url + :CUSTOM_ID: update_hosting_info_by_hosted_url :END: - - URL :: /hostinginfos/ + - URL :: /hosting_info/ - Method :: PUT @@ -5902,14 +8694,14 @@ class TestDeleteDiscipline(TestCase): - Example: #+BEGIN_EXAMPLE - http://localhost:5000/hostinginfos?hosted_url=http://cse14-iiith.vlabs.ac.in + http://localhost:5000/hosting_info?hosted_url=http://cse14-iiith.vlabs.ac.in #+END_EXAMPLE *** Implementation -#+NAME: update_hostinginfo +#+NAME: update_hosting_info #+BEGIN_SRC python -@api.route('/hostinginfos', methods=['PUT']) -def update_hostinginfo(): +@api.route('/hosting_info', methods=['PUT']) +def update_hosting_info(): if request.method == 'PUT': if request.is_json: data_json = json.dumps(request.get_json()) @@ -5920,51 +8712,51 @@ def update_hostinginfo(): if 'hosted_url' in request.args: data_dict['hosted_url'] = request.args['hosted_url'] else: - abort(500, "Please provide the 'hosted_url' to update the hostinginfo") + abort(500, "Please provide the 'hosted_url' to update the hosting_info") try: - hostinginfo = SystemInterface.update_hostinginfo(data_dict) - return jsonify(hostinginfo) + hosting_info = SystemInterface.update_hosting_info(data_dict) + return jsonify(hosting_info) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases -**** TestUpdateHostingInfo - #+NAME: test_update_hostinginfo +**** TestUpdateHosting_Info + #+NAME: test_update_hosting_info #+BEGIN_SRC python -class TestUpdateHostingInfo(TestCase): +class TestUpdateHosting_Info(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -5977,8 +8769,8 @@ class TestUpdateHostingInfo(TestCase): db.session.remove() db.drop_all() - def test_update_hostinginfo(self): - print "test_update_hostinginfo" + def test_update_hosting_info(self): + print "test_update_hosting_info" payload = {'hosting_status': 'hosted', 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', @@ -5989,17 +8781,17 @@ class TestUpdateHostingInfo(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/hostinginfos", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), headers=headers) - response = self.client.put("/hostinginfos?hosted_url=http://cse14-iiith.vlabs.ac.in", data=json.dumps(payload1), + response = self.client.put("/hosting_info?hosted_url=http://cse14-iiith.vlabs.ac.in", data=json.dumps(payload1), headers=headers) self.assertEqual(response.status_code, 200) #+END_SRC - + ** Update Developer *** API Design **** Update developers by email_id @@ -6016,7 +8808,6 @@ class TestUpdateHostingInfo(TestCase): #+BEGIN_EXAMPLE { "dev_name": "Prof. Dharamraj", - "email_id": "dharamraj@gmail.com", "key": "" } @@ -6062,39 +8853,40 @@ def update_developer(): try: developer = SystemInterface.update_developer(data_dict) - return jsonify(developer) + + return jsonify(developer.to_client()) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -6118,9 +8910,59 @@ class TestUpdateDeveloper(TestCase): def test_update_developer(self): print "test_update_developer" + 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 = {'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/institutes", data=json.dumps(payload), + headers=headers) + + payload = {'dis_name': 'Computer Science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/disciplines", data=json.dumps(payload), + headers=headers) + payload = {'name': 'Prof.Dharamraj', 'email': 'dharamraj@gmail.com', - 'key': KEY} + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} + + payload1 = {'inst_name': 'IIT Kharagpur', + 'inst_id': 'IITKgp', + 'assets': ['vlabs.ac.in/images/video/icon.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/institutes", data=json.dumps(payload), + headers=headers) + + payload1 = {'dis_name': 'Electronics & Comuunication Engg.', + 'dis_id': 'ECE', + 'assets': ['vlabs.ac.in/images/video/icon.png'], + 'key': KEY} + + + response = self.client.post("/disciplines", data=json.dumps(payload), + headers=headers) payload1 = {'name': 'Prof.Raj', 'key': KEY} @@ -6138,13 +8980,13 @@ class TestUpdateDeveloper(TestCase): #+END_SRC -** Delete HostingInfo +** Delete Hosting_Info *** API Design -**** Delete hostinginfo by hosted_url +**** Delete hosting_info by hosted_url :PROPERTIES: - :CUSTOM_ID: delete_hostinginfo_by_hosted_url + :CUSTOM_ID: delete_hosting_info_by_hosted_url :END: - - URL :: /hostinginfos?&key= + - URL :: /hosting_info?&key= - Method :: DELETE @@ -6168,63 +9010,63 @@ class TestUpdateDeveloper(TestCase): - Example: #+BEGIN_EXAMPLE - http://localhost:5000/hostinginfos?hosted_url=http://cse14-iiith.vlabs.ac.in&key= + http://localhost:5000/hosting_info?hosted_url=http://cse14-iiith.vlabs.ac.in&key= #+END_EXAMPLE *** Implementation -#+NAME: delete_hostinginfo +#+NAME: delete_hosting_info #+BEGIN_SRC python -@api.route('/hostinginfos', methods=['DELETE']) -def delete_hostinginfo(): +@api.route('/hosting_info', methods=['DELETE']) +def delete_hosting_info(): if request.method == 'DELETE': if 'hosted_url' in request.args and 'key' in request.args: hosted_url = request.args['hosted_url'] key = request.args['key'] try: - hostinginfo = SystemInterface.delete_hostinginfo(hosted_url, key) - return jsonify({"status":"sucess"})(data_dict) + hosting_info = SystemInterface.delete_hosting_info(hosted_url, key) + return jsonify({"status":"sucess"}) except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases -**** TestDeleteHostingInfo - #+NAME: test_delete_hostinginfo +**** TestDeleteHosting_Info + #+NAME: test_delete_hosting_info #+BEGIN_SRC python -class TestDeleteHostingInfo(TestCase): +class TestDeleteHosting_Info(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -6237,8 +9079,8 @@ class TestDeleteHostingInfo(TestCase): db.session.remove() db.drop_all() - def test_delete_hostinginfo(self): - print "test_delete_hostinginfo" + def test_delete_hosting_info(self): + print "test_delete_hosting_info" payload = {'hosting_status': 'hosted', 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', @@ -6247,10 +9089,10 @@ class TestDeleteHostingInfo(TestCase): headers = {'Content-Type': 'application/json'} - response = self.client.post("/hostinginfos", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), headers=headers) - response = self.client.delete("/hostinginfos?hosted_url=http://cse14-iiith.vlabs.ac.in&key=defaultkey", + response = self.client.delete("/hosting_info?hosted_url=http://cse14-iiith.vlabs.ac.in&key=defaultkey", headers=headers) self.assertEqual(response.status_code, 200) @@ -6258,13 +9100,13 @@ class TestDeleteHostingInfo(TestCase): #+END_SRC -** Delete IntegrationStatus +** Delete Integration_Status *** API Design -**** Delete integrationstatus by integration_level +**** Delete integration_status by integration_level :PROPERTIES: - :CUSTOM_ID: api_delete_integrationstatus_by_integration_level + :CUSTOM_ID: api_delete_integration_status_by_integration_level :END: - - URL :: /integrationstatuss?&key= + - URL :: /integration_status?integration_level=&key= - Method :: DELETE @@ -6288,21 +9130,21 @@ class TestDeleteHostingInfo(TestCase): - Example: #+BEGIN_EXAMPLE - http://localhost:5000/integrationstatuss?integration_level=4&key= + http://localhost:5000/integration_status?integration_level=4&key= #+END_EXAMPLE *** Implementation -#+NAME: delete_integrationstatus +#+NAME: delete_integration_status #+BEGIN_SRC python -@api.route('/integrationstatuss', methods=['DELETE']) -def delete_integrationstatus(): +@api.route('/integration_status', methods=['DELETE']) +def delete_integration_status(): if request.method == 'DELETE': if 'integration_level' in request.args and 'key' in request.args: integration_level = request.args['integration_level'] key = request.args['key'] try: - integrationstatus = SystemInterface.delete_integrationstatus(integration_level, key) + integration_status = SystemInterface.delete_integration_status(integration_level, key) return jsonify({"status":"sucess"}) except NotAuthorizedError as e: @@ -6310,41 +9152,488 @@ def delete_integrationstatus(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC -*** Test Cases -**** TestDeleteIntegrationStatus - #+NAME: test_delete_integrationstatus +*** Test Cases +**** TestDeleteIntegration_Status + #+NAME: test_delete_integration_status + #+BEGIN_SRC python +class TestDeleteIntegration_Status(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_delete_integration_status(self): + print "test_delete_integration_status" + + payload = {'integration_level': 4, + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/integration_status", data=json.dumps(payload), + headers=headers) + + response = self.client.delete("/integration_status?integration_level=4&key=defaultkey", + headers=headers) + + self.assertEqual(response.status_code, 200) + + #+END_SRC + + +** Delete Email +*** API Design +**** Delete email + :PROPERTIES: + :CUSTOM_ID: delete_email_by_email + :END: + - URL :: /emails?&key= + + - Method :: DELETE + + - URL Params :: None + + - Payload :: + + - Success Response + + Status_Code: 200 + + Contents : +#+BEGIN_EXAMPLE +{ + "status": "sucess" +} + +#+END_EXAMPLE + + - Error Response: + + Contents : + {"status" : "error"} + + - Example: +#+BEGIN_EXAMPLE + http://localhost:5000/emails?email=dharamraj@gmail.com&key= +#+END_EXAMPLE + +*** Implementation +#+NAME: delete_email +#+BEGIN_SRC python +@api.route('/emails', methods=['DELETE']) +def delete_email(): + if request.method == 'DELETE': + if 'email' in request.args and 'key' in request.args: + email = request.args['email'] + key = request.args['key'] + + try: + email = SystemInterface.delete_email(email, key) + return jsonify({"status":"sucess"}) + except NotAuthorizedError as e: + err_str = str(e) + msg = {"status": "failure", + "status code": 401, + "msg": err_str} + abort(401, msg) + + except TypeError as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str } + abort(500, msg) + + except StateError as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str} + abort(500, msg) + + except NotFoundError as e: + err_str = str(e) + msg = {"status": "failure", + "status code": 404, + "msg": err_str} + abort(404, msg) + + except Exception as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str} + abort(500, msg) + +#+END_SRC + +*** Test Cases +**** TestDeleteEmail + #+NAME: test_delete_email + #+BEGIN_SRC python +class TestDeleteEmail(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_delete_email(self): + print "test_delete_email" + + payload = {'email': 'dharamraj@gmail.com', + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/emails", data=json.dumps(payload), + headers=headers) + + response = self.client.delete("/emails?email=dharamraj@gmail.com&key=defaultkey", + headers=headers) + + self.assertEqual(response.status_code, 200) + + #+END_SRC + + +** Update, Delete and Get Name by ID +*** API Design +**** Update name by id + :PROPERTIES: + :CUSTOM_ID: update_section_by_id + :END: + - URL :: /names/ + + - Method :: PUT + + - URL Params :: None + + - Payload :: +#+BEGIN_EXAMPLE + +{ + "key" : "", + "name" : "Prof. Dharamrajuuuu" +} + + +#+END_EXAMPLE + + - Success Response + + Status_Code: 200 + + Contents : +#+BEGIN_EXAMPLE +{ + "id": 1, + "name": "Prof. Dharamrajuuuu" +} +#+END_EXAMPLE + + - Error Response: + + Contents : + {"status" : "error"} + + + - Example: +#+BEGIN_EXAMPLE +http://localhost:5000/names/1 +#+END_EXAMPLE + +**** Delete name by id + :PROPERTIES: + :CUSTOM_ID: delete_section_by_id + :END: + - URL :: /names/ + + - Method :: DELETE + + - URL Params :: None + + - Payload :: + + - Success Response + + Status_Code: 200 + + Contents : + { "status" : "success" } + + - Error Response: + + Contents : + {"status" : "error"} + + - Example: +#+BEGIN_EXAMPLE +http://localhost:5000/names/2 +#+END_EXAMPLE + +**** Get name by id + :PROPERTIES: + :CUSTOM_ID: api_get_section_by_id + :END: + - URL :: /names/ + + - Method :: GET + + - URL Params :: None + + - Payload :: + - Success Response + + Status_Code: 200 + + Contents : + +#+BEGIN_EXAMPLE +{ + "id": 1, + "name" : "Prof. Dharamraj" +} +#+END_EXAMPLE + + + - Error Response: + + Contents : + {"status" : "error"} + + - Example: +#+BEGIN_EXAMPLE +http://localhost:5000/names/1 +#+END_EXAMPLE + +*** Implementation +#+NAME: update_and_delete_name +#+BEGIN_SRC python +@api.route('/names/', methods=['GET', 'PUT', 'DELETE']) +def update_and_delete_name(id): + if request.method == 'GET': + try: + name = SystemInterface.get_name_by_id(id) + return jsonify(name) + + except NotAuthorizedError as e: + err_str = str(e) + msg = {"status": "failure", + "status code": 401, + "msg": err_str} + abort(401, msg) + + except TypeError as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str } + abort(500, msg) + + except StateError as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str} + abort(500, msg) + + except NotFoundError as e: + err_str = str(e) + msg = {"status": "failure", + "status code": 404, + "msg": err_str} + abort(404, msg) + + except Exception as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str} + abort(500, msg) + + if request.method == 'PUT': + if request.is_json: + data_json = json.dumps(request.get_json()) + data_dict = yaml.safe_load(data_json) + data_dict['n_id']=id + else: + abort(500, "the request does not contain data in json") + + try: + name = SystemInterface.update_name(data_dict) + return jsonify(name) + + except NotAuthorizedError as e: + err_str = str(e) + msg = {"status": "failure", + "status code": 401, + "msg": err_str} + abort(401, msg) + + except TypeError as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str } + abort(500, msg) + + except StateError as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str} + abort(500, msg) + + except NotFoundError as e: + err_str = str(e) + msg = {"status": "failure", + "status code": 404, + "msg": err_str} + abort(404, msg) + + except Exception as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str} + abort(500, msg) + + if request.method == 'DELETE': + + try: + name = SystemInterface.delete_name(id) + return jsonify({"status":"sucess"}) + + except NotAuthorizedError as e: + err_str = str(e) + msg = {"status": "failure", + "status code": 401, + "msg": err_str} + abort(401, msg) + + except TypeError as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str } + abort(500, msg) + + except StateError as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str} + abort(500, msg) + + except NotFoundError as e: + err_str = str(e) + msg = {"status": "failure", + "status code": 404, + "msg": err_str} + abort(404, msg) + + except Exception as e: + err_str = str(e) + msg = {"status": "failure", + "msg": err_str} + abort(500, msg) +#+END_SRC +*** Test Cases +**** TestUpdateNameById + #+NAME: test_update_name_by_id + #+BEGIN_SRC python +class TestUpdateNameById(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_update_name_by_id(self): + print "test_update_name_by_id" + payload = {'name': 'Prof. Dharamraj', + 'key': KEY} + + payload1 = {'name': 'Prof. Dharamrajuuuu', + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/names", data=json.dumps(payload), + headers=headers) + + response = self.client.put("/names/1", data=json.dumps(payload1), + headers=headers) + + self.assertEqual(response.status_code, 200) + + #+END_SRC + +**** TestDeleteNameById + #+NAME: test_delete_name_by_id + #+BEGIN_SRC python +class TestDeleteNameById(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_delete_name_by_id(self): + print "test_delete_name_by_id" + + payload = {'name': 'Prof. Dharamraj', + 'key': KEY + } + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/names", data=json.dumps(payload), + headers=headers) + + response = self.client.delete("/names/1", headers=headers) + + self.assertEqual(response.status_code, 200) + + #+END_SRC + +**** TestGetNameById + #+NAME: test_get_name_by_id #+BEGIN_SRC python -class TestDeleteIntegrationStatus(TestCase): +class TestGetNamebyid(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -6357,32 +9646,32 @@ class TestDeleteIntegrationStatus(TestCase): db.session.remove() db.drop_all() - def test_delete_integrationstatus(self): - print "test_delete_integrationstatus" + def test_get_name_by_id(self): + print "test_get_name_by_id" - payload = {'integration_level': 4, - 'key': KEY} + payload = {'name': 'Prof. Dharamraj', + 'key': KEY + } headers = {'Content-Type': 'application/json'} - response = self.client.post("/integrationstatuss", data=json.dumps(payload), + response = self.client.post("/names", data=json.dumps(payload), headers=headers) - response = self.client.delete("/integrationstatuss?integration_level=4&key=defaultkey", - headers=headers) + response = self.client.delete("/names/1", headers=headers) self.assertEqual(response.status_code, 200) #+END_SRC - -** Delete Email + +** Delete Developer *** API Design -**** Delete email +**** Delete developer :PROPERTIES: - :CUSTOM_ID: delete_email_by_email + :CUSTOM_ID: delete_developer_by_email_id :END: - - URL :: /emails?&key= + - URL :: /developers?&key= - Method :: DELETE @@ -6406,61 +9695,62 @@ class TestDeleteIntegrationStatus(TestCase): - Example: #+BEGIN_EXAMPLE - http://localhost:5000/emails?email=dharamraj@gmail.com&key= + http://localhost:5000/developers?email_id=dharamraj@gmail.com&key= #+END_EXAMPLE *** Implementation -#+NAME: delete_email +#+NAME: delete_developer #+BEGIN_SRC python -@api.route('/emails', methods=['DELETE']) -def delete_email(): +@api.route('/developers', methods=['DELETE']) +def delete_developer(): if request.method == 'DELETE': if 'email' in request.args and 'key' in request.args: email = request.args['email'] key = request.args['key'] try: - email = SystemInterface.delete_email(email, key) + developer = SystemInterface.delete_developer(email, key) return jsonify({"status":"sucess"}) + except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases -**** TestDeleteEmail - #+NAME: test_delete_email +**** TestDeleteDeveloper + #+NAME: test_delete_developer #+BEGIN_SRC python -class TestDeleteEmail(TestCase): +class TestDeleteDeveloper(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -6473,18 +9763,50 @@ class TestDeleteEmail(TestCase): db.session.remove() db.drop_all() - def test_delete_email(self): - print "test_delete_email" + def test_delete_developer(self): + print "test_delete_developer" - payload = {'email': 'dharamraj@gmail.com', + payload = {'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png', 'key': KEY} headers = {'Content-Type': 'application/json'} - response = self.client.post("/emails", data=json.dumps(payload), + response = self.client.post("/assets", data=json.dumps(payload), headers=headers) - response = self.client.delete("/emails?email=dharamraj@gmail.com&key=defaultkey", + payload = {'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/institutes", data=json.dumps(payload), + headers=headers) + + payload = {'dis_name': 'Computer Science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/disciplines", data=json.dumps(payload), + headers=headers) + + payload = {'name': 'Prof. Dharamraj', + 'email': 'dharamraj@gmail.com', + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} + + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/developers", data=json.dumps(payload), + headers=headers) + + response = self.client.delete("/developers?email=dharamraj@gmail.com&key=defaultkey", headers=headers) self.assertEqual(response.status_code, 200) @@ -6492,13 +9814,13 @@ class TestDeleteEmail(TestCase): #+END_SRC -** Delete Name +** Delete Experiment *** API Design -**** Delete name +**** Delete experiment by exp_id :PROPERTIES: - :CUSTOM_ID: delete_name_by_name + :CUSTOM_ID: api_delete_experiment_by_exp_id :END: - - URL :: /names?&key= + - URL :: /experiments?exp_id=&key= - Method :: DELETE @@ -6522,63 +9844,61 @@ class TestDeleteEmail(TestCase): - Example: #+BEGIN_EXAMPLE - http://localhost:5000/names?name=prof.dharamraj&key= +http://localhost:5000/experiments/2 #+END_EXAMPLE *** Implementation -#+NAME: delete_name +#+NAME: delete_experiment #+BEGIN_SRC python -@api.route('/names', methods=['DELETE']) -def delete_name(): +@api.route('/experiments', methods=['DELETE']) +def delete_experiment(): if request.method == 'DELETE': - if 'name' in request.args and 'key' in request.args: - name = request.args['name'] + if 'exp_id' in request.args and 'key' in request.args: + exp_id = request.args['exp_id'] key = request.args['key'] - try: - name = SystemInterface.delete_name(name, key) + exp_id = SystemInterface.delete_experiment(exp_id, key) return jsonify({"status":"sucess"}) - + except NotAuthorizedError as e: err_str = str(e) msg = {"status": "failure", "status code": 401, - "msg": err_str} - return jsonify(msg) + "msg": err_str} + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, - "msg": err_str} - return jsonify(msg) + "msg": err_str} + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC - *** Test Cases -**** TestDeleteName - #+NAME: test_delete_name +**** TestDeleteExperiment + #+NAME: test_delete_experiment #+BEGIN_SRC python -class TestDeleteName(TestCase): +class TestDeleteExperiment(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -6591,138 +9911,96 @@ class TestDeleteName(TestCase): db.session.remove() db.drop_all() - def test_delete_name(self): - print "test_delete_name" + def test_delete_experiment(self): + print "test_delete_experiment" - payload = {'name': 'prof.dharamraj', + payload = {'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png', 'key': KEY} - headers = {'Content-Type': 'application/json'} - response = self.client.post("/names", data=json.dumps(payload), - headers=headers) - - response = self.client.delete("/names?name=prof.dharamraj&key=defaultkey", - headers=headers) - - self.assertEqual(response.status_code, 200) - - #+END_SRC - - -** Delete Developer -*** API Design -**** Delete developer - :PROPERTIES: - :CUSTOM_ID: delete_developer_by_email_id - :END: - - URL :: /developers?&key= - - - Method :: DELETE - - - URL Params :: None - - - Payload :: - - - Success Response - + Status_Code: 200 - + Contents : -#+BEGIN_EXAMPLE -{ - "status": "sucess" -} - -#+END_EXAMPLE - - - Error Response: - + Contents : - {"status" : "error"} - - - Example: -#+BEGIN_EXAMPLE - http://localhost:5000/developers?email_id=dharamraj@gmail.com&key= -#+END_EXAMPLE - -*** Implementation -#+NAME: delete_developer -#+BEGIN_SRC python -@api.route('/developers', methods=['DELETE']) -def delete_developer(): - if request.method == 'DELETE': - if 'email' in request.args and 'key' in request.args: - email = request.args['email'] - key = request.args['key'] + response = self.client.post("/assets", data=json.dumps(payload), + headers=headers) - try: - developer = SystemInterface.delete_developer(email, key) - return jsonify({"status":"sucess"}) + payload = {'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} - except NotAuthorizedError as e: - err_str = str(e) - msg = {"status": "failure", - "status code": 401, - "msg": err_str} - return jsonify(msg) + headers = {'Content-Type': 'application/json'} - except TypeError as e: - err_str = str(e) - msg = {"status": "failure", - "msg": err_str } - return jsonify(msg) + response = self.client.post("/institutes", data=json.dumps(payload), + headers=headers) - except StateError as e: - err_str = str(e) - msg = {"status": "failure", - "msg": err_str} - return jsonify(msg) + payload = {'dis_name': 'Computer Science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key': KEY} - except NotFoundError as e: - err_str = str(e) - msg = {"status": "failure", - "status code": 404, - "msg": err_str} - return jsonify(msg) + headers = {'Content-Type': 'application/json'} - except Exception as e: - err_str = str(e) - msg = {"status": "failure", - "msg": err_str} - return jsonify(msg) + response = self.client.post("/disciplines", data=json.dumps(payload), + headers=headers) -#+END_SRC + payload = {'integration_level': 4, + 'key': KEY + } + headers = {'Content-Type': 'application/json'} -*** Test Cases -**** TestDeleteDeveloper - #+NAME: test_delete_developer - #+BEGIN_SRC python -class TestDeleteDeveloper(TestCase): - TESTING = True - def create_app(self): - app = create_app(config) - return app + response = self.client.post("/integration_status", data=json.dumps(payload), + headers=headers) - def setUp(self): - db.create_all() + payload = {'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE'} - def tearDown(self): - db.session.remove() - db.drop_all() + headers = {'Content-Type': 'application/json'} - def test_delete_developer(self): - print "test_delete_developer" + response = self.client.post("/developers", data=json.dumps(payload), + headers=headers) - payload = {'name': 'Prof. Dharamraj', - 'email': 'dharamraj@gmail.com', + 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("/developers", data=json.dumps(payload), + response = self.client.post("/hosting_info", data=json.dumps(payload), headers=headers) - response = self.client.delete("/developers?email=dharamraj@gmail.com&key=defaultkey", - headers=headers) + payload = {'exp_name': 'stack', + 'exp_id': 'cse01', + 'overview' : 'overview', + 'sections' : [], + 'integration_level': 4, + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'key': KEY, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}]} + headers = {'Content-Type': 'application/json'} + + response = self.client.post("/experiments", data=json.dumps(payload), + headers=headers) + response = self.client.get("/experiments", headers=headers) self.assertEqual(response.status_code, 200) #+END_SRC @@ -6747,7 +10025,13 @@ class TestDeleteDeveloper(TestCase): + Contents : #+BEGIN_EXAMPLE -[{"asset_type": "Image", "id": 1, "path": "vlabs.ac.in/images/static/logo.png"}] +[ + { + "path": "vlabs.ac.in/images/static/logo.png", + "asset_type": "Image", + "id": 1 + } +] #+END_EXAMPLE @@ -6777,7 +10061,11 @@ http://localhost:5000/assets + Contents : #+BEGIN_EXAMPLE -{"asset_type": "Image", "id": 1, "path": "vlabs.ac.in/images/static/logo.png"} +{ + "asset_type": "Image", + "id": 3, + "path": "vlabs.ac.in/images/static/icon.png" +} #+END_EXAMPLE @@ -6800,33 +10088,33 @@ def get_asset(): if 'path' in request.args: path = request.args['path'] try: - asset = SystemInterface.get_asset(path) + asset = SystemInterface.get_asset_by_path(path) return jsonify(asset) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) else: try: assets = SystemInterface.get_assets() @@ -6836,26 +10124,26 @@ def get_asset(): err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC *** Test Cases @@ -6941,7 +10229,7 @@ class TestGetAsset(TestCase): - Payload :: #+BEGIN_EXAMPLE -{ + { "path": "vlabs.ac.in/images/static/logo.png", "asset_type": "Image", "key": "" @@ -6991,32 +10279,32 @@ def add_asset(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -7121,32 +10409,32 @@ def update_asset(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -7242,32 +10530,32 @@ def delete_asset(): msg = {"status": "failure", "status code": 401, "msg": err_str} - return jsonify(msg) + abort(401, msg) except TypeError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str } - return jsonify(msg) + abort(500, msg) except StateError as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) except NotFoundError as e: err_str = str(e) msg = {"status": "failure", "status code": 404, "msg": err_str} - return jsonify(msg) + abort(404, msg) except Exception as e: err_str = str(e) msg = {"status": "failure", "msg": err_str} - return jsonify(msg) + abort(500, msg) #+END_SRC @@ -7309,7 +10597,6 @@ class TestDeleteAsset(TestCase): #+END_SRC - * Infra :boilerplate: ** sources @@ -7378,7 +10665,7 @@ if __name__ == '__main__': <> <> <> -<> +<> <> <> <> @@ -7386,13 +10673,13 @@ if __name__ == '__main__': <> <> <> -<> -<> -<> -<> -<> -<> -<> +<> +<> +<> +<> +<> +<> +<> <> <> <> @@ -7400,13 +10687,14 @@ if __name__ == '__main__': <> <> <> -<> +<> <> <> <> <> <> <> +<> #+END_SRC @@ -7434,12 +10722,12 @@ if __name__ == '__main__': <> <> <> -<> +<> <> -<> +<> <> -<> -<> +<> +<> <> <> <> @@ -7453,17 +10741,20 @@ if __name__ == '__main__': <> <> <> -<> -<> -<> -<> -<> -<> -<> +<> +<> +<> +<> +<> +<> +<> <> <> <> <> <> +<> +<> +<> <> #+end_src diff --git a/src/runtime/system/persistence-delegate.org b/src/runtime/system/persistence-delegate.org index b482c75..6060a48 100755 --- a/src/runtime/system/persistence-delegate.org +++ b/src/runtime/system/persistence-delegate.org @@ -29,9 +29,9 @@ class PersistenceDelegate(): 'section' : Section, 'institute' : Institute, 'discipline' : Discipline, - 'hostinginfo': HostingInfo, + 'hosting_info': HostingInfo, 'asset' : Asset, - 'integrationstatus': IntegrationStatus, + 'integration_status': IntegrationStatus, 'name' : Name, 'email' : Email, 'developer' : Developer @@ -67,7 +67,7 @@ class TestPersistenceDelegate(TestCase): Other functions that help =System= perform the operations. -*** Check if entity already exists +*** Check if entity already exists The following three functions checks whether the given entity exists or not. To optimize the code, apply the following three principles: @@ -102,7 +102,11 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_lab_exists #+BEGIN_SRC python def lab_exists(self, lab): + current_app.logger.debug("running check on the existence of" + " lab = %s" % lab) lab_id = lab.get("lab_id") + current_app.logger.debug("completed check on the existence of" + " lab with lab_id = %s" % lab_id) return lab == self.get_lab(lab_id=lab_id) #+END_SRC @@ -116,43 +120,47 @@ class TestPersistenceDelegate(TestCase): lab_id1="CSE01" overview1 = "overview" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id,\ + assets=[asset]) discipline.save() integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() + integration_status = IntegrationStatus(integration_level=\ + integration_level) + integration_status.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = Asset(asset_type=asset_type, path=path) - asset.save() - dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" host = HostingInfo(hosting_status=hosting_status, - hosted_url=hosted_url, hosted_on=hosted_on) + hosted_url=hosted_url, + hosted_on=hosted_on) host.save() lab = Lab(lab_name=lab_name1, lab_id=lab_id1, overview=overview1, institute=inst, discipline=discipline, assets=[asset], - experiments=[], integrationstatus=integrationstatus, - developers=[dev], hostinginfo=host) + experiments=[], integration_status=integration_status, + developers=[dev], hosting_info=[host]) lab1 = self.persistence_delegate.add_lab(lab) @@ -160,9 +168,9 @@ class TestPersistenceDelegate(TestCase): lab_id2="CSE02" overview2 = "overview" lab2 = Lab(lab_name=lab_name2, lab_id=lab_id2, overview=overview2, - integrationstatus=integrationstatus, - institute=inst, discipline=discipline, assets=[asset], - experiments=[], developers=[dev], hostinginfo=host) + integration_status=integration_status, + institute=inst, discipline=discipline, assets=[asset], + experiments=[], developers=[dev], hosting_info=[host]) self.assertEqual(self.persistence_delegate.lab_exists(lab1), True) @@ -178,7 +186,11 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_experiment_exists #+BEGIN_SRC python def experiment_exists(self, experiment): + current_app.logger.debug("running check on the existence of" + " experiment = %s" % experiment) exp_id = experiment.get("exp_id") + current_app.logger.debug("completed check on the existence of" + " experiment with exp_id = %s" % exp_id) return experiment == self.get_experiment(exp_id=exp_id) #+END_SRC @@ -188,19 +200,65 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_experiment_exists(self): print "test_experiment_exists" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id,\ + assets=[asset]) + discipline.save() + + dev_name = Name(name="Mohit Tahiliani") + dev_name.save() + email_id = Email(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, hosted_on=hosted_on) + host.save() + exp_name1 = "Number Systems" exp_id1 = "EE99777" overview1 = "overview" + + integration_level = 4 + integration_status = IntegrationStatus(integration_level=\ + integration_level) + integration_status.save() + experiment1 = Experiment(exp_name=exp_name1, exp_id=exp_id1, - overview=overview1, sections=[]) + overview=overview1, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], developers=[dev], + hosting_info=[host]) + exp1 = self.persistence_delegate.add_experiment(experiment1) exp_name2 = "Transformations" exp_id2 = "EE98747" overview2 = "overview" experiment2 = Experiment(exp_name=exp_name2, exp_id=exp_id2, \ - overview=overview2, sections=[]) - + overview=overview2, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], developers=[dev], + hosting_info=[host]) self.assertEqual(self.persistence_delegate.experiment_exists\ (experiment1), True) self.assertEqual(self.persistence_delegate.experiment_exists\ @@ -215,7 +273,11 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_section_exists #+BEGIN_SRC python def section_exists(self, section): + current_app.logger.debug("running check on the existence of" + " section = %s" % section) name = section.get("name") + current_app.logger.debug("completed check on the existence of" + " section with name = %s" % name) return section == self.get_section(name=name) #+END_SRC @@ -243,7 +305,11 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_institute_exists #+BEGIN_SRC python def institute_exists(self, institute): + current_app.logger.debug("running check on the existence of" + " institute = %s" % institute) inst_id = institute.get("inst_id") + current_app.logger.debug("completed check on the existence of" + " institute with inst_id = %s" % inst_id) return institute == self.get_institute(inst_id=inst_id) #+END_SRC @@ -253,14 +319,22 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_institute_exists(self): print "test_institute_exists" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name1 = "IIT Kanpur" inst_id1 = "IITK" - institute1 = Institute(inst_name=inst_name1, inst_id=inst_id1) + institute1 = Institute(inst_name=inst_name1, inst_id=inst_id1, + assets=[asset]) inst1 = self.persistence_delegate.add_institute(institute1) inst_name2 = "IIT Kharagpur" inst_id2 = "IITKgp" - institute2 = Institute(inst_name=inst_name2, inst_id=inst_id2) + institute2 = Institute(inst_name=inst_name2, inst_id=inst_id2, + assets=[asset]) self.assertEqual(self.persistence_delegate.institute_exists\ (institute1), True) @@ -278,9 +352,12 @@ class TestPersistenceDelegate(TestCase): def name_exists(self, name): ret_val = False try: + current_app.logger.debug("running check on the existence of name") if self.get_name(name=name.get("name")) is not None: ret_val = True + current_app.logger.debug("completed check on the existence of name") except Exception as e: + current_app.logger.error("Error in returning the name") pass return ret_val @@ -311,9 +388,12 @@ class TestPersistenceDelegate(TestCase): def email_exists(self, email): ret_val = False try: + current_app.logger.debug("running check on the existence of email") if self.get_email(email=email.get("email")) is not None: ret_val = True + current_app.logger.debug("completed check on the existence of email") except Exception as e: + current_app.logger.error("Error in returning the email") pass return ret_val @@ -343,9 +423,14 @@ class TestPersistenceDelegate(TestCase): def developer_exists(self, developer): ret_val = False try: + current_app.logger.debug("running check on the existence of" + " developer") if self.get_developer(email=developer.get("email")) is not None: ret_val = True + current_app.logger.debug("completed check on the existence of" + " developer") except Exception as e: + current_app.logger.error("Error in returning the developer") pass return ret_val @@ -357,31 +442,57 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_developer_exists(self): print "test_developer_exists" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id,\ + assets=[asset]) + discipline.save() + dev_name1 = Name(name="Prof. Dharmaraj") dev_name1.save() email_id1 = Email(email="abc@gmail.com") email_id1.save() - developer1 = Developer(name=dev_name1, email=email_id1) + developer1 = Developer(name=dev_name1, email=email_id1, + institute=inst, discipline=discipline) developer1.save() dev_name2 = Name(name="Prof. Raja") dev_name2.save() email_id2 = Email(email="xyz@gmail.com") email_id2.save() - developer2 = Developer(name=dev_name2, email=email_id2) + developer2 = Developer(name=dev_name2, email=email_id2, + institute=inst, discipline=discipline) - self.assertEqual(self.persistence_delegate.developer_exists(developer1), True) + self.assertEqual(self.persistence_delegate.\ + developer_exists(developer1), True) self.assertEqual(self.persistence_delegate.developer_exists\ (developer2), False) #+END_SRC -*** Check if =Discipline= already exists +*** Check if =Discipline= already exists This function checks if a discipline is already in the discipline-set of the =System=. #+NAME: persistence_discipline_exists #+BEGIN_SRC python def discipline_exists(self, discipline): + current_app.logger.debug("running check on the existence of" + " discipline = %s" % + discipline.to_client()) dis_id = discipline.get("dis_id") + current_app.logger.debug("completed check on the existence of" + " discipline with dis_id = %s" + % dis_id) return discipline == self.get_discipline(dis_id=dis_id) #+END_SRC @@ -392,15 +503,23 @@ class TestPersistenceDelegate(TestCase): def test_discipline_exists(self): print "test_discipline_exists" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + dis_name1="IIT Delhi" dis_id1="EEE08" - dis = Discipline(dis_name=dis_name1, dis_id=dis_id1) + dis = Discipline(dis_name=dis_name1, dis_id=dis_id1, + assets=[asset]) dis1 = self.persistence_delegate.add_discipline(dis) dis_name2="IIT Delhi" dis_id2="EEE09" - dis2 = Discipline(dis_name=dis_name2, dis_id=dis_id2) + dis2 = Discipline(dis_name=dis_name2, dis_id=dis_id2, + assets=[asset]) self.assertEqual(self.persistence_delegate.discipline_exists(dis1), True) @@ -412,36 +531,46 @@ class TestPersistenceDelegate(TestCase): #+END_SRC -*** Check if =hostinginfo= already exists - This function checks if an hostinginfo is already in the hostinginfo-set of the =System=. -#+NAME: persistence_hostinginfo_exists -#+BEGIN_SRC python - def hostinginfo_exists(self, hostinginfo): - hosted_url = str(hostinginfo.get("hosted_url")) - return hostinginfo == self.get_hostinginfo(hosted_url=hosted_url) - +*** Check if =hosting_info= already exists + This function checks if an hosting_info is already in the hosting_info-set of the =System=. +#+NAME: persistence_hosting_info_exists +#+BEGIN_SRC python + def hosting_info_exists(self, hosting_info): + current_app.logger.debug("running check on the existence of" + " hosting_info = %s" % + hosting_info.to_client()) + hosted_url = hosting_info.get("hosted_url") + current_app.logger.debug("completed check on the existence of" + " hosting_info with hosted_url = %s" + % hosted_url) + return hosting_info == self.get_hosting_info(hosted_url=hosted_url) + #+END_SRC **** Tests -#+NAME: test_persistence_hostinginfo_exists +#+NAME: test_persistence_hosting_info_exists #+BEGIN_SRC python - def test_hostinginfo_exists(self): - print "test_hostinginfo_exists" + def test_hosting_info_exists(self): + print "test_hosting_info_exists" hosting_status1 = "hosted" hosted_url1 = "http://cse14-iiith.vlabs.ac.in" hosted_on1 = "cloud" - hostinginfo1 = HostingInfo(hosting_status=hosting_status1, hosted_url=hosted_url1, hosted_on=hosted_on1) - host1 = self.persistence_delegate.add_hostinginfo(hostinginfo1) + hosting_info1 = HostingInfo(hosting_status=hosting_status1,\ + hosted_url=hosted_url1,\ + hosted_on=hosted_on1) + host1 = self.persistence_delegate.add_hosting_info(hosting_info1) hosting_status2 = "not hosted" hosted_url2 = "http://iitkgp.vlab.co.in/" hosted_on2 = "server" - hostinginfo2 = HostingInfo(hosting_status=hosting_status2, hosted_url=hosted_url2, hosted_on=hosted_on2) + hosting_info2 = HostingInfo(hosting_status=hosting_status2,\ + hosted_url=hosted_url2,\ + hosted_on=hosted_on2) - self.assertEqual(self.persistence_delegate.hostinginfo_exists\ - (hostinginfo1), True) - self.assertEqual(self.persistence_delegate.hostinginfo_exists\ - (hostinginfo2), False) + self.assertEqual(self.persistence_delegate.hosting_info_exists\ + (hosting_info1), True) + self.assertEqual(self.persistence_delegate.hosting_info_exists\ + (hosting_info2), False) #+END_SRC @@ -452,15 +581,21 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_asset_exists #+BEGIN_SRC python def asset_exists(self, asset): + current_app.logger.debug("running check on the existence of" + " asset = %s" % asset.to_client()) path = asset.get("path") + current_app.logger.debug("completed check on the existence of" + " asset with path = %s" % path) return asset == self.get_asset(path=path) + #+END_SRC **** Tests #+NAME: test_persistence_asset_exists #+BEGIN_SRC python def test_asset_exists(self): - print "test_asset_exists" + print "test_asset_exists" + asset_type1 = "Image" path1 = "vlabs.ac.in/static/images/logo.png" asset1 = Asset(asset_type=asset_type1, path=path1) @@ -477,42 +612,58 @@ class TestPersistenceDelegate(TestCase): #+END_SRC -*** Check if =integrationstatus= already exists - This function checks if an integrationstatus is already in the integrationstatus-set of the =System=. -#+NAME: persistence_integrationstatus_exists +*** Check if =integration_status= already exists + This function checks if an integration_status is already in the integration_status-set of the =System=. +#+NAME: persistence_integration_status_exists #+BEGIN_SRC python - def integrationstatus_exists(self, integrationstatus): - integration_level = integrationstatus.get("integration_level") - return integrationstatus == self.get_integrationstatus(integration_level=integration_level) + def integration_status_exists(self, integration_status): + current_app.logger.debug("running check on the existence of" + " integration_status = %s" + % integration_status.to_client()) + integration_level = integration_status.get("integration_level") + + current_app.logger.debug("completed check on the existence of" + " integration_status" + " with integration_level = %s" % + integration_level) + return integration_status == self.get_integration_status( + integration_level=integration_level) #+END_SRC **** Tests -#+NAME: test_persistence_integrationstatus_exists +#+NAME: test_persistence_integration_status_exists #+BEGIN_SRC python - def test_integrationstatus_exists(self): - print "test_integrationstatus_exists" + def test_integration_status_exists(self): + print "test_integration_status_exists" integration_level1 = 4 - integrationstatus1 = IntegrationStatus(integration_level=integration_level1) - intstatus1 = self.persistence_delegate.add_integrationstatus(integrationstatus1) + integration_status1 = IntegrationStatus(integration_level=\ + integration_level1) + intstatus1 = self.persistence_delegate.add_integration_status\ + (integration_status1) integration_level2 = 2 - integrationstatus2 = IntegrationStatus(integration_level=integration_level2) + integration_status2 = IntegrationStatus(integration_level=\ + integration_level2) - self.assertEqual(self.persistence_delegate.integrationstatus_exists\ - (integrationstatus1), True) - self.assertEqual(self.persistence_delegate.integrationstatus_exists\ - (integrationstatus2), False) + self.assertEqual(self.persistence_delegate.integration_status_exists\ + (integration_status1), True) + self.assertEqual(self.persistence_delegate.integration_status_exists\ + (integration_status2), False) #+END_SRC -*** Add lab to the system +*** Add lab to the system This function adds lab to the system. #+NAME: persistence_add_lab #+BEGIN_SRC python def add_lab(self, lab): + current_app.logger.debug("running add lab to system operation" + " lab = %s" % lab.to_client()) lab.save() + current_app.logger.debug("completed add lab to system operation" + " lab = %s" % lab.to_client()) return lab #+END_SRC @@ -522,53 +673,64 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_add_lab(self): print "test_add_lab" - exp_name = "Number Systems" - exp_id = "EE99777" - overview = "exp" - experiment = Experiment(exp_name=exp_name, exp_id=exp_id, \ - overview=overview, sections=[]) - experiment.save() - + integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() + integration_status = IntegrationStatus(integration_level=\ + integration_level) + integration_status.save() + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id,\ + assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id,\ + assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = Asset(asset_type=asset_type, path=path) - asset.save() - dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status,\ + hosted_url=hosted_url, hosted_on=hosted_on) host.save() + exp_name = "Number Systems" + exp_id = "EE99777" + overview = "exp" + experiment = Experiment(exp_name=exp_name, exp_id=exp_id, \ + overview=overview, institute=inst, + discipline=discipline, + integration_status=integration_status, + sections=[], assets=[asset], + developers=[dev], hosting_info=[host]) + experiment.save() + lab_name1="Computer Programming" lab_id1="CSE01" overview="lab" lab1 = Lab(lab_name=lab_name1, lab_id=lab_id1, \ - institute=inst, discipline=discipline, assets=[asset], \ - overview=overview, experiments=[experiment], \ - integrationstatus=integrationstatus, developers=[dev], - hostinginfo=host) + institute=inst, discipline=discipline,\ + assets=[asset], overview=overview,\ + experiments=[experiment], \ + integration_status=integration_status,\ + developers=[dev], hosting_info=[host]) lab1 = self.persistence_delegate.add_lab(lab1) @@ -578,8 +740,8 @@ class TestPersistenceDelegate(TestCase): lab2 = Lab(lab_name=lab_name2, lab_id=lab_id2, overview=overview, institute=inst, discipline=discipline, assets=[asset], - experiments=[], integrationstatus=integrationstatus, - developers=[dev], hostinginfo=host) + experiments=[], integration_status=integration_status, + developers=[dev], hosting_info=[host]) self.assertEqual(self.persistence_delegate.lab_exists(lab1), True) @@ -589,13 +751,17 @@ class TestPersistenceDelegate(TestCase): #+END_SRC -*** Add experiment to the system +*** Add experiment to the system This function adds experiment to the system. #+NAME: persistence_add_experiment #+BEGIN_SRC python def add_experiment(self, experiment): + current_app.logger.debug("running add experiment to system operation" + " experiment = %s" % experiment.to_client()) experiment.save() + current_app.logger.debug("completed add experiment to system operation" + " experiment = %s" % experiment.to_client()) return experiment #+END_SRC @@ -605,35 +771,87 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_add_experiment(self): print "test_add_experiment" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + + dev_name = Name(name="Mohit Tahiliani") + dev_name.save() + email_id = Email(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) + host.save() + + integration_level = 4 + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() + exp_name1 = "Number Systems" exp_id1 = "EE99777" overview1 = "overview" experiment1 = Experiment(exp_name=exp_name1, exp_id=exp_id1, - overview=overview1, sections=[]) + overview=overview1, institute=inst, + discipline=discipline, + integration_status=integration_status, + sections=[], assets=[asset], + developers=[dev], hosting_info=[host]) experiment1 = self.persistence_delegate.add_experiment(experiment1) + experiment1.save() exp_name2="Transformations" - exp_id2="EE99870" + exp_id2="EE98747" overview2="overview" experiment2 = Experiment(exp_name=exp_name2, exp_id=exp_id2, - overview=overview2, sections=[]) - + overview=overview2, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], developers=[dev], + hosting_info=[host]) experiment = Experiment.get_by_id(1) - self.assertEqual(self.persistence_delegate.experiment_exists(experiment1), + self.assertEqual(self.persistence_delegate. + experiment_exists(experiment1), True) - self.assertEqual(self.persistence_delegate.experiment_exists(experiment2), + self.assertEqual(self.persistence_delegate. + experiment_exists(experiment2), False) #+END_SRC -*** Add discipline to the system +*** Add discipline to the system This function adds discipline to the system. #+NAME: persistence_add_discipline #+BEGIN_SRC python def add_discipline(self, discipline): + current_app.logger.debug("running add discipline to system operation" + " discipline = %s" % discipline.to_client()) discipline.save() + current_app.logger.debug("completed add discipline to system operation" + " discipline = %s" % discipline.to_client()) return discipline #+END_SRC @@ -643,11 +861,20 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_add_discipline(self): print "test_add_discipline" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + dis_name = "IIT Delhi" dis_id = "EEE08" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) discipline = self.persistence_delegate.add_discipline(discipline) + discipline = discipline.get_by_id(1) + self.assertEqual(discipline.get("dis_name"), dis_name) self.assertEqual(discipline.get("dis_id"), dis_id) @@ -655,12 +882,16 @@ class TestPersistenceDelegate(TestCase): -*** Add section to the system +*** Add section to the system This function adds section to the system. #+NAME: persistence_add_section #+BEGIN_SRC python def add_section(self, section): + current_app.logger.debug("running add section to system operation" + " section = %s" % section.to_client()) section.save() + current_app.logger.debug("completed add section to system operation" + " section = %s" % section.to_client()) return section #+END_SRC @@ -680,12 +911,16 @@ class TestPersistenceDelegate(TestCase): #+END_SRC -*** Add name to the system +*** Add name to the system This function adds name to the system. #+NAME: persistence_add_name #+BEGIN_SRC python def add_name(self, name): + current_app.logger.debug("running add name to system operation" + " name = %s" % name.to_client()) name.save() + current_app.logger.debug("completed add name to system operation" + " name = %s" % name.to_client()) return name #+END_SRC @@ -705,12 +940,16 @@ class TestPersistenceDelegate(TestCase): #+END_SRC -*** Add email to the system +*** Add email to the system This function adds email to the system. #+NAME: persistence_add_email #+BEGIN_SRC python def add_email(self, email): + current_app.logger.debug("running add email to system operation" + " email = %s" % email.to_client()) email.save() + current_app.logger.debug("completed add email to system operation" + " email = %s" % email.to_client()) return email #+END_SRC @@ -730,18 +969,34 @@ class TestPersistenceDelegate(TestCase): #+END_SRC -*** Add developer to the system +*** Add developer to the system This function adds developer to the system. #+NAME: persistence_add_developer #+BEGIN_SRC python def add_developer(self, developer): + current_app.logger.debug("running add developer to system" + " developer = %s" % developer.to_client()) name = developer.get("name") + current_app.logger.debug("running add developer to system" + " with name = %s" % name) email = developer.get("email") + current_app.logger.debug("running add developer to system" + " with email = %s" % email) + if not self.name_exists(name.get("name")): name.save() + current_app.logger.debug("completed add operation" + " to system with developer" + " name = %s" % name) if not self.email_exists(email.get("email")): email.save() + current_app.logger.debug("completed add operation" + " to system with developer" + " email = %s" % email) developer.save() + + current_app.logger.debug("completed add developer" + " operation = %s" % developer.to_client()) return developer #+END_SRC @@ -751,11 +1006,29 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_add_developer(self): print "test_add_developer" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + dev_name = Name(name="Prof. S. Dharmaraja") dev_name.save() email = Email(email="dharmar@maths.iitd.ac.in") email.save() - dev = Developer(name=dev_name, email=email) + dev = Developer(name=dev_name, email=email, + institute=inst, discipline=discipline) dev = self.persistence_delegate.add_developer(dev) self.assertEqual(self.persistence_delegate.developer_exists(dev), @@ -763,10 +1036,28 @@ class TestPersistenceDelegate(TestCase): def test_add_developer_without_saving_name(self): print "test_add_developer_without_saving_name" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + dev_name = Name(name="Prof. S. Dharmaraja") email = Email(email="dharmar@maths.iitd.ac.in") email.save() - dev = Developer(name=dev_name, email=email) + dev = Developer(name=dev_name, email=email, + institute=inst, discipline=discipline) dev = self.persistence_delegate.add_developer(dev) self.assertEqual(self.persistence_delegate.developer_exists(dev), @@ -774,10 +1065,28 @@ class TestPersistenceDelegate(TestCase): def test_add_developer_without_saving_email(self): print "test_add_developer_without_saving_email" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + dev_name = Name(name="Prof. S. Dharmaraja") dev_name.save() email = Email(email="dharmar@maths.iitd.ac.in") - dev = Developer(name=dev_name, email=email) + dev = Developer(name=dev_name, email=email, + institute=inst, discipline=discipline) dev = self.persistence_delegate.add_developer(dev) self.assertEqual(self.persistence_delegate.developer_exists(dev), @@ -785,13 +1094,18 @@ class TestPersistenceDelegate(TestCase): #+END_SRC + *** Add institute to the system This function adds institute to the system. #+NAME: persistence_add_institute #+BEGIN_SRC python def add_institute(self, institute): + current_app.logger.debug("running add institute to system operation" + " institute = %s" % institute.to_client()) institute.save() + current_app.logger.debug("completed add institute to system operation" + " institute = %s" % institute.to_client()) return institute #+END_SRC @@ -800,14 +1114,22 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_add_institute(self): print "test_add_institute" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name1 = "IIT Kanpur" inst_id1 = "IITK" - institute1 = Institute(inst_name=inst_name1, inst_id=inst_id1) + institute1 = Institute(inst_name=inst_name1, inst_id=inst_id1, + assets=[asset]) institute1 = self.persistence_delegate.add_institute(institute1) inst_name2= "IIT Kharagpur" inst_id2= "IITKgp" - institute2 = Institute(inst_name=inst_name2, inst_id=inst_id2) + institute2 = Institute(inst_name=inst_name2, inst_id=inst_id2, + assets=[asset]) institute = Institute.get_by_id(1) @@ -816,41 +1138,53 @@ class TestPersistenceDelegate(TestCase): self.assertEqual(self.persistence_delegate.institute_exists\ (institute2), False) + #+END_SRC -*** Add hostinginfo to the system +*** Add hosting_info to the system - This function adds hostinginfo to the system. -#+NAME: persistence_add_hostinginfo + This function adds hosting_info to the system. +#+NAME: persistence_add_hosting_info #+BEGIN_SRC python - def add_hostinginfo(self, hostinginfo): - hostinginfo.save() - return hostinginfo + def add_hosting_info(self, hosting_info): + current_app.logger.debug("running add hosting_info to system operation" + " hosting_info = %s" % + hosting_info.to_client()) + hosting_info.save() + current_app.logger.debug("completed add hosting_info" + " to system operation" + " hosting_info = %s" % + hosting_info.to_client()) + return hosting_info #+END_SRC -**** Tests -#+NAME: test_persistence_add_hostinginfo +**** COMMENT Tests +#+NAME: test_persistence_add_hosting_info #+BEGIN_SRC python - def test_add_hostinginfo(self): - print "test_add_hostinginfo" + def test_add_hosting_info(self): + print "test_add_hosting_info" hosting_status1 = "hosted" hosted_url1 = "http://cse14-iiith.vlabs.ac.in" hosted_on1 = "cloud" - hostinginfo1 = HostingInfo(hosting_status=hosting_status1, hosted_url=hosted_url1, hosted_on=hosted_on1) - hostinginfo1 = self.persistence_delegate.add_hostinginfo(hostinginfo1) + hosting_info1 = HostingInfo(hosting_status=hosting_status1,\ + hosted_url=hosted_url1,\ + hosted_on=hosted_on1) + hosting_info1 = self.persistence_delegate.add_hosting_info(hosting_info1) hosting_status2 = "not hosted" hosted_url2 = "http://iitkgp.vlab.co.in/" hosted_on2 = "server" - hostinginfo2 = HostingInfo(hosting_status=hosting_status2, hosted_url=hosted_url2, hosted_on=hosted_on2) + hosting_info2 = HostingInfo(hosting_status=hosting_status2,\ + hosted_url=hosted_url2,\ + hosted_on=hosted_on2) - hostinginfo = HostingInfo.get_by_id(1) + hosting_info = HostingInfo.get_by_id(1) - self.assertEqual(self.persistence_delegate.hostinginfo_exists\ - (hostinginfo1), True) - self.assertEqual(self.persistence_delegate.hostinginfo_exists\ - (hostinginfo2), False) + self.assertEqual(self.persistence_delegate.hosting_info_exists\ + (hosting_info1), True) + self.assertEqual(self.persistence_delegate.hosting_info_exists\ + (hosting_info2), False) #+END_SRC @@ -861,7 +1195,11 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_add_asset #+BEGIN_SRC python def add_asset(self, asset): + current_app.logger.debug("running add asset to system operation" + " asset = %s" % asset.to_client()) asset.save() + current_app.logger.debug("completed add asset to system operation" + " asset = %s" % asset.to_client()) return asset #+END_SRC @@ -871,6 +1209,7 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_add_asset(self): print "test_add_asset" + asset_type1 = "Image" path1 = "vlabs.ac.in/static/images/logo.png" asset1 = Asset(asset_type=asset_type1, path=path1) @@ -889,34 +1228,42 @@ class TestPersistenceDelegate(TestCase): #+END_SRC -*** Add integrationstatus to the system +*** Add integration_status to the system - This function adds integrationstatus to the system. -#+NAME: persistence_add_integrationstatus + This function adds integration_status to the system. +#+NAME: persistence_add_integration_status #+BEGIN_SRC python - def add_integrationstatus(self, integrationstatus): - integrationstatus.save() - return integrationstatus + def add_integration_status(self, integration_status): + current_app.logger.debug("running add integration_status to" + " system operation" + " integration_status = %s" % + integration_status.to_client()) + integration_status.save() + current_app.logger.debug("completed add integration_status to" + " system operation" + " integration_status = %s" % + integration_status.to_client()) + return integration_status #+END_SRC **** Tests -#+NAME: test_persistence_add_integrationstatus +#+NAME: test_persistence_add_integration_status #+BEGIN_SRC python - def test_add_integrationstatus(self): - print "test_add_integrationstatus" + def test_add_integration_status(self): + print "test_add_integration_status" integration_level1 = 4 - integrationstatus1 = IntegrationStatus(integration_level=integration_level1) - integrationstatus1 = self.persistence_delegate.add_integrationstatus(integrationstatus1) + integration_status1 = IntegrationStatus(integration_level= integration_level1) + integration_status1 = self.persistence_delegate.add_integration_status(integration_status1) integration_level2= 2 - integrationstatus2 = IntegrationStatus(integration_level=integration_level2) + integration_status2 = IntegrationStatus(integration_level= integration_level2) - integrationstatus = IntegrationStatus.get_by_id(1) + integration_status = IntegrationStatus.get_by_id(1) - self.assertEqual(self.persistence_delegate.integrationstatus_exists\ - (integrationstatus1), True) - self.assertEqual(self.persistence_delegate.integrationstatus_exists\ - (integrationstatus2), False) + self.assertEqual(self.persistence_delegate.integration_status_exists\ + (integration_status1), True) + self.assertEqual(self.persistence_delegate.integration_status_exists\ + (integration_status2), False) #+END_SRC @@ -925,14 +1272,24 @@ class TestPersistenceDelegate(TestCase): This function updates existing lab. #+NAME: persistence_update_lab #+BEGIN_SRC python - def update_lab(self, lab, lab_name, overview): - lab.set(lab_name=lab_name, overview=overview) + def update_lab(self, lab, lab_name, overview, institute, discipline, + integration_status, hosting_info, developers, + assets, experiments): + + current_app.logger.debug("running update lab operation") + + lab.set(lab_name=lab_name, overview=overview, institute=institute, + discipline=discipline, hosting_info=hosting_info, + integration_status=integration_status, + developers=developers, assets=assets, + experiments=experiments) lab.save() + + current_app.logger.debug("completed update lab operation") + return lab #+END_SRC - - **** Tests #+NAME: test_persistence_update_lab #+BEGIN_SRC python @@ -943,64 +1300,167 @@ class TestPersistenceDelegate(TestCase): overview = "overview lab" experiments = [] + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() - dis_name = "IIT Kanpur" - dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + dis_name = "Electronics & Communications" + dis_id = "ECE" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) discipline.save() integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() - - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = Asset(asset_type=asset_type, path=path) - asset.save() - + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() + dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) host.save() + + exp_name = "Data Structures" + exp_id = "cse01" + overview = "overview" + + exp = Experiment(exp_name=exp_name, exp_id=exp_id, \ + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], developers=[dev], + hosting_info=[host]) + + exp1 = self.persistence_delegate.add_experiment(exp) + + lab = Lab(lab_name=lab_name, lab_id=lab_id, overview=overview, - institute=inst, discipline=discipline, hostinginfo=host, assets=[asset], - experiments=experiments, developers=[dev], - integrationstatus=integrationstatus) + institute=inst, discipline=discipline, + assets=[asset], hosting_info=[host], + experiments=[exp1], developers=[dev], + integration_status=integration_status) lab1 = self.persistence_delegate.add_lab(lab) lab_name1 = "Computer Programming" overview1 = "overview" + + inst_name1 = "IIT Kharagpur" + inst_id1 = "IITKgp" + inst1 = Institute(inst_name=inst_name1, inst_id=inst_id1, + assets=[asset]) + inst1.save() + + dis_name1 = "Computer Science & Engineering" + dis_id1 = "CSE" + discipline1 = Discipline(dis_name=dis_name1, dis_id=dis_id1, + assets=[asset]) + discipline1.save() + + integration_level1 = 2 + integration_status1 = IntegrationStatus(integration_level=\ + integration_level1) + integration_status1.save() + + hosting_status1 = "hosted" + hosted_url1 = "http://cse13-iiith.vlabs.ac.in" + hosted_on1 = "cloud" + host1 = HostingInfo(hosting_status=hosting_status1, + hosted_url=hosted_url1, + hosted_on=hosted_on1) + host1.save() + + dev_name1 = Name(name="Tahiliani") + dev_name1.save() + email_id1 = Email(email="tahiliani@gmail.com") + email_id1.save() + dev1 = Developer(name=dev_name1, email=email_id1, + institute=inst1, discipline=discipline1) + dev1.save() + + asset_type1 = "Image" + path1 = "vlabs.ac.in/images/static/image.png" + asset1 = Asset(asset_type=asset_type1, path=path1) + asset1.save() + + exp_name1 = "Computer Programming" + exp_id1 = "cse02" + overview1 = "computer overview" + + exp1 = Experiment(exp_name=exp_name1, exp_id=exp_id1, \ + overview=overview1, sections=[], + institute=inst1, discipline=discipline1, + integration_status=integration_status, + assets=[asset1], developers=[dev1], + hosting_info=[host1]) + + exp2 = self.persistence_delegate.add_experiment(exp) + lab2 = self.persistence_delegate.update_lab\ - (lab1, lab_name1, overview=overview1), + (lab1, lab_name1, overview1, inst1, discipline1, + integration_status1, [host1], [dev1], [asset1], [exp2]), + lab2 = Lab.get_by_id(1) self.assertEqual(lab2.get("lab_id"), lab_id) self.assertEqual(lab2.get("lab_name"), lab_name1) self.assertEqual(lab2.get("overview"), overview1) + self.assertEqual(lab2.get("institute").get("inst_id"), + inst1.get("inst_id")) + self.assertEqual(lab2.get("discipline").get("dis_id"), + discipline1.get("dis_id")) + self.assertEqual(lab2.get("integration_status"). + get("integration_level"), + integration_status1.get("integration_level")) -#+END_SRC + self.assertEqual(lab2.get("hosting_info")[0].get("hosted_url"), + hosted_url1) + self.assertEqual(lab2.get("developers")[0].get("email").get("email"), + email_id1.get("email")) + self.assertEqual(lab2.get("assets")[0].get("path"), + asset1.get("path")) + self.assertEqual(lab2.get("experiments")[0].get("exp_id"), + exp2.get("exp_id")) +#+END_SRC + *** Update Experiment This function updates existing experiment. #+NAME: persistence_update_experiment #+BEGIN_SRC python - def update_experiment(self, experiment, exp_name, overview): - experiment.set(exp_name=exp_name, overview=overview) + def update_experiment(self, experiment, exp_name, overview, institute, + discipline, integration_status, hosting_info, + developers, assets, sections): + current_app.logger.debug("running update experiment operation") + + experiment.set(exp_name=exp_name, overview=overview, + institute=institute, discipline=discipline, + integration_status=integration_status, + hosting_info=hosting_info, + developers=developers, assets=assets, + sections=sections) experiment.save() + + current_app.logger.debug("completed update experiment operation") + return experiment #+END_SRC @@ -1010,20 +1470,130 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_update_experiment(self): print "test_update_experiment" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "computer science" + dis_id = "cse" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + + dev_name = Name(name="Mohit Tahiliani") + dev_name.save() + email_id = Email(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) + host.save() + exp_name = "Data Structures" exp_id = "cse01" overview = "overview" + + integration_level = 4 + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() + + name = "Theory" + section = Section(name=name) + section.save() + exp = Experiment(exp_name=exp_name, exp_id=exp_id, \ - overview=overview, sections=[]) + overview=overview, sections=[section], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], developers=[dev], + hosting_info=[host] ) exp1 = self.persistence_delegate.add_experiment(exp) + exp_name1 = "Computer Programming" overview1 = "overveiw exp" - exp2 = self.persistence_delegate.update_experiment\ - (exp1, exp_name1, overview1), + + asset_type1 = "Video" + path1 = "vlabs.ac.in/images/video/logo.png" + asset1 = Asset(asset_type=asset_type1, path=path1) + asset1.save() + + inst_name1 = "IIT Kharagpur" + inst_id1 = "IITKgp" + inst1 = Institute(inst_name=inst_name1, inst_id=inst_id1, + assets=[asset1]) + inst1.save() + + dis_name1 = "Electronics and Communication" + dis_id1 = "ece" + discipline1 = Discipline(dis_name=dis_name1, dis_id=dis_id1, + assets=[asset1]) + discipline1.save() + + dev_name1 = Name(name="Palavi Pawar") + dev_name1.save() + email_id1 = Email(email="pallavipawar@gmail.com") + email_id1.save() + dev1 = Developer(name=dev_name1, email=email_id1, + institute=inst1, discipline=discipline1) + dev1.save() + + integration_level1 = 3 + integration_status1 = IntegrationStatus(integration_level= + integration_level1) + integration_status1.save() + + hosting_status1 = "hosted" + hosted_url1 = "http://cse13-iiith.vlabs.ac.in" + hosted_on1 = "cloud" + host1 = HostingInfo(hosting_status=hosting_status1, + hosted_url=hosted_url1, + hosted_on=hosted_on1) + host1.save() + + name1 = "Procedure" + section1 = Section(name=name1) + section1.save() + + exp2 = self.persistence_delegate.update_experiment(exp1, exp_name1, + overview1, inst1, discipline1, + integration_status1, [host1], + [dev1], [asset1], [section1]) exp2 = Experiment.get_by_id(1) + self.assertEqual(exp2.get("exp_name"), exp_name1) self.assertEqual(exp2.get("overview"), overview1) self.assertEqual(exp2.get("exp_id"), exp_id) + self.assertEqual(exp2.get("institute").get("inst_id"), + inst1.get("inst_id")) + self.assertEqual(exp2.get("discipline").get("dis_id"), + discipline1.get("dis_id")) + self.assertEqual(exp2.get("integration_status"). + get("integration_level"), + integration_status1.get("integration_level")) + self.assertEqual(exp2.get("hosting_info")[0].get("hosted_url"), + hosted_url1) + self.assertEqual(exp2.get("developers")[0].get("email").get("email"), + email_id1.get("email")) + self.assertEqual(exp2.get("assets")[0].get("path"), + asset1.get("path")) + self.assertEqual(exp2.get("sections")[0].get("name"), + section1.get("name")) + #+END_SRC @@ -1032,9 +1602,13 @@ class TestPersistenceDelegate(TestCase): This function updates existing discipline. #+NAME: persistence_update_discipline #+BEGIN_SRC python - def update_discipline(self, discipline, dis_name): - discipline.set(dis_name=dis_name) + def update_discipline(self, discipline, dis_name, assets): + current_app.logger.debug("running update discipline operation") + + discipline.set(dis_name=dis_name, assets=assets) discipline.save() + + current_app.logger.debug("completed update discipline operation") return discipline #+END_SRC @@ -1044,17 +1618,31 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_update_discipline(self): print "test_update_discipline" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + dis_name = "IIT Delhi" dis_id = "EEE08" - dis = Discipline(dis_name=dis_name, dis_id=dis_id) + dis = Discipline(dis_name=dis_name, dis_id=dis_id, assets=[asset]) dis1 = self.persistence_delegate.add_discipline(dis) + + asset_type1 = "Image" + path1 = "vlabs.ac.in/images/static/image.png" + asset1 = Asset(asset_type=asset_type1, path=path1) + asset1.save() + dis_name1 = "IIT Bombay" dis_id1 = "EEE09" dis2 = self.persistence_delegate.update_discipline\ - (dis1, dis_name1), + (dis1, dis_name1, [asset1]), dis2 = Discipline.get_by_id(1) self.assertEqual(dis2.get("dis_name"), dis_name1) self.assertEqual(dis2.get("dis_id"), dis_id) + self.assertEqual(dis2.get("assets")[0].get("path"), + asset1.get("path")) #+END_SRC @@ -1065,8 +1653,14 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_update_section #+BEGIN_SRC python def update_section(self, section, name): + current_app.logger.debug("running update section operation" + " with section name = %s" % name) + section.set(name=name) section.save() + + current_app.logger.debug("completed update section operation" + " with section name = %s" % name) return section #+END_SRC @@ -1088,14 +1682,19 @@ class TestPersistenceDelegate(TestCase): #+END_SRC - *** Update developer This function updates existing developer. #+NAME: persistence_update_developer #+BEGIN_SRC python - def update_developer(self, dev, dev_name): - dev.set(name=dev_name) + def update_developer(self, dev, dev_name, institute, discipline): + + current_app.logger.debug("running update developer operation") + + dev.set(name=dev_name, institute=institute, discipline=discipline) dev.save() + + current_app.logger.debug("completed update developer operation") + return dev #+END_SRC @@ -1106,19 +1705,51 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_update_developer(self): print "test_update_developer" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "computer science" + dis_id = "cse" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + dev_name = Name(name="Prof. S. Dharmaraja") dev_name.save() email_id = Email(email="dharmar@maths.iitd.ac.in") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev1 = self.persistence_delegate.add_developer(dev) + inst_name1 = "IIT Kharagpur" + inst_id1 = "IITKgp" + inst1 = Institute(inst_name=inst_name1, inst_id=inst_id1, assets=[asset]) + inst1.save() + + dis_name1 = "Computer Science & Engineering" + dis_id1 = "IIT Kharagpur" + discipline1 = Discipline(dis_name=dis_name1, dis_id=dis_id1, assets=[asset]) + discipline1.save() + dev_name1 = Name(name="Prof. S. raja") dev_name1.save() - dev2 = self.persistence_delegate.update_developer(dev1, dev_name1) + dev2 = self.persistence_delegate.update_developer(dev1, dev_name1, inst1, discipline1) self.assertEqual(dev1.get("name").get("name"), dev_name1.get("name")) + self.assertEqual(dev1.get("institute").get("inst_id"), + inst1.get("inst_id")) + self.assertEqual(dev1.get("discipline").get("dis_id"), + discipline1.get("dis_id")) #+END_SRC @@ -1127,9 +1758,15 @@ class TestPersistenceDelegate(TestCase): This function updates existing institute. #+NAME: persistence_update_institute #+BEGIN_SRC python - def update_institute(self, institute, inst_name): - institute.set(inst_name=inst_name) + def update_institute(self, institute, inst_name, assets): + + current_app.logger.debug("running update institute operation") + + institute.set(inst_name=inst_name, assets=assets) institute.save() + + current_app.logger.debug("completed update institute operation") + return institute #+END_SRC @@ -1139,55 +1776,78 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_update_institute(self): print "test_update_institute" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Delhi" inst_id = "IITD" - institute = Institute(inst_name=inst_name, inst_id=inst_id) + institute = Institute(inst_name=inst_name, inst_id=inst_id, + assets=[asset]) institute1 = self.persistence_delegate.add_institute(institute) + asset_type1 = "Image" + path1 = "vlabs.ac.in/images/static/image.png" + asset1 = Asset(asset_type=asset_type1, path=path1) + asset1.save() + inst_name1 = "IIT Kanpur" institute2 = self.persistence_delegate.update_institute\ - (institute1, inst_name1), + (institute1, inst_name1, [asset1]), institute = Institute.get_by_id(1) self.assertEqual(institute.get("inst_name"), inst_name1) self.assertEqual(institute.get("inst_id"), inst_id) + self.assertEqual(institute.get("assets")[0].get("path"), + asset1.get("path")) #+END_SRC *** Update HostingInfo - This function updates existing hostinginfo. -#+NAME: persistence_update_hostinginfo + This function updates existing hosting_info. +#+NAME: persistence_update_hosting_info #+BEGIN_SRC python - def update_hostinginfo(self, hostinginfo, hosting_status, hosted_on): - hostinginfo.set(hosting_status=hosting_status, hosted_on=hosted_on) - hostinginfo.save() - return hostinginfo + def update_hosting_info(self, hosting_info, hosting_status, hosted_on): + + current_app.logger.debug("running update hosting_info operation") + + hosting_info.set(hosting_status=hosting_status, hosted_on=hosted_on) + hosting_info.save() + + current_app.logger.debug("completed update hosting_info operation") + + return hosting_info #+END_SRC **** Tests -#+NAME: test_persistence_update_hostinginfo +#+NAME: test_persistence_update_hosting_info #+BEGIN_SRC python - def test_update_hostinginfo(self): - print "test_update_hostinginfo" + def test_update_hosting_info(self): + print "test_update_hosting_info" hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - hostinginfo = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) - hostinginfo1 = self.persistence_delegate.add_hostinginfo(hostinginfo) + hosting_info = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) + hosting_info1 = self.persistence_delegate.add_hosting_info( + hosting_info) hosting_status1 = "not hosted" hosted_on1 = "server" - hostinginfo2 = self.persistence_delegate.update_hostinginfo\ - (hostinginfo1, hosting_status1, hosted_on1), + hosting_info2 = self.persistence_delegate.update_hosting_info\ + (hosting_info1, hosting_status1, hosted_on1), - hostinginfo = HostingInfo.get_by_id(1) + hosting_info = HostingInfo.get_by_id(1) - self.assertEqual(hostinginfo.get("hosting_status"), hosting_status1) - self.assertEqual(hostinginfo.get("hosted_url"), hosted_url) - self.assertEqual(hostinginfo.get("hosted_on"), hosted_on1) + self.assertEqual(hosting_info.get("hosting_status"), hosting_status1) + self.assertEqual(hosting_info.get("hosted_url"), hosted_url) + self.assertEqual(hosting_info.get("hosted_on"), hosted_on1) #+END_SRC @@ -1197,8 +1857,12 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_update_asset #+BEGIN_SRC python def update_asset(self, asset, asset_type): + + current_app.logger.debug("running update asset operation") asset.set(asset_type=asset_type) asset.save() + + current_app.logger.debug("completed update asset operation") return asset #+END_SRC @@ -1208,6 +1872,7 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_update_asset(self): print "test_update_asset" + asset_type = "Image" path = "vlabs.ac.in/static/images/logo.png" asset = Asset(asset_type=asset_type, path=path) @@ -1234,10 +1899,16 @@ class TestPersistenceDelegate(TestCase): abort(404, 'No Lab with lab_id %s' % (lab_id)) else: try: + current_app.logger.debug("running delete operation on" + " lab with lab_id = %s" + % lab_id) record.delete() #db.session.delete(record) #db.session.commit() except Exception, e: + current_app.logger.debug("completed delete operation on" + " lab with lab_id = %s" + % lab_id) print e abort(500, str(e)) @@ -1254,41 +1925,49 @@ class TestPersistenceDelegate(TestCase): lab_id = "cse01" overview = "overview" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, + assets=[asset]) inst.save() integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = Asset(asset_type=asset_type, path=path) - asset.save() - dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) host.save() lab = Lab(lab_name=lab_name, lab_id=lab_id, overview=overview, - institute=inst, discipline=discipline, hostinginfo=host, assets=[asset], - experiments=[], developers=[dev], integrationstatus=integrationstatus) + institute=inst, discipline=discipline, + hosting_info=[host], assets=[asset], + experiments=[], developers=[dev], + integration_status=integration_status) lab1 = self.persistence_delegate.add_lab(lab) @@ -1298,8 +1977,8 @@ class TestPersistenceDelegate(TestCase): lab1 = Lab(lab_name=lab_name1, lab_id=lab_id1, overview=overview, institute=inst, discipline=discipline, assets=[asset], - experiments=[], integrationstatus=integrationstatus, - developers=[dev], hostinginfo=host) + experiments=[], integration_status=integration_status, + developers=[dev], hosting_info=[host]) lab2 = self.persistence_delegate.add_lab(lab1) @@ -1320,10 +1999,16 @@ class TestPersistenceDelegate(TestCase): abort(404, 'No Experiment found with exp_id %s' % (exp_id)) else: try: + current_app.logger.debug("running delete operation on" + " experiment with exp_id = %s" + % exp_id) record.delete() #db.session.delete(record) #db.session.commit() except Exception, e: + current_app.logger.debug("completed delete operation on" + " experiment with exp_id = %s" + % exp_id) print e abort(500, str(e)) @@ -1336,18 +2021,64 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_delete_experiment(self): print "test_delete_experiment" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + + dev_name = Name(name="Mohit Tahiliani") + dev_name.save() + email_id = Email(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) + host.save() + + integration_level = 4 + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() + exp_name = "arrays" - exp_id = "cse01" + exp_id = "cse01" overview = "overview" exp = Experiment(exp_name=exp_name, exp_id=exp_id, \ - overview=overview, sections=[]) + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], developers=[dev], + hosting_info=[host]) exp1 = self.persistence_delegate.add_experiment(exp) exp_name1 = "linked list" exp_id1 = "cse02" overview = "overview" exp1 = Experiment(exp_name=exp_name1, exp_id=exp_id1, \ - overview=overview, sections=[]) + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], developers=[dev], + hosting_info=[host]) exp2 = self.persistence_delegate.add_experiment(exp1) self.persistence_delegate.delete_experiment(exp_id) @@ -1367,10 +2098,16 @@ class TestPersistenceDelegate(TestCase): abort(404, 'No Discipline with dis_id %s' % (dis_id)) else: try: + current_app.logger.debug("running delete operation on" + " discipline with dis_id = %s" + % dis_id) record.delete() #db.session.delete(record) #db.session.commit() except Exception, e: + current_app.logger.debug("completed delete operation on" + " discipline with dis_id = %s" + % dis_id) print e abort(500, str(e)) @@ -1383,14 +2120,20 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_delete_discipline(self): print "test_delete_discipline" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + dis_name = "IIT Delhi" dis_id = "EEE08" - dis = Discipline(dis_name=dis_name, dis_id=dis_id) + dis = Discipline(dis_name=dis_name, dis_id=dis_id, assets=[asset]) dis1 = self.persistence_delegate.add_discipline(dis) dis_name1 = "IIT Kanpur" dis_id1 = "EEE10" - dis1 = Discipline (dis_name=dis_name1, dis_id=dis_id1) + dis1 = Discipline (dis_name=dis_name1, dis_id=dis_id1, assets=[asset]) dis2 = self.persistence_delegate.add_discipline(dis1) self.persistence_delegate.delete_discipline("EEE08") @@ -1410,10 +2153,13 @@ class TestPersistenceDelegate(TestCase): abort(404, 'No Section with id %s' % (e_id)) else: try: + current_app.logger.debug("running delete operation on section") record.delete() #db.session.delete(record) #db.session.commit() except Exception, e: + current_app.logger.debug("completed delete" + " operation on section") print e abort(500, str(e)) @@ -1445,20 +2191,24 @@ class TestPersistenceDelegate(TestCase): This function delete existing name. #+NAME: persistence_delete_name #+BEGIN_SRC python - def delete_name(self, name): - record = self.get_name(name=name.get("name")) + def delete_name(self, n_id): + current_app.logger.debug("running delete on developer name") + record = Name.get_by_id(n_id) if not record: - abort(404, 'No Name with id %s' % (name)) + abort(404, 'No Name with id %s' % (n_id)) else: try: record.delete() + current_app.logger.debug("completed delete on developer" + " name") #db.session.delete(record) #db.session.commit() except Exception, e: + current_app.logger.error("Exception = %s" % str(e)) print e abort(500, str(e)) - return name + return n_id #+END_SRC @@ -1475,7 +2225,7 @@ class TestPersistenceDelegate(TestCase): name2 = Name(name=name1) name2.save() - self.persistence_delegate.delete_name(name2) + self.persistence_delegate.delete_name(1) self.assertEqual(len(Name.get_all()), 1) @@ -1488,14 +2238,19 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def delete_email(self, email_id): record = self.get_email(email=email_id.get("email")) + current_app.logger.debug("running delete on developer" + " email with email_id = %s" % email_id) if not record: abort(404, 'No Email with id %s' % (email_id)) else: - try: + try: record.delete() + current_app.logger.debug("completed delete on developer" + " email with email_id = %s" % email_id) #db.session.delete(record) #db.session.commit() except Exception, e: + current_app.logger.error("Exception = %s" % str(etest_delete_developer)) print e abort(500, str(e)) @@ -1527,12 +2282,18 @@ class TestPersistenceDelegate(TestCase): def delete_developer(self, email_id): record = self.get_developer(email=email_id) if not record: + current_app.logger.debug("running delete on developer" + " with email_id = %s" % email_id) abort(404, 'No Developer with id %s' % (email_id)) else: try: record.delete() + current_app.logger.debug("completed delete on developer" + " with email_id = %s" % email_id) self.delete_email(email_id) + except Exception, e: + current_app.logger.error("Exception = %s" % str(e)) print e abort(500, str(e)) @@ -1545,13 +2306,31 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_delete_developer(self): print "test_delete_developer" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + dev_name = Name(name="Prof. S. Dharmaraja") dev_name.save() email_id = Email(email="dharmar@maths.iitd.ac.in") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev1 = self.persistence_delegate.add_developer(dev) dev_name1 = Name(name="Prof. S. Yamraja") @@ -1559,7 +2338,8 @@ class TestPersistenceDelegate(TestCase): email_id1 = Email(email="yamraja@maths.iitd.ac.in") email_id1.save() - dev2 = Developer(name=dev_name1, email=email_id1) + dev2 = Developer(name=dev_name1, email=email_id1, + institute=inst, discipline=discipline) dev3 = self.persistence_delegate.add_developer(dev2) self.persistence_delegate.delete_developer(dev3.get("email")) @@ -1581,10 +2361,17 @@ class TestPersistenceDelegate(TestCase): abort(404, 'No Institute with id %s' % (inst_id)) else: try: + current_app.logger.debug("running delete on institute" + " with inst_id = %s" % + inst_id) record.delete() + current_app.logger.debug("completed delete on institute" + " with inst_id = %s" % + inst_id) #db.session.delete(record) #db.session.commit() except Exception, e: + current_app.logger.error("Exception = %s" % str(e)) print e abort(500, str(e)) @@ -1597,14 +2384,22 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_delete_institute(self): print "test_delete_institute" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Delhi" inst_id = "IITD" - institute = Institute(inst_name=inst_name, inst_id=inst_id) + institute = Institute(inst_name=inst_name, inst_id=inst_id, + assets=[asset]) institute1 = self.persistence_delegate.add_institute(institute) inst_name1 = "IIT Kharagpur" inst_id1 = "IITKgp" - institute1 = Institute(inst_name=inst_name1, inst_id=inst_id1) + institute1 = Institute(inst_name=inst_name1, inst_id=inst_id1, + assets=[asset]) institute2 = self.persistence_delegate.add_institute(institute1) self.persistence_delegate.delete_institute("IITD") @@ -1615,19 +2410,24 @@ class TestPersistenceDelegate(TestCase): *** Delete HostingInfo - This function deletes existing hostinginfo. -#+NAME: persistence_delete_hostinginfo + This function deletes existing hosting_info. +#+NAME: persistence_delete_hosting_info #+BEGIN_SRC python - def delete_hostinginfo(self, hosted_url): - record = self.get_hostinginfo(hosted_url=hosted_url) + def delete_hosting_info(self, hosted_url): + record = self.get_hosting_info(hosted_url=hosted_url) if not record: abort(404, 'No HostingInfo with id %s' % (hosted_url)) else: try: + current_app.logger.debug("running delete on hosting_info" + " with hosted_url = %s" % hosted_url) record.delete() + current_app.logger.debug("completed delete on hosting_info" + " with hosted_url = %s" % hosted_url) #db.session.delete(record) #db.session.commit() except Exception, e: + current_app.logger.error("Exception = %s" % str(e)) print e abort(500, str(e)) @@ -1636,23 +2436,29 @@ class TestPersistenceDelegate(TestCase): #+END_SRC **** Tests -#+NAME: test_persistence_delete_hostinginfo +#+NAME: test_persistence_delete_hosting_info #+BEGIN_SRC python - def test_delete_hostinginfo(self): - print "test_delete_hostinginfo" + def test_delete_hosting_info(self): + print "test_delete_hosting_info" hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - hostinginfo = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) - hostinginfo1 = self.persistence_delegate.add_hostinginfo(hostinginfo) + hosting_info = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) + hosting_info = self.persistence_delegate.add_hosting_info(hosting_info) hosting_status1 = "not hosted" hosted_url1 = "http://iitkgp.vlab.co.in/" hosted_on1 = "server" - hostinginfo1 = HostingInfo(hosting_status=hosting_status1, hosted_url=hosted_url1, hosted_on=hosted_on1) - hostinginfo2 = self.persistence_delegate.add_hostinginfo(hostinginfo1) + hosting_info1 = HostingInfo(hosting_status=hosting_status1, + hosted_url=hosted_url1, + hosted_on=hosted_on1) + hosting_info2 = self.persistence_delegate.add_hosting_info( + hosting_info1) - self.persistence_delegate.delete_hostinginfo("http://cse14-iiith.vlabs.ac.in") + self.persistence_delegate.delete_hosting_info( + "http://cse14-iiith.vlabs.ac.in") self.assertEqual(len(HostingInfo.get_all()), 1) @@ -1669,10 +2475,15 @@ class TestPersistenceDelegate(TestCase): abort(404, 'No Asset found with path %s' % (path)) else: try: + current_app.logger.debug("running delete on asset" + " with path = %s" % path) record.delete() + current_app.logger.debug("completed delete on asset" + " with path = %s" % path) #db.session.delete(record) #db.session.commit() except Exception, e: + current_app.logger.error("Exception = %s" % str(e)) print e abort(500, str(e)) @@ -1685,14 +2496,17 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_delete_asset(self): print "test_delete_asset" + asset_type = "Image" path = "vlabs.ac.in/static/images/logo.png" asset = Asset(asset_type=asset_type, path=path) + asset1 = self.persistence_delegate.add_asset(asset) asset_type1 = "Icon" path1 = "vlabs.ac.in/static/images/icon.png" asset1 = Asset(asset_type=asset_type1, path=path1) + asset2 = self.persistence_delegate.add_asset(asset1) self.persistence_delegate.delete_asset(path) @@ -1703,19 +2517,26 @@ class TestPersistenceDelegate(TestCase): *** Delete IntegrationStatus - This function deletes existing integrationstatus. -#+NAME: persistence_delete_integrationstatus + This function deletes existing integration_status. +#+NAME: persistence_delete_integration_status #+BEGIN_SRC python - def delete_integrationstatus(self, integration_level): - record = self.get_integrationstatus(integration_level=integration_level) + def delete_integration_status(self, integration_level): + record = self.get_integration_status(integration_level=integration_level) if not record: abort(404, 'No IntegrationStatus with id %s' % (integration_level)) else: try: + current_app.logger.debug("running delete on integration_status" + " with integration_level = %s" + % integration_level) record.delete() + current_app.logger.debug("completed delete on integration_status" + " with integration_level = %s" + % integration_level) #db.session.delete(record) #db.session.commit() except Exception, e: + current_app.logger.error("Exception = %s" % str(e)) print e abort(500, str(e)) @@ -1723,19 +2544,23 @@ class TestPersistenceDelegate(TestCase): #+END_SRC **** Tests -#+NAME: test_persistence_delete_integrationstatus +#+NAME: test_persistence_delete_integration_status #+BEGIN_SRC python - def test_delete_integrationstatus(self): - print "test_delete_integrationstatus" + def test_delete_integration_status(self): + print "test_delete_integration_status" integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus1 = self.persistence_delegate.add_integrationstatus(integrationstatus) + integration_status = IntegrationStatus(integration_level=\ + integration_level) + integration_status1 = self.persistence_delegate.add_integration_status\ + (integration_status) integration_level1 = 2 - integrationstatus1 = IntegrationStatus(integration_level=integration_level1) - integrationstatus2 = self.persistence_delegate.add_integrationstatus(integrationstatus1) + integration_status1 = IntegrationStatus(integration_level=\ + integration_level1) + integration_status2 = self.persistence_delegate.\ + add_integration_status(integration_status1) - self.persistence_delegate.delete_integrationstatus(integration_level) + self.persistence_delegate.delete_integration_status(integration_level) self.assertEqual(len(IntegrationStatus.get_all()), 1) @@ -1751,15 +2576,23 @@ class TestPersistenceDelegate(TestCase): lab = self.get_lab_by_id(labid) experiment_list = [] for experiment in experiments: + + current_app.logger.debug("running add experiments to a lab" + " operation with labid = %s" % labid) + if self.experiment_exists(experiment): - experiment = self.get_experiment(exp_id=experiment.get('exp_id'), - exp_name=experiment.get('exp_name')) + experiment = self.get_experiment(exp_id=experiment. + get('exp_id'), + exp_name=experiment. + get('exp_name')) else: experiment.save() experiment_list.append(experiment) lab.set(experiments=experiment_list) + + current_app.logger.debug("completed add experiments to a lab operation") return lab #+END_SRC @@ -1774,41 +2607,48 @@ class TestPersistenceDelegate(TestCase): lab_id="CSE02" overview = "overview" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = Asset(asset_type=asset_type, path=path) - asset.save() - integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) host.save() lab = Lab(lab_name=lab_name, lab_id=lab_id, overview=overview, - institute=inst, discipline=discipline, hostinginfo=host, assets=[asset], - experiments=[], developers=[dev], integrationstatus=integrationstatus) + institute=inst, discipline=discipline, + hosting_info=[host], assets=[asset], + experiments=[], developers=[dev], + integration_status=integration_status) lab.save() @@ -1816,7 +2656,11 @@ class TestPersistenceDelegate(TestCase): exp_id = "EE99777" overview = "overview" experiment = Experiment(exp_name=exp_name, exp_id=exp_id, \ - overview=overview, sections=[]) + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], developers=[dev], + hosting_info=[host]) experiment.save() lab1 = Lab.get_by_id(1) @@ -1839,15 +2683,22 @@ class TestPersistenceDelegate(TestCase): def add_assets_to_lab(self, lab, assets): asset_list = [] for asset in assets: + + current_app.logger.debug("running add assets to a" + " lab = %s" % lab.to_client()) if self.asset_exists(asset): asset = self.get_asset(path=asset.get('path'), - asset_type=asset.get('asset_type')) + asset_type=asset. + get('asset_type')) else: asset.save() asset_list.append(asset) lab.set(assets=asset_list) + + current_app.logger.debug("completed add assets to a lab = %s" + % lab.to_client()) return lab #+END_SRC @@ -1862,35 +2713,59 @@ class TestPersistenceDelegate(TestCase): lab_id="CSE02" overview = "overview" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = Asset(asset_type=asset_type, path=path) - asset.save() - integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() + + dev_name = Name(name="Mohit Tahiliani") + dev_name.save() + email_id = Email(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = Developer(name=dev_name, email=email_id) + dev.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) + host.save() lab = Lab(lab_name=lab_name, lab_id=lab_id, overview=overview, - institute=inst, discipline=discipline, assets=[asset], - experiments=[], integrationstatus=integrationstatus) + institute=inst, discipline=discipline, + hosting_info=[host], assets=[asset], + experiments=[], developers=[dev], + integration_status=integration_status) + lab.save() exp_name = "Number Systems" exp_id = "EE99777" overview = "overview" experiment = Experiment(exp_name=exp_name, exp_id=exp_id, \ - overview=overview, sections=[]) + overview=overview, + integration_status=integration_status, + sections=[], assets=[asset], + developers=[dev], hosting_info=[host], + institute=inst, discipline=discipline) experiment.save() lab1 = Lab.get_by_id(1) @@ -1914,6 +2789,8 @@ class TestPersistenceDelegate(TestCase): institute = self.get_institute_by_id(instituteid) lab_list = [] for lab in labs: + current_app.logger.debug("running add labs to an institute with" + " instituteid = %s" % instituteid) if self.lab_exists(lab): lab = self.get_lab(lab_id=lab.get('lab_id'), lab_name=lab.get('lab_name')) @@ -1923,6 +2800,9 @@ class TestPersistenceDelegate(TestCase): lab_list.append(lab) institute.set(labs=lab_list) + + current_app.logger.debug("completed add labs to an institute with" + " instituteid = %s" % instituteid) return institute #+END_SRC @@ -1933,27 +2813,30 @@ class TestPersistenceDelegate(TestCase): def test_add_saved_labs_to_institute(self): print "test_add_labs_to_institute_in_persistence_delegate" - inst_name="IIT Kanpur" - inst_id="IITK" - institute = Institute(inst_name=inst_name, inst_id=inst_id) - institute.save() + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() lab_name = "Data Structures" lab_id = "cse05" overview = "overview" + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) discipline.save() integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() dev_name = Name(name="Mohit Tahiliani") dev_name.save() @@ -1965,19 +2848,22 @@ class TestPersistenceDelegate(TestCase): hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) host.save() lab = Lab(lab_name=lab_name, lab_id=lab_id, overview=overview, - institute=inst, discipline=discipline, hostinginfo=host, assets=[] - experiments=[], developers=[dev], integrationstatus=integrationstatus) + institute=inst, discipline=discipline, + hosting_info=[host], assets=[], experiments=[], + developers=[dev], integration_status=integration_status) lab.save() institute1 = Lab.get_by_id(1) - institute1 = self.persistence_delegate.add_labs_to_institute(institute1.id, \ - [lab]) + institute1 = self.persistence_delegate.add_labs_to_institute( + institute1.id, [lab]) self.assertEqual(len(institute1.get("labs")), 1) self.assertEqual(institute1.get("labs")[0].get("lab_id"), lab_id) @@ -1994,6 +2880,8 @@ class TestPersistenceDelegate(TestCase): def add_sections_to_experiment(self, experiment, sections): section_list = [] for section in sections: + current_app.logger.debug("running add sections to an" + " experiment = %s" % experiment.to_client()) if self.section_exists(section): section = self.get_section(name=section.get('name')) else: @@ -2002,6 +2890,9 @@ class TestPersistenceDelegate(TestCase): section_list.append(section) experiment.set(sections=section_list) + + current_app.logger.debug("completed add sections to an" + " experiment = %s" % experiment.to_client()) return experiment #+END_SRC @@ -2012,11 +2903,52 @@ class TestPersistenceDelegate(TestCase): def test_add_saved_sections_to_experiment(self): print "test_add_sections_to_experiment_in_persistence_delegate" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + + dev_name = Name(name="Mohit Tahiliani") + dev_name.save() + email_id = Email(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) + host.save() + + integration_level = 4 + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() + exp_name = "Number Systems" exp_id = "EE99777" overview = "overview" exp = Experiment(exp_name=exp_name, exp_id=exp_id, \ - overview=overview, sections=[]) + overview=overview, institute=inst, + discipline=discipline, + integration_status=integration_status, + sections=[], assets=[asset], + developers=[dev], hosting_info=[host]) exp.save() section1 = Section(name='Theory') @@ -2057,6 +2989,9 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_get_lab #+BEGIN_SRC python def get_lab(self, **kwargs): + current_app.logger.debug("running get lab operation") + current_app.logger.debug("completed get lab operation") + return self.get_object(Lab, **kwargs) #+END_SRC @@ -2069,41 +3004,49 @@ class TestPersistenceDelegate(TestCase): lab_name1 = "Computer Programming" lab_id1 = "CSE01" overview = "overview" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = Asset(asset_type=asset_type, path=path) - asset.save() - integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) host.save() lab = Lab(lab_name=lab_name1, lab_id=lab_id1, overview=overview, - institute=inst, discipline=discipline, hostinginfo=host, assets=[asset], - experiments=[], developers=[dev], integrationstatus=integrationstatus) + institute=inst, discipline=discipline, + hosting_info=[host], assets=[asset], + experiments=[], developers=[dev], + integration_status=integration_status) lab.save() @@ -2122,6 +3065,8 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_get_section #+BEGIN_SRC python def get_section(self, **kwargs): + current_app.logger.debug("running get section operation") + current_app.logger.debug("completed get section operation") return self.get_object(Section, **kwargs) #+END_SRC @@ -2150,6 +3095,8 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_get_name #+BEGIN_SRC python def get_name(self, **kwargs): + current_app.logger.debug("running get developer's name operation") + current_app.logger.debug("completed get developer's name operation") return self.get_object(Name, **kwargs) #+END_SRC @@ -2178,6 +3125,8 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_get_email #+BEGIN_SRC python def get_email(self, **kwargs): + current_app.logger.debug("running get developer's email operation") + current_app.logger.debug("completed get developer's email operation") return self.get_object(Email, **kwargs) #+END_SRC @@ -2206,6 +3155,8 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_get_developer #+BEGIN_SRC python def get_developer(self, **kwargs): + current_app.logger.debug("running get developer operation") + current_app.logger.debug("completed get developer operation") return self.get_object(Developer, **kwargs) #+END_SRC @@ -2215,15 +3166,35 @@ class TestPersistenceDelegate(TestCase): #+BEGIN_SRC python def test_get_developer(self): print "test_get_developer" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + dev_name = Name(name="Prof. S. Dharmaraja") dev_name.save() email_id = Email(email="dharmar@maths.iitd.ac.in") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() - dev_obj = self.persistence_delegate.get_developer(email=dev.get("email")) - self.assertEqual(dev_obj.get("email").get("email"), email_id.get("email")) + dev_obj = self.persistence_delegate.get_developer(email=dev. + get("email")) + self.assertEqual(dev_obj.get("email").get("email"), email_id. + get("email")) #+END_SRC @@ -2235,6 +3206,8 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_get_experiment #+BEGIN_SRC python def get_experiment(self, **kwargs): + current_app.logger.debug("running get experiment operation") + current_app.logger.debug("completed get experiment operation") return self.get_object(Experiment, **kwargs) #+END_SRC @@ -2245,11 +3218,53 @@ class TestPersistenceDelegate(TestCase): def test_get_experiment(self): print "test_get_experiment" + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) + host.save() + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + + dev_name = Name(name="Mohit Tahiliani") + dev_name.save() + email_id = Email(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + exp_name = "Number Systems" exp_id = "EE99777" overview = "overview" + + integration_level = 4 + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() + exp = Experiment(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], developers=[dev], + hosting_info=[host]) exp.save() exp_obj = self.persistence_delegate.get_experiment(exp_name= exp.get("exp_name")) @@ -2267,6 +3282,8 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_get_institute #+BEGIN_SRC python def get_institute(self, **kwargs): + current_app.logger.debug("running get institute operation") + current_app.logger.debug("completed get institute operation") return self.get_object(Institute, **kwargs) #+END_SRC @@ -2277,9 +3294,15 @@ class TestPersistenceDelegate(TestCase): def test_get_institute(self): print "test_get_institute" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Delhi" inst_id = "IITD" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, + assets=[asset]) inst.save() inst_obj = self.persistence_delegate.get_institute(inst_name= inst.get("inst_name")) @@ -2299,6 +3322,8 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_get_discipline #+BEGIN_SRC python def get_discipline(self, **kwargs): + current_app.logger.debug("running get discipline operation") + current_app.logger.debug("completed get discipline operation") return self.get_object(Discipline, **kwargs) #+END_SRC @@ -2310,9 +3335,14 @@ class TestPersistenceDelegate(TestCase): def test_get_discipline(self): print "test_get_discipline" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + dis_name = "IIT Delhi" dis_id = "EEE08" - dis = Discipline(dis_name=dis_name, dis_id=dis_id) + dis = Discipline(dis_name=dis_name, dis_id=dis_id, assets=[asset]) dis.save() dis_obj = self.persistence_delegate.get_discipline(dis_name=dis_name) dis_obj1 = self.persistence_delegate.get_discipline(dis_id=dis_id) @@ -2329,6 +3359,8 @@ class TestPersistenceDelegate(TestCase): #+NAME: persistence_get_asset #+BEGIN_SRC python def get_asset(self, **kwargs): + current_app.logger.debug("running get asset operation") + current_app.logger.debug("completed get asset operation") return self.get_object(Asset, **kwargs) #+END_SRC @@ -2362,8 +3394,11 @@ class TestPersistenceDelegate(TestCase): current_app.logger.debug("") ret_val = None try: + current_app.logger.debug("running operation get labs") ret_val = Lab.apply_filters(**kwargs) + except NotFoundError as e: + current_app.logger.error("Exception = %s" % str(e)) ret_val = None return ret_val @@ -2379,41 +3414,48 @@ class TestPersistenceDelegate(TestCase): lab_id1="CSE01" overview="overview" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = Asset(asset_type=asset_type, path=path) - asset.save() - integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) host.save() lab1 = Lab(lab_name=lab_name1, lab_id=lab_id1, overview=overview, - institute=inst, discipline=discipline, hostinginfo=host, assets=[asset], - experiments=[], developers=[dev], integrationstatus=integrationstatus) + institute=inst, discipline=discipline, + hosting_info=[host], assets=[asset], + experiments=[], developers=[dev], + integration_status=integration_status) lab1.save() @@ -2421,9 +3463,9 @@ class TestPersistenceDelegate(TestCase): lab_id2="CSE02" lab2 = Lab(lab_name=lab_name2, lab_id=lab_id2, overview=overview, \ - institute=inst, discipline=discipline, assets=[asset], \ - experiments=[], integrationstatus=integrationstatus, - developers=[dev], hostinginfo=host) + institute=inst, discipline=discipline, assets=[asset],\ + experiments=[], integration_status=integration_status, + developers=[dev], hosting_info=[host]) lab2.save() @@ -2438,41 +3480,48 @@ class TestPersistenceDelegate(TestCase): lab_id1="CSE01" overview="overview" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) discipline.save() - - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = Asset(asset_type=asset_type, path=path) - asset.save() integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) host.save() lab1 = Lab(lab_name=lab_name1, lab_id=lab_id1, overview=overview, - institute=inst, discipline=discipline, hostinginfo=host, assets=[asset], - experiments=[], developers=[dev], integrationstatus=integrationstatus) + institute=inst, discipline=discipline, + hosting_info=[host], assets=[asset], + experiments=[], developers=[dev], + integration_status=integration_status) lab1.save() @@ -2480,9 +3529,9 @@ class TestPersistenceDelegate(TestCase): lab_id2="CSE02" lab2 = Lab(lab_name=lab_name2, lab_id=lab_id2, overview=overview, \ - institute=inst, discipline=discipline, assets=[asset], \ - experiments=[], integrationstatus=integrationstatus, \ - developers=[dev], hostinginfo=host) + institute=inst, discipline=discipline, assets=[asset],\ + experiments=[], integration_status=integration_status,\ + developers=[dev], hosting_info=[host]) lab2.save() @@ -2495,51 +3544,58 @@ class TestPersistenceDelegate(TestCase): lab_name1="Computer Programming" lab_id1="CSE01" overview="overview" - inst_name = "IIT Kanpur" - inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) - inst.save() - - dis_name = "IIT Kanpur" - dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) - discipline.save() asset_type = "Image" path = "vlabs.ac.in/images/static/logo.png" asset = Asset(asset_type=asset_type, path=path) asset.save() + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "computer science" + dis_id = "cse" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, - hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) host.save() lab1 = Lab(lab_name=lab_name1, lab_id=lab_id1, overview=overview, - institute=inst, discipline=discipline, hostinginfo=host, assets=[asset], - experiments=[], developers=[dev], integrationstatus=integrationstatus) + institute=inst, discipline=discipline, + hosting_info=[host], assets=[asset], + experiments=[], developers=[dev], + integration_status=integration_status) lab1.save() lab_name2="Data Structures" lab_id2="CSE02" lab2 = Lab(lab_name=lab_name2, lab_id=lab_id2, overview=overview, \ - institute=inst, discipline=discipline, assets=[asset], \ - experiments=[], integrationstatus=integrationstatus, - developers=[dev], hostinginfo=host) + institute=inst, discipline=discipline, assets=[asset],\ + experiments=[], integration_status=integration_status, + developers=[dev], hosting_info=[host]) lab2.save() labs_list = self.persistence_delegate.get_labs(lab_id=lab_id1, @@ -2549,54 +3605,62 @@ class TestPersistenceDelegate(TestCase): def test_get_lab_with_given_institute(self): print "test_get_lab_with_given_institute" + lab_name1="Computer Programming" lab_id1="CSE01" overview="overview" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) discipline.save() - - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = Asset(asset_type=asset_type, path=path) - asset.save() integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) host.save() lab1 = Lab(lab_name=lab_name1, lab_id=lab_id1, overview=overview, - institute=inst, discipline=discipline, hostinginfo=host, assets=[asset], - experiments=[], developers=[dev], integrationstatus=integrationstatus) + institute=inst, discipline=discipline, + hosting_info=[host], assets=[asset], + experiments=[], developers=[dev], + integration_status=integration_status) lab1.save() lab_name2="Data Structures" lab_id2="CSE02" lab2 = Lab(lab_name=lab_name2, lab_id=lab_id2, overview=overview, \ - institute=inst, discipline=discipline, assets=[asset], \ - experiments=[], integrationstatus=integrationstatus, - developers=[dev], hostinginfo=host) + institute=inst, discipline=discipline, assets=[asset],\ + experiments=[], integration_status=integration_status, + developers=[dev], hosting_info=[host]) lab2.save() labs_list = self.persistence_delegate.get_labs(institute=inst) @@ -2616,8 +3680,11 @@ class TestPersistenceDelegate(TestCase): current_app.logger.debug("") ret_val = None try: + current_app.logger.debug("running operation get institutes") ret_val = Institute.apply_filters(**kwargs) + except NotFoundError as e: + current_app.logger.error("Exception = %s" % str(e)) ret_val = None return ret_val @@ -2630,9 +3697,15 @@ class TestPersistenceDelegate(TestCase): def test_get_institutes(self): print "test_get_institutes" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Delhi" inst_id = "IITD" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, + assets=[asset]) inst.save() inst_obj = self.persistence_delegate.get_institute(inst_name= inst.get("inst_name")) @@ -2650,65 +3723,75 @@ class TestPersistenceDelegate(TestCase): *** Get HostingInfo - This function returns hostinginfo if present in the database. If the hostinginfo is + This function returns hosting_info if present in the database. If the hosting_info is not present, =None= type is returned. -#+NAME: persistence_get_hostinginfo +#+NAME: persistence_get_hosting_info #+BEGIN_SRC python - def get_hostinginfo(self, **kwargs): + def get_hosting_info(self, **kwargs): + current_app.logger.debug("running get hostinginfo operation") + current_app.logger.debug("completed get hostinginfo operation") return self.get_object(HostingInfo, **kwargs) #+END_SRC **** Tests -#+NAME: test_persistence_get_hostinginfo +#+NAME: test_persistence_get_hosting_info #+BEGIN_SRC python - def test_get_hostinginfo(self): - print "test_get_hostinginfo" + def test_get_hosting_info(self): + print "test_get_hosting_info" hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) host.save() - host_obj = self.persistence_delegate.get_hostinginfo(hosting_status= + host_obj = self.persistence_delegate.get_hosting_info(hosting_status= host.get("hosting_status")) - host_obj1 = self.persistence_delegate.get_hostinginfo(hosted_url= + host_obj1 = self.persistence_delegate.get_hosting_info(hosted_url= host.get("hosted_url")) - host_obj2 = self.persistence_delegate.get_hostinginfo(hosted_on= + host_obj2 = self.persistence_delegate.get_hosting_info(hosted_on= host.get("hosted_on")) - self.assertEqual(host_obj.get("hosting_status"), host.get("hosting_status")) - self.assertEqual(host_obj1.get("hosted_url"), host.get("hosted_url")) - self.assertEqual(host_obj2.get("hosted_on"), host.get("hosted_on")) + self.assertEqual(host_obj.get("hosting_status"), + host.get("hosting_status")) + self.assertEqual(host_obj1.get("hosted_url"), host. + get("hosted_url")) + self.assertEqual(host_obj2.get("hosted_on"), host. + get("hosted_on")) #+END_SRC *** Get IntegrationStatus - This function returns integrationstatus if present in the database. If the integrationstatus is + This function returns integration_status if present in the database. If the integration_status is not present, =None= type is returned. -#+NAME: persistence_get_integrationstatus +#+NAME: persistence_get_integration_status #+BEGIN_SRC python - def get_integrationstatus(self, **kwargs): + def get_integration_status(self, **kwargs): + current_app.logger.debug("running get instegration status operation") + current_app.logger.debug("completed get integration status operation") return self.get_object(IntegrationStatus, **kwargs) #+END_SRC **** Tests -#+NAME: test_persistence_get_integrationstatus +#+NAME: test_persistence_get_integration_status #+BEGIN_SRC python - def test_get_integrationstatus(self): - print "test_get_integrationstatus" + def test_get_integration_status(self): + print "test_get_integration_status" integration_level = 4 - intstatus = IntegrationStatus(integration_level=integration_level) + intstatus = IntegrationStatus(integration_level=integration_level) intstatus.save() - intstatus_obj = self.persistence_delegate.get_integrationstatus(integration_level= - intstatus.get("integration_level")) + intstatus_obj = self.persistence_delegate.get_integration_status\ + (integration_level=intstatus.get("integration_level")) - self.assertEqual(intstatus_obj.get("integration_level"), intstatus.get("integration_level")) + self.assertEqual(intstatus_obj.get("integration_level"), + intstatus.get("integration_level")) #+END_SRC @@ -2722,8 +3805,10 @@ class TestPersistenceDelegate(TestCase): current_app.logger.debug("") ret_val = None try: + current_app.logger.debug("running operation get assets") ret_val = Asset.apply_filters(**kwargs) except NotFoundError as e: + current_app.logger.error("Exception = %s" % str(e)) ret_val = None return ret_val @@ -2738,7 +3823,7 @@ class TestPersistenceDelegate(TestCase): asset_type = "Image" path = "vlabs.ac.in/static/images/logo.png" - asset = Asset(path=path, asset_type=asset_type) + asset = Asset(path=path, asset_type=asset_type) asset.save() asset_obj = self.persistence_delegate.get_asset(asset_type= asset.get("asset_type")) @@ -2763,6 +3848,8 @@ class TestPersistenceDelegate(TestCase): def get_lab_by_id(self, id): ret_val = None try: + current_app.logger.debug("running operation get" + " lab by ID = %s" % id) ret_val = Lab.get_by_id(id) except Exception as err: current_app.logger.error("Exception = %s" % str(err)) @@ -2781,41 +3868,49 @@ class TestPersistenceDelegate(TestCase): lab_name1="Computer Programming" lab_id1="CSE01" overview="overview" + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = Discipline(dis_name=dis_name, dis_id=dis_id) + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = Asset(asset_type=asset_type, path=path) - asset.save() - integration_level = 4 - integrationstatus = IntegrationStatus(integration_level=integration_level) - integrationstatus.save() + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() dev_name = Name(name="Mohit Tahiliani") dev_name.save() email_id = Email(email="mohit.tahiliani@gmail.com") email_id.save() - dev = Developer(name=dev_name, email=email_id) + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = HostingInfo(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) host.save() lab = Lab(lab_name=lab_name1, lab_id=lab_id1, overview=overview, - institute=inst, discipline=discipline, hostinginfo=host, assets=[asset], - experiments=[], developers=[dev], integrationstatus=integrationstatus) + institute=inst, discipline=discipline, + hosting_info=[host], assets=[asset], + experiments=[], developers=[dev], + integration_status=integration_status) lab.save() lab_obj = self.persistence_delegate.get_lab_by_id(1) @@ -2836,6 +3931,8 @@ class TestPersistenceDelegate(TestCase): def get_experiment_by_id(self, id): ret_val = None try: + current_app.logger.debug("running operation get" + " experiment by ID = %s" % id) ret_val = Experiment.get_by_id(id) except Exception as err: current_app.logger.error("Exception = %s" % str(err)) @@ -2851,11 +3948,53 @@ class TestPersistenceDelegate(TestCase): def test_get_experiment_by_id(self): print "test_persistence_get_experiment_by_id" + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = HostingInfo(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) + host.save() + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + + dev_name = Name(name="Mohit Tahiliani") + dev_name.save() + email_id = Email(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + exp_name = "Number Systems" exp_id = "EE99777" overview = "overview" + + integration_level = 4 + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() + exp = Experiment(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], developers=[dev], + hosting_info=[host]) exp.save() exp_obj = self.persistence_delegate.get_experiment_by_id(1) @@ -2875,6 +4014,8 @@ class TestPersistenceDelegate(TestCase): def get_institute_by_id(self, id): ret_val = None try: + current_app.logger.debug("running operation get" + " institute by ID = %s" % id) ret_val = Institute.get_by_id(id) except Exception as err: current_app.logger.error("Exception = %s" % str(err)) @@ -2890,9 +4031,15 @@ class TestPersistenceDelegate(TestCase): def test_get_institute_by_id(self): print "test_persistence_get_institute_by_id" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = Institute(inst_name=inst_name, inst_id=inst_id) + inst = Institute(inst_name=inst_name, inst_id=inst_id, + assets=[asset]) inst.save() inst_obj = self.persistence_delegate.get_institute_by_id(1) @@ -2911,6 +4058,8 @@ class TestPersistenceDelegate(TestCase): def get_discipline_by_id(self, id): ret_val = None try: + current_app.logger.debug("running operation get" + " discipline by ID = %s" % id) ret_val = Discipline.get_by_id(id) except Exception as err: current_app.logger.error("Exception = %s" % str(err)) @@ -2926,9 +4075,14 @@ class TestPersistenceDelegate(TestCase): def test_get_discipline_by_id(self): print "test_persistence_get_discipline_by_id" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + dis_name = "IIT Delhi" dis_id = "EEE08" - dis = Discipline(dis_name=dis_name, dis_id=dis_id) + dis = Discipline(dis_name=dis_name, dis_id=dis_id, assets=[asset]) dis.save() dis_obj = self.persistence_delegate.get_discipline_by_id(1) @@ -2937,6 +4091,35 @@ class TestPersistenceDelegate(TestCase): #+END_SRC +*** Update Name + This function updates existing name. +#+NAME: persistence_update_name +#+BEGIN_SRC python + def update_name(self, name, n_name): + name.set(name=n_name) + name.save() + return name + +#+END_SRC + +**** Tests + +#+NAME: test_persistence_update_name +#+BEGIN_SRC python + def test_update_name(self): + print "test_update_name" + n_name = "Prof. Dharamraj" + name = Name(name=n_name) + name1 = self.persistence_delegate.add_name(name) + n_name1 = "Prof. Dharam" + name2 = self.persistence_delegate.update_name\ + (name1, n_name1) + name2 = Name.get_by_id(1) + self.assertEqual(name2.get("name"), n_name1) + +#+END_SRC + + * Infra :boilerplate: @@ -2995,9 +4178,9 @@ if __name__ == '__main__': <> <> <> -<> +<> <> -<> +<> <> <> <> @@ -3014,31 +4197,31 @@ if __name__ == '__main__': <> <> <> -<> +<> <> -<> +<> <> <> <> <> -<> +<> <> -<> +<> <> <> <> <> -<> +<> <> -<> +<> <> <> <> <> -<> +<> <> <> @@ -3065,6 +4248,8 @@ if __name__ == '__main__': <> <> <> +<> + #+end_src @@ -3078,9 +4263,9 @@ if __name__ == '__main__': <> <> <> -<> +<> <> -<> +<> <> <> @@ -3094,34 +4279,34 @@ if __name__ == '__main__': <> <> <> -<> +<> <> -<> +<> <> <> <> <> <> -<> +<> <> -<> +<> <> <> <> <> <> -<> +<> <> -<> +<> <> <> <> <> <> -<> +<> <> <> @@ -3148,6 +4333,7 @@ if __name__ == '__main__': <> <> <> +<> <> #+end_src diff --git a/src/runtime/system/persistence-delegate.org[*Org Src persistence-delegate.org[ python ]*] b/src/runtime/system/persistence-delegate.org[*Org Src persistence-delegate.org[ python ]*] new file mode 100644 index 0000000..2bc4d34 --- /dev/null +++ b/src/runtime/system/persistence-delegate.org[*Org Src persistence-delegate.org[ python ]*] @@ -0,0 +1,8 @@ + def integration_status_exists(self, integration_status): + current_app.logger.debug("running check on the existence of" + " integration_status = %s" + % integration_status) + integration_level = integration_status.get("integration_level") + current_app.logger.debug("completed check on the existence of integration_status + with integration_level = %s" % integration_level) + return integration_status == self.get_integration_status(integration_level=integration_level) diff --git a/src/runtime/system/persistence-delegate.org_archive b/src/runtime/system/persistence-delegate.org_archive new file mode 100644 index 0000000..01f0252 --- /dev/null +++ b/src/runtime/system/persistence-delegate.org_archive @@ -0,0 +1,139 @@ +# -*- mode: org -*- + + +Archived entries from file /home/osboxes/vlabs/lab-data-service/src/runtime/system/persistence-delegate.org + + +* Tests + :PROPERTIES: + :ARCHIVE_TIME: 2017-03-08 Wed 20:36 + :ARCHIVE_FILE: ~/vlabs/lab-data-service/src/runtime/system/persistence-delegate.org + :ARCHIVE_OLPATH: Persistence Delegate/Other functions/Update lab + :ARCHIVE_CATEGORY: persistence-delegate + :END: +#+NAME: test_persistence_update_lab +#+BEGIN_SRC python + def test_update_lab(self): + print "test_update_lab" + lab_name = "Data Structures" + lab_id = "cse01" + overview = "overview lab" + experiments = [] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = Asset(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = Institute(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "Electronics & Communications" + dis_id = "IITK" + discipline = Discipline(dis_name=dis_name, dis_id=dis_id, + assets=[asset]) + discipline.save() + + integration_level = 4 + integration_status = IntegrationStatus(integration_level= + integration_level) + integration_status.save() + + dev_name = Name(name="Mohit Tahiliani") + dev_name.save() + email_id = Email(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = Developer(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = HostingInfo(hosting_status=hosting_status, +<<<<<<< HEAD + hosted_url=hosted_url, + hosted_on=hosted_on) + host.save() + + lab = Lab(lab_name=lab_name, lab_id=lab_id, overview=overview, + institute=inst, discipline=discipline, + assets=[asset], hosting_info=[host], + experiments=experiments, developers=[dev], + integration_status=integration_status) + + lab1 = self.persistence_delegate.add_lab(lab) + lab_name1 = "Computer Programming" + overview1 = "overview" + + inst_name1 = "IIT Kharagpur" + inst_id1 = "IITKgp" + inst1 = Institute(inst_name=inst_name1, inst_id=inst_id1, + assets=[asset]) + inst1.save() + + dis_name1 = "Computer Science & Engineering" + dis_id1 = "IIT Kharagpur" + discipline1 = Discipline(dis_name=dis_name1, dis_id=dis_id1, + assets=[asset]) + discipline1.save() + + integration_level1 = 2 + integration_status1 = IntegrationStatus(integration_level=\ + integration_level1) + integration_status1.save() + + hosting_status1 = "hosted" + hosted_url1 = "http://cse13-iiith.vlabs.ac.in" + hosted_on1 = "cloud" + host1 = HostingInfo(hosting_status=hosting_status1, + hosted_url=hosted_url1, + hosted_on=hosted_on1) + host1.save() + + dev_name1 = Name(name="Tahiliani") + dev_name1.save() + email_id1 = Email(email="tahiliani@gmail.com") + email_id1.save() + dev1 = Developer(name=dev_name1, email=email_id1, + institute=inst1, discipline=discipline1) + dev1.save() + + asset_type1 = "Image" + path1 = "vlabs.ac.in/images/static/image.png" + asset1 = Asset(asset_type=asset_type1, path=path1) + asset1.save() + + lab2 = self.persistence_delegate.update_lab\ + (lab1, lab_name1, overview1, inst1, discipline1, +<<<<<<< HEAD + integration_status1, [host1]), +======= + integration_status1, [host1], [dev1], [asset1]), +>>>>>>> 830b5761a140520bffe83bde09764b7ce20f709e + lab2 = Lab.get_by_id(1) + + self.assertEqual(lab2.get("lab_id"), lab_id) + self.assertEqual(lab2.get("lab_name"), lab_name1) + self.assertEqual(lab2.get("overview"), overview1) + self.assertEqual(lab2.get("institute").get("inst_id"), + inst1.get("inst_id")) + self.assertEqual(lab2.get("discipline").get("dis_id"), + discipline1.get("dis_id")) + self.assertEqual(lab2.get("integration_status"). + get("integration_level"), + integration_status1.get("integration_level")) + + self.assertEqual(lab2.get("hosting_info")[0].get("hosted_url"), + hosted_url1) + self.assertEqual(lab2.get("developers")[0].get("email").get("email"), + email_id1.get("email")) + self.assertEqual(lab2.get("assets")[0].get("path"), + asset1.get("path")) + + +#+END_SRC + + diff --git a/src/runtime/system/system-interface.org b/src/runtime/system/system-interface.org index acc0842..6af7491 100755 --- a/src/runtime/system/system-interface.org +++ b/src/runtime/system/system-interface.org @@ -1,3 +1,4 @@ + #+TITLE: System Interface implementation for LDS #+AUTHOR: VLEAD #+DATE: [2016-07-22 Tue] @@ -36,7 +37,11 @@ class SystemInterface (): session_cls = System.delegate.entities['session'] lab_cls = System.delegate.entities['lab'] exp_cls = System.delegate.entities['experiment'] + name_cls = System.delegate.entities['name'] email_cls = System.delegate.entities['email'] + developer_cls = System.delegate.entities['developer'] + asset_cls = System.delegate.entities['asset'] + hosting_info_cls = System.delegate.entities['hosting_info'] session = session_cls(key=data_dict['key']) del(data_dict['key']) @@ -51,38 +56,56 @@ class SystemInterface (): institute = System.do("get_institute", inst_id=inst_id) integration_level = data_dict['integration_level'] - integrationstatus = System.do("get_integrationstatus", integration_level=integration_level) + integration_status = System.do("get_integration_status", + integration_level=integration_level) dis_id = data_dict['dis_id'] discipline = System.do("get_discipline", dis_id=dis_id) + assets = data_dict['assets'] asset_list = [] - for asset in assets: - asset = System.do("get_asset", path=asset) + for asset_x in assets: + asset = System.do("get_asset", path=asset_x['path']) + if asset is None: + asset = asset_cls(asset_type=str(asset_x['asset_type']), \ + path=str(asset_x['path'])) + asset = System.do("add_asset", asset=asset, session=session) asset_list.append(asset) developers = data_dict['developers'] developer_list = [] - for d_id in developers: - email = email_cls(email=d_id) + for developer_x in developers: + name = name_cls(name=developer_x['name']) + email = email_cls(email=developer_x['email']) developer = System.do("get_developer", email=email) + institute = System.do("get_institute", inst_id=developer_x['inst_id']) + discipline = System.do("get_discipline", dis_id=developer_x['dis_id']) + if developer is None: + developer = developer_cls(name=name, email=email, institute=institute, discipline=discipline) + developer = System.do("add_developer", developer=developer, session=session) developer_list.append(developer) - hosted_url = data_dict['hosted_url'] - hostinginfo = System.do("get_hostinginfo", hosted_url=hosted_url) + hosting_info = data_dict['hosting_info'] + hosting_info_list = [] + for hosting_info_x in hosting_info: + hosting_info = System.do("get_hosting_info", hosted_url=hosting_info_x['hosted_url']) + if hosting_info is None: + hosting_info = hosting_info_cls(hosting_status=str(hosting_info_x['hosting_status']), \ + hosted_url=str(hosting_info_x['hosted_url']), hosted_on=str(hosting_info_x['hosted_on'])) + hosting_info = System.do("add_hosting_info", hosting_info=hosting_info, session=session) + hosting_info_list.append(hosting_info) lab = lab_cls(lab_name=data_dict['lab_name'], lab_id=data_dict['lab_id'], overview=data_dict['overview'], institute=institute, - integrationstatus=integrationstatus, + integration_status=integration_status, discipline=discipline, assets=asset_list, experiments=exp_list, developers=developer_list, - hostinginfo=hostinginfo) - + hosting_info=hosting_info_list) try: current_app.logger.debug("running operation add_lab") lab = System.do("add_lab", lab=lab, session=session) @@ -119,26 +142,34 @@ class TestAddLab(TestCase): print "test_add_lab_in_system_interface" data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [] - } + 'key' : KEY, + 'integration_level': 4 + } - experiment = SystemInterface.add_experiment(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) data_dict = { 'key' : KEY, - 'integration_level': 4 - } + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = { + 'key' : KEY, + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud' + } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + hosting_info = SystemInterface.add_hosting_info(data_dict) data_dict = { 'key' : KEY, 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } institute = SystemInterface.add_institute(data_dict) @@ -146,47 +177,72 @@ class TestAddLab(TestCase): data_dict = { 'key' : KEY, 'dis_name': 'computer science', - 'dis_id': 'CSE' + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } discipline = SystemInterface.add_discipline(data_dict) - data_dict = { - 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' - } - - asset = SystemInterface.add_asset(data_dict) - data_dict = { 'key' : KEY, 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } developer = SystemInterface.add_developer(data_dict) - - data_dict = { - 'key' : KEY, - 'hosting_status': 'hosted', - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'hosted_on': 'cloud' - } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) - - data_dict = {'lab_name': 'data structure', - 'lab_id': 'cse02', - 'overview': 'overview', + data_dict = { 'key': KEY, + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'sections': [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [], 'integration_level': 4, - 'experiments': ['exp123'], - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + } + + experiment = SystemInterface.add_experiment(data_dict) + + data_dict = {'lab_name': 'data structure', + 'lab_id': 'cse02', + 'overview': 'overview', + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + 'integration_level': 4, + 'experiments': ['exp123'] } lab = SystemInterface.add_lab(data_dict) @@ -197,14 +253,14 @@ class TestAddLab(TestCase): self.assertEqual(lab.get("lab_id"), data_dict['lab_id']) self.assertEqual(lab.get("institute").get("inst_id"), data_dict['inst_id']) - self.assertEqual(lab.get("integrationstatus").get("integration_level"), + self.assertEqual(lab.get("integration_status").get("integration_level"), data_dict['integration_level']) self.assertEqual(lab.get("discipline").get("dis_id"), data_dict['dis_id']) self.assertEqual(lab.get("assets")[0].get("path"), - 'vlabs.ac.in/images/static/logo.png'), - self.assertEqual(lab.get("hostinginfo").get("hosted_url"), - data_dict['hosted_url']) + 'vlabs.ac.in/images/static/logo.png') + self.assertEqual(lab.get("hosting_info")[0].get("hosted_url"), + 'http://cse14-iiith.vlabs.ac.in') self.assertEqual(lab.get("experiments")[0].get("exp_name"), 'arrays') self.assertEqual(lab.get("experiments")[0].get("exp_id"), 'exp123') self.assertEqual(lab.get("developers")[0].get("email").get("email"), 'abc@gmail.com') @@ -213,26 +269,34 @@ class TestAddLab(TestCase): print "test_add_lab_raises_type_error_in_system_interface" data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [] - } + 'key' : KEY, + 'integration_level': 4 + } - experiment = SystemInterface.add_experiment(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) data_dict = { 'key' : KEY, - 'integration_level': 4 - } + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = { + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY + } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + hosting_info = SystemInterface.add_hosting_info(data_dict) data_dict = { 'key' : KEY, 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } institute = SystemInterface.add_institute(data_dict) @@ -240,47 +304,75 @@ class TestAddLab(TestCase): data_dict = { 'key' : KEY, 'dis_name': 'computer science', - 'dis_id': 'CSE' + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } discipline = SystemInterface.add_discipline(data_dict) - data_dict = { - 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' - } - - asset = SystemInterface.add_asset(data_dict) - data_dict = { 'key' : KEY, 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } developer = SystemInterface.add_developer(data_dict) data_dict = { - 'hosting_status': 'hosted', - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'hosted_on': 'cloud', - 'key' : KEY + 'key': KEY, + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'integration_level': 4, + 'sections': [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) - + experiment = SystemInterface.add_experiment(data_dict) + data_dict = {'lab_name': 'data structure', 'lab_id': 123, 'overview': 'overview', 'key': KEY, 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], 'experiments': ['exp123'], 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } with self.assertRaises(TypeError): @@ -297,22 +389,87 @@ class TestAddLab(TestCase): session_cls = System.delegate.entities['session'] section_cls = System.delegate.entities['section'] experiment_cls = System.delegate.entities['experiment'] - + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] + developer_cls = System.delegate.entities['developer'] + name_cls = System.delegate.entities['name'] + email_cls = System.delegate.entities['email'] + hosting_info_cls = System.delegate.entities['hosting_info'] + asset_cls = System.delegate.entities['asset'] session = session_cls(key=data_dict['key']) del(data_dict['key']) sections = data_dict['sections'] - data_dict['sections'] = [] + section_list = [] + for section_x in sections: + section = System.do("get_section", name=section_x) + if section is None: + section = section_cls(name=str(section_x)) + section = System.do("add_section", section=section, session=session) + section_list.append(section) + + inst_id = data_dict['inst_id'] + institute = System.do("get_institute", inst_id=inst_id) + + dis_id = data_dict['dis_id'] + discipline = System.do("get_discipline", dis_id=dis_id) + + integration_level = data_dict['integration_level'] + integration_status = System.do("get_integration_status", + integration_level=integration_level) + + assets = data_dict['assets'] + asset_list = [] + for asset_x in assets: + asset = System.do("get_asset", path=asset_x['path']) + if asset is None: + asset = asset_cls(asset_type=str(asset_x['asset_type']), \ + path=str(asset_x['path'])) + asset = System.do("add_asset", asset=asset, session=session) + asset_list.append(asset) + + developers = data_dict['developers'] + developer_list = [] + for developer_x in developers: + name = name_cls(name=developer_x['name']) + email = email_cls(email=developer_x['email']) + developer = System.do("get_developer", email=email) + institute = System.do("get_institute", inst_id=developer_x['inst_id']) + discipline = System.do("get_discipline", dis_id=developer_x['dis_id']) + if developer is None: + developer = developer_cls(name=name, email=email, + institute=institute, + discipline=discipline) + developer = System.do("add_developer", developer=developer, + session=session) + developer_list.append(developer) + + hosting_info = data_dict['hosting_info'] + hosting_info_list = [] + for hosting_info_x in hosting_info: + hosting_info = System.do("get_hosting_info", hosted_url=hosting_info_x['hosted_url']) + if hosting_info is None: + hosting_info = hosting_info_cls(hosting_status=str(hosting_info_x['hosting_status']), \ + hosted_url=str(hosting_info_x['hosted_url']), hosted_on=str(hosting_info_x['hosted_on'])) + hosting_info = System.do("add_hosting_info", hosting_info=hosting_info, session=session) + hosting_info_list.append(hosting_info) experiment = experiment_cls(exp_name=data_dict['exp_name'], exp_id=data_dict['exp_id'], overview=data_dict['overview'], - sections=data_dict['sections']) + sections=section_list, + institute=institute, + discipline=discipline, + assets=asset_list, + integration_status=integration_status, + developers=developer_list, + hosting_info=hosting_info_list) try: current_app.logger.debug("running operation add_experiment") - question = System.do("add_experiment", experiment=experiment, + experiment = System.do("add_experiment", experiment=experiment, session=session) current_app.logger.debug("completed operation add_experiment") + return experiment except (ArityError, TypeError, NotAuthorizedError, StateError) as err: current_app.logger.error("Exception = %s" % str(err)) @@ -322,26 +479,6 @@ class TestAddLab(TestCase): current_app.logger.error("Exception = %s" % str(err)) raise err - section_list = [] - try: - for section in sections: - section = section_cls(name=str(section)) - section_list.append(section) - current_app.logger.debug("running operation" - "add_sections_to_experiments") - experiment = System.do("add_sections_to_experiment", - sections=section_list, - experiment=experiment, - session=session) - current_app.logger.debug("running operation" - "add_sections_to_experiment") - return experiment.to_client() - - except Exception as e: - experiment.delete() - current_app.logger.error("Exception = %s" % str(e)) - raise e - #+end_src *** TestAddExperiment @@ -362,52 +499,226 @@ class TestAddExperiment(TestCase): def test_add_experiment_in_system_interface(self): print "test_add_experiment_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + discipline = SystemInterface.add_discipline(data_dict) + + data_dict = { + 'key' : KEY, + 'integration_level': 4 + } + + integration_status = SystemInterface.add_integration_status(data_dict) + + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' + } + + developer = SystemInterface.add_developer(data_dict) + + data_dict = { + 'key' : KEY, + 'name': 'Theory' + } + section = SystemInterface.add_section(data_dict) + + data_dict = { + 'key' : KEY, + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud' + } + + hosting_info = SystemInterface.add_hosting_info(data_dict) + data_dict = { 'key' : KEY, 'exp_name': 'array', 'exp_id': 'cse02', 'overview': 'overview', - 'sections': ["Introduction", "Quize"] - } + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + 'sections': ['Theory'] + } experiment = SystemInterface.add_experiment(data_dict) - + self.assertEqual(experiment.get("exp_name"), data_dict['exp_name']) self.assertEqual(experiment.get("exp_id"), data_dict['exp_id']) - + self.assertEqual(experiment.get("institute").get("inst_id"), + data_dict['inst_id']) + self.assertEqual(experiment.get("discipline").get("dis_id"), + data_dict['dis_id']) + self.assertEqual(experiment.get("integration_status").get("integration_level"), + data_dict['integration_level']) + self.assertEqual(experiment.get("assets")[0].get("path"), + 'vlabs.ac.in/images/static/logo.png') + self.assertEqual(experiment.get("hosting_info")[0].get("hosted_url"), + 'http://cse14-iiith.vlabs.ac.in') + self.assertEqual(experiment.get("developers")[0].get("email").\ + get("email"), 'abc@gmail.com') + self.assertEqual(experiment.get("sections")[0].get("name"), 'Theory') + def test_add_experiment_raises_type_error_in_system_interface(self): print "test_add_experiment_raises_type_error_in_system_interface" data_dict = { - 'key': KEY, - 'exp_name': 'cse02', - 'overview': 'overview', - 'exp_id': 123, - 'sections': ["Theory", "Procedure"] - } - with self.assertRaises(TypeError): - SystemInterface.add_experiment(data_dict) - #+END_SRC + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + asset = SystemInterface.add_asset(data_dict) -** Add Institute -#+NAME: class_add_institute -#+begin_src python - @staticmethod - def add_institute(data_dict): - session_cls = System.delegate.entities['session'] - institute_cls = System.delegate.entities['institute'] + data_dict = { + 'key' : KEY, + 'name': 'Procedure' + } + section = SystemInterface.add_section(data_dict) - session = session_cls(key=data_dict['key']) - del(data_dict['key']) - institute = institute_cls(inst_name=str(data_dict['inst_name']), - inst_id=str(data_dict['inst_id'])) + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } - try: - current_app.logger.debug("running operation add_institute") - institute = System.do("add_institute", institute=institute, + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + discipline = SystemInterface.add_discipline(data_dict) + + data_dict = { + 'key' : KEY, + 'integration_level': 4 + } + + integration_status = SystemInterface.add_integration_status(data_dict) + + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' + } + + developer = SystemInterface.add_developer(data_dict) + + data_dict = { + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY + } + + hosting_info = SystemInterface.add_hosting_info(data_dict) + + data_dict = { + 'key': KEY, + 'exp_name': 'cse02', + 'overview': 'overview', + 'integration_level': 4, + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'exp_id': 123, + 'sections': ["Theory", "Procedure"], + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + } + with self.assertRaises(TypeError): + SystemInterface.add_experiment(data_dict) + #+END_SRC + + +** Add Institute +#+NAME: class_add_institute +#+begin_src python + @staticmethod + def add_institute(data_dict): + session_cls = System.delegate.entities['session'] + institute_cls = System.delegate.entities['institute'] + asset_cls = System.delegate.entities['asset'] + + session = session_cls(key=data_dict['key']) + del(data_dict['key']) + + assets = data_dict['assets'] + asset_list = [] + for asset in assets: + asset = System.do("get_asset", path=asset) + asset_list.append(asset) + institute = institute_cls(inst_name=str(data_dict['inst_name']), + inst_id=str(data_dict['inst_id']), + assets=asset_list) + + try: + current_app.logger.debug("running operation add_institute") + institute = System.do("add_institute", institute=institute, session=session) current_app.logger.debug("completed operation add_institute") return institute.to_client() @@ -439,10 +750,19 @@ class TestAddInstitute(TestCase): def test_add_institute_in_system_interface(self): print "test_add_institute_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + data_dict = { 'key' : KEY, 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } institute = SystemInterface.add_institute(data_dict) @@ -452,7 +772,28 @@ class TestAddInstitute(TestCase): self.assertEqual(institute.get("inst_name"), data_dict['inst_name']) self.assertEqual(institute.get("inst_id"), data_dict['inst_id']) - + self.assertEqual(institute.get("assets")[0].get("path"), + 'vlabs.ac.in/images/static/logo.png') + +# def test_add_institute_raises_type_error_in_system_interface(self): +# print "test_add_institute_raises_type_error_in_system_interface" + +# data_dict = { +# 'key' : KEY, +# 'asset_type': 'Image', +# 'path': 'vlabs.ac.in/images/static/logo.png' +# } + +# asset = SystemInterface.add_asset(data_dict) + +# data_dict = { +# 'key' : KEY, +# 'inst_name': 'IIT Kanpur', +# 'inst_id': 123, +# 'assets': ['vlabs.ac.in/images/static/logo.png'] +# } +# with self.assertRaises(TypeError): +# SystemInterface.add_institute(data_dict) #+END_SRC @@ -464,10 +805,19 @@ class TestAddInstitute(TestCase): def add_discipline(data_dict): session_cls = System.delegate.entities['session'] discipline_cls = System.delegate.entities['discipline'] + asset_cls = System.delegate.entities['asset'] session = session_cls(key=data_dict['key']) + + assets = data_dict['assets'] + asset_list = [] + for asset in assets: + asset = System.do("get_asset", path=asset) + asset_list.append(asset) + discipline = discipline_cls(dis_name=data_dict['dis_name'], - dis_id=data_dict['dis_id']) + dis_id=data_dict['dis_id'], + assets=asset_list) try: current_app.logger.debug("running operation add_discipline") question = System.do("add_discipline", discipline=discipline, @@ -505,10 +855,19 @@ class TestAddDiscipline(TestCase): def test_add_discipline_in_system_interface(self): print "test_add_discipline_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + data_dict = { 'key' : KEY, 'dis_name': 'array', - 'dis_id': 'cse02' + 'dis_id': 'cse02', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } discipline = SystemInterface.add_discipline(data_dict) @@ -516,14 +875,25 @@ class TestAddDiscipline(TestCase): self.assertEqual(discipline.get("dis_name"), data_dict['dis_name']) self.assertEqual(discipline.get("dis_id"), data_dict['dis_id']) + self.assertEqual(discipline.get("assets")[0].get("path"), + 'vlabs.ac.in/images/static/logo.png') def test_add_discipline_raises_type_error_in_system_interface(self): print "test_add_discipline_raises_type_error_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + data_dict = { 'key' : KEY, 'dis_name': 'cse02', - 'dis_id': 123 + 'dis_id': 123, + 'assets': ['vlabs.ac.in/images/static/logo.png'] } with self.assertRaises(TypeError): SystemInterface.add_discipline(data_dict) @@ -597,27 +967,27 @@ class TestAddSection(TestCase): #+END_SRC -** Add HostingInfo -#+NAME: class_add_hostinginfo +** Add Hosting_Info +#+NAME: class_add_hosting_info #+begin_src python @staticmethod - def add_hostinginfo(data_dict): + def add_hosting_info(data_dict): session_cls = System.delegate.entities['session'] - hostinginfo_cls = System.delegate.entities['hostinginfo'] + hosting_info_cls = System.delegate.entities['hosting_info'] session = session_cls(key=data_dict['key']) del(data_dict['key']) - hostinginfo = hostinginfo_cls(hosting_status=str(data_dict['hosting_status']), + hosting_info = hosting_info_cls(hosting_status=str(data_dict['hosting_status']), hosted_url=str(data_dict['hosted_url']), hosted_on=str(data_dict['hosted_on'])) try: - current_app.logger.debug("running operation add_hostinginfo") - hostinginfo = System.do("add_hostinginfo", hostinginfo=hostinginfo, + current_app.logger.debug("running operation add_hosting_info") + hosting_info = System.do("add_hosting_info", hosting_info=hosting_info, session=session) - current_app.logger.debug("completed operation add_hostinginfo") - return hostinginfo.to_client() + current_app.logger.debug("completed operation add_hosting_info") + return hosting_info.to_client() except (ArityError, TypeError, NotAuthorizedError, StateError) as err: current_app.logger.error("Exception = %s" % str(err)) @@ -628,10 +998,10 @@ class TestAddSection(TestCase): raise err #+END_SRC -*** TestAddHostingInfo - #+NAME: test_class_add_hostinginfo +*** TestAddHosting_Info + #+NAME: test_class_add_hosting_info #+BEGIN_SRC python -class TestAddHostingInfo(TestCase): +class TestAddHosting_Info(TestCase): def create_app(self): app = create_app(config) return app @@ -643,8 +1013,8 @@ class TestAddHostingInfo(TestCase): db.session.remove() db.drop_all() - def test_add_hostinginfo_in_system_interface(self): - print "test_add_hostinginfo_in_system_interface" + def test_add_hosting_info_in_system_interface(self): + print "test_add_hosting_info_in_system_interface" data_dict = { 'key' : KEY, @@ -653,14 +1023,14 @@ class TestAddHostingInfo(TestCase): 'hosted_on': 'cloud' } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) - hostinginfo_cls = System.delegate.entities['hostinginfo'] - hostinginfo = hostinginfo_cls.get_all()[0] + hosting_info = SystemInterface.add_hosting_info(data_dict) + hosting_info_cls = System.delegate.entities['hosting_info'] + hosting_info = hosting_info_cls.get_all()[0] - self.assertEqual(hostinginfo.get("hosting_status"), + self.assertEqual(hosting_info.get("hosting_status"), data_dict['hosting_status']) - self.assertEqual(hostinginfo.get("hosted_url"), data_dict['hosted_url']) - self.assertEqual(hostinginfo.get("hosted_on"), data_dict['hosted_on']) + self.assertEqual(hosting_info.get("hosted_url"), data_dict['hosted_url']) + self.assertEqual(hosting_info.get("hosted_on"), data_dict['hosted_on']) #+END_SRC @@ -794,68 +1164,6 @@ class TestAddEmail(TestCase): SystemInterface.add_email(data_dict) #+END_SRC -#** Get Emails -#+NAME: class_get_emails -#+begin_src python - @staticmethod - def get_emails(): - email_cls = System.delegate.entities['email'] - try: - current_app.logger.debug("getting emails") - emails = email_cls.get_all() - email_dict_list = [] - for email in emails: - email_x = email.to_client() - email_dict_list.append(email_x) - current_app.logger.debug("got emails") - return email_dict_list - - except (ArityError, TypeError, NotAuthorizedError, StateError) as err: - current_app.logger.error("Exception = %s" % str(err)) - raise err - - except Exception as err: - current_app.logger.error("Exception = %s" % str(err)) - raise err -#+end_src - -#*** TestGetEmails - #+NAME: test_class_get_emails - #+BEGIN_SRC python -class TestGetEmails(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_emails_in_system_interface(self): - print "test_get_emails_in_system_interface" - - data_dict = {'email': 'dharamaraj@gmail.com', - 'key': KEY - } - - data_dict1 = {'email': 'raja@gmail.com', - 'key': KEY - } - - email1 = SystemInterface.add_email(data_dict) - email2 = SystemInterface.add_email(data_dict1) - - emails_list = SystemInterface.get_emails() - - self.assertEqual(emails_list[0].get("email"), data_dict['email']) - self.assertEqual(emails_list[1].get("email"), data_dict1['email']) - - #+END_SRC - ** Add Developer #+NAME: class_add_developer @@ -866,12 +1174,21 @@ class TestGetEmails(TestCase): name_cls = System.delegate.entities['name'] email_cls = System.delegate.entities['email'] developer_cls = System.delegate.entities['developer'] + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] session = session_cls(key=data_dict['key']) name = name_cls(name=str(data_dict['name'])) email = email_cls(email=str(data_dict['email'])) - developer = developer_cls(name=name, email=email) + inst_id = data_dict['inst_id'] + institute = System.do("get_institute", inst_id=inst_id) + + dis_id = data_dict['dis_id'] + discipline = System.do("get_discipline", dis_id=dis_id) + + developer = developer_cls(name=name, email=email, + institute=institute, discipline=discipline) try: current_app.logger.debug("running operation add_developer") @@ -910,9 +1227,37 @@ class TestAddDeveloper(TestCase): print "test_add_developer_in_system_interface" data_dict = { - 'key': KEY, - 'name': 'Prof. S. Dharmaraja', - 'email': 'dharmar@maths.iitd.ac.in' + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + discipline = SystemInterface.add_discipline(data_dict) + + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } developer = SystemInterface.add_developer(data_dict) @@ -936,25 +1281,25 @@ class TestAddDeveloper(TestCase): #+END_SRC -** Add IntegrationStatus -#+NAME: class_add_integrationstatus +** Add Integration_Status +#+NAME: class_add_integration_status #+begin_src python @staticmethod - def add_integrationstatus(data_dict): + def add_integration_status(data_dict): session_cls = System.delegate.entities['session'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] + integration_status_cls = System.delegate.entities['integration_status'] session = session_cls(key=data_dict['key']) del(data_dict['key']) - integrationstatus = integrationstatus_cls(integration_level=data_dict['integration_level']) + integration_status = integration_status_cls(integration_level=data_dict['integration_level']) try: - current_app.logger.debug("running operation add_integrationstatus") - integrationstatus = System.do("add_integrationstatus", integrationstatus=integrationstatus, + current_app.logger.debug("running operation add_integration_status") + integration_status = System.do("add_integration_status", integration_status=integration_status, session=session) - current_app.logger.debug("completed operation add_integrationstatus") - return integrationstatus.to_client() + current_app.logger.debug("completed operation add_integration_status") + return integration_status.to_client() except (ArityError, TypeError, NotAuthorizedError, StateError) as err: current_app.logger.error("Exception = %s" % str(err)) @@ -965,10 +1310,10 @@ class TestAddDeveloper(TestCase): raise err #+END_SRC -*** TestAddIntegrationStatus - #+NAME: test_class_add_integrationstatus +*** TestAddIntegration_Status + #+NAME: test_class_add_integration_status #+BEGIN_SRC python -class TestAddIntegrationStatus(TestCase): +class TestAddIntegration_Status(TestCase): def create_app(self): app = create_app(config) return app @@ -980,19 +1325,19 @@ class TestAddIntegrationStatus(TestCase): db.session.remove() db.drop_all() - def test_add_integrationstatus_in_system_interface(self): - print "test_add_integrationstatus_in_system_interface" + def test_add_integration_status_in_system_interface(self): + print "test_add_integration_status_in_system_interface" data_dict = { 'key' : KEY, 'integration_level': 4 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) - integrationstatus_cls = System.delegate.entities['integrationstatus'] - integrationstatus = integrationstatus_cls.get_all()[0] + integration_status = SystemInterface.add_integration_status(data_dict) + integration_status_cls = System.delegate.entities['integration_status'] + integration_status = integration_status_cls.get_all()[0] - self.assertEqual(integrationstatus.get("integration_level"), + self.assertEqual(integration_status.get("integration_level"), data_dict['integration_level']) #+END_SRC @@ -1005,7 +1350,7 @@ class TestAddIntegrationStatus(TestCase): def get_labs(): lab_cls = System.delegate.entities['lab'] try: - current_app.logger.debug("getting labs") + current_app.logger.debug("running operation get labs") labs = lab_cls.get_all() lab_dict_list = [] for lab in labs: @@ -1042,99 +1387,139 @@ class TestGetLabsByLabName(TestCase): def test_get_labs_in_system_interface(self): print "test_get_labs_in_system_interface" - data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [] - } - - experiment = SystemInterface.add_experiment(data_dict) - data_dict = { 'key' : KEY, 'integration_level': 4 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) data_dict = { 'key' : KEY, - 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' - } - - institute = SystemInterface.add_institute(data_dict) + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + asset = SystemInterface.add_asset(data_dict) + data_dict = { 'key' : KEY, - 'dis_name': 'computer science', - 'dis_id': 'CSE' + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud' } - discipline = SystemInterface.add_discipline(data_dict) + hosting_info = SystemInterface.add_hosting_info(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } - asset1 = SystemInterface.add_asset(data_dict) + institute = SystemInterface.add_institute(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/icon.png', - } + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } - asset2 = SystemInterface.add_asset(data_dict) + discipline = SystemInterface.add_discipline(data_dict) data_dict = { 'key' : KEY, 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } developer = SystemInterface.add_developer(data_dict) data_dict = { - 'key' : KEY, - 'hosting_status': 'hosted', - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'hosted_on': 'cloud' + 'key': KEY, + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'sections': [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) + experiment = SystemInterface.add_experiment(data_dict) data_dict = {'lab_name': 'data structure', - 'lab_id': 'cse01', - 'key': KEY, + 'lab_id': 'cse02', 'overview': 'overview', + 'key': KEY, 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], - 'experiments': ['exp123'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'experiments': ['exp123'] } - data_dict1 = {'lab_name': "Automata data", + data_dict1 = {'lab_name': "data Automata", 'lab_id': 'DFA', 'key': KEY, 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/icon.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } - lab1 = SystemInterface.add_lab(data_dict) lab2 = SystemInterface.add_lab(data_dict1) @@ -1157,7 +1542,8 @@ class TestGetLabsByLabName(TestCase): def get_labs_by_keyword_lab_name(keyword): lab_cls = System.delegate.entities['lab'] try: - current_app.logger.debug("getting labs") + current_app.logger.debug("running get labs by keyword" + " lab name") labs = lab_cls.get_all() labs_match_list=[] for lab in labs: @@ -1165,7 +1551,7 @@ class TestGetLabsByLabName(TestCase): if keyword.lower() in (lab_x['lab_name']).lower(): labs_match_list.append(lab_x) - current_app.logger.debug("got labs") + current_app.logger.debug("got labs by keyword lab name") return labs_match_list except (ArityError, TypeError, NotAuthorizedError, StateError) as err: @@ -1180,7 +1566,7 @@ class TestGetLabsByLabName(TestCase): *** TestGetLabsByKeywordLabName #+NAME: test_class_get_labs_by_keyword_lab_name #+BEGIN_SRC python -class TestGetLabs(TestCase): +class TestGetLabsByKeywordLabName(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -1196,83 +1582,111 @@ class TestGetLabs(TestCase): def test_get_labs_by_keyword_lab_in_system_interface(self): print "test_get_labs_by_keyword_lab_name_in_system_interface" - data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [] - } - - experiment = SystemInterface.add_experiment(data_dict) - data_dict = { 'key' : KEY, 'integration_level': 4 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) data_dict = { 'key' : KEY, - 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' - } - - institute = SystemInterface.add_institute(data_dict) + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + asset = SystemInterface.add_asset(data_dict) + data_dict = { 'key' : KEY, - 'dis_name': 'computer science', - 'dis_id': 'CSE' + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud' } - discipline = SystemInterface.add_discipline(data_dict) + hosting_info = SystemInterface.add_hosting_info(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } - asset1 = SystemInterface.add_asset(data_dict) + institute = SystemInterface.add_institute(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/icon.png', - } + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } - asset2 = SystemInterface.add_asset(data_dict) + discipline = SystemInterface.add_discipline(data_dict) data_dict = { 'key' : KEY, 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } developer = SystemInterface.add_developer(data_dict) data_dict = { - 'key' : KEY, - 'hosting_status': 'hosted', - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'hosted_on': 'cloud' + 'key': KEY, + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'sections': [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) + experiment = SystemInterface.add_experiment(data_dict) data_dict = {'lab_name': 'data structure', - 'lab_id': 'cse01', - 'key': KEY, + 'lab_id': 'cse02', 'overview': 'overview', + 'key': KEY, 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], - 'experiments': ['exp123'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'experiments': ['exp123'] } data_dict1 = {'lab_name': "data Automata", @@ -1281,11 +1695,24 @@ class TestGetLabs(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/icon.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } @@ -1351,26 +1778,35 @@ class TestGetLabsByInstitute(TestCase): print "test_get_labs_by_institute_in_system_interface" data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [] + 'key' : KEY, + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud' } - experiment = SystemInterface.add_experiment(data_dict) + hosting_info = SystemInterface.add_hosting_info(data_dict) data_dict = { 'key' : KEY, 'integration_level': 4 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + data_dict = { 'key' : KEY, 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } institute = SystemInterface.add_institute(data_dict) @@ -1378,18 +1814,21 @@ class TestGetLabsByInstitute(TestCase): data_dict = { 'key' : KEY, 'dis_name': 'computer science', - 'dis_id': 'CSE' + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } discipline = SystemInterface.add_discipline(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } - asset1 = SystemInterface.add_asset(data_dict) + developer = SystemInterface.add_developer(data_dict) data_dict = { 'key' : KEY, @@ -1401,20 +1840,32 @@ class TestGetLabsByInstitute(TestCase): data_dict = { 'key': KEY, - 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' - } - - developer = SystemInterface.add_developer(data_dict) - - data_dict = { - 'key' : KEY, - 'hosting_status': 'hosted', - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'hosted_on': 'cloud' + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, + 'sections': [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + 'inst_id': 'IITK', + 'dis_id': 'CSE' } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) + experiment = SystemInterface.add_experiment(data_dict) data_dict = { 'key' : KEY, @@ -1423,11 +1874,24 @@ class TestGetLabsByInstitute(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } data_dict1 = { @@ -1437,11 +1901,24 @@ class TestGetLabsByInstitute(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/icon.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } lab = SystemInterface.add_lab(data_dict) @@ -1464,7 +1941,7 @@ class TestGetLabsByInstitute(TestCase): try: current_app.logger.debug("running operation get_labs_by_discipline") labs = System.do("get_labs_by_discipline", discipline=discipline) - current_app.logger.debug("completed operation get_labs_by_institute") + current_app.logger.debug("completed operation get_labs_by_discipline") labs_dict_list = [] for lab in labs: lab_x = lab.to_client() @@ -1502,68 +1979,92 @@ class TestGetLabsByDiscipline(TestCase): data_dict = { 'key' : KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections' : [] + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud' } - experiment = SystemInterface.add_experiment(data_dict) + hosting_info = SystemInterface.add_hosting_info(data_dict) data_dict = { 'key' : KEY, 'integration_level': 4 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) data_dict = { 'key' : KEY, - 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' } - institute = SystemInterface.add_institute(data_dict) + asset = SystemInterface.add_asset(data_dict) data_dict = { 'key' : KEY, - 'dis_name': 'Computer Science', - 'dis_id': 'CSE' - } + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/icon.png' + } - discipline = SystemInterface.add_discipline(data_dict) + asset2 = SystemInterface.add_asset(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' - } + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } - asset1 = SystemInterface.add_asset(data_dict) + institute = SystemInterface.add_institute(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/icon.png' + 'dis_name': 'Computer Science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } - asset2 = SystemInterface.add_asset(data_dict) + discipline = SystemInterface.add_discipline(data_dict) data_dict = { - 'key': KEY, + 'key' : KEY, 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } developer = SystemInterface.add_developer(data_dict) + data_dict = { 'key' : KEY, - 'hosting_status': 'hosted', - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'hosted_on': 'cloud' + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, + 'sections' : [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + 'inst_id': 'IITK', + 'dis_id': 'CSE' } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) + experiment = SystemInterface.add_experiment(data_dict) data_dict = { 'key' : KEY, @@ -1572,11 +2073,24 @@ class TestGetLabsByDiscipline(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } data_dict1 = { @@ -1586,11 +2100,24 @@ class TestGetLabsByDiscipline(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/icon.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } lab = SystemInterface.add_lab(data_dict) @@ -1649,26 +2176,34 @@ class TestGetLabsByLabName(TestCase): print "test_get_labs_by_lab_name_in_system_interface" data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [] + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY } - experiment = SystemInterface.add_experiment(data_dict) + hosting_info = SystemInterface.add_hosting_info(data_dict) data_dict = { 'key' : KEY, 'integration_level': 4 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) data_dict = { 'key' : KEY, 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } institute = SystemInterface.add_institute(data_dict) @@ -1676,34 +2211,50 @@ class TestGetLabsByLabName(TestCase): data_dict = { 'key' : KEY, 'dis_name': 'computer science', - 'dis_id': 'CSE' + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } discipline = SystemInterface.add_discipline(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' - } - - asset = SystemInterface.add_asset(data_dict) - - data_dict = { - 'key': KEY, 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } developer = SystemInterface.add_developer(data_dict) + data_dict = { - 'hosting_status': 'hosted', - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'hosted_on': 'cloud', - 'key' : KEY + 'key': KEY, + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, + 'sections': [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + 'inst_id': 'IITK', + 'dis_id': 'CSE' } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) + experiment = SystemInterface.add_experiment(data_dict) data_dict = { 'key' : KEY, @@ -1712,11 +2263,24 @@ class TestGetLabsByLabName(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } data_dict1 = { @@ -1726,11 +2290,24 @@ class TestGetLabsByLabName(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } lab = SystemInterface.add_lab(data_dict) @@ -1747,13 +2324,13 @@ class TestGetLabsByLabName(TestCase): #+NAME: class_get_labs_by_asset #+begin_src python @staticmethod - def get_labs_by_asset(dis_name): + def get_labs_by_asset(asset_type): asset = System.do("get_asset_by_asset_type", asset_type=str(asset_type)) try: - current_app.logger.debug("running operation get_labs_by_asset") - labs = System.do("get_labs_by_asset", assets=[asset]) - current_app.logger.debug("completed operation get_labs_by_asset") + current_app.logger.debug("running operation get_labs_by_asset_type") + labs = System.do("get_labs_by_asset", asset=asset) + current_app.logger.debug("completed operation get_labs_by_asset_type") labs_dict_list = [] for lab in labs: lab_x = lab.to_client() @@ -1770,10 +2347,10 @@ class TestGetLabsByLabName(TestCase): raise err #+end_src -*** TestGetLabsByAsset - #+NAME: test_class_get_labs_by_asset +*** TestGetLabsByAssetType + #+NAME: test_class_get_labs_by_asset_type #+BEGIN_SRC python -class TestGetLabsByAsset(TestCase): +class TestGetLabsByAssetType(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -1790,62 +2367,109 @@ class TestGetLabsByAsset(TestCase): print "test_get_labs_by_asset_in_system_interface" data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [] + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY } - experiment = SystemInterface.add_experiment(data_dict) + hosting_info = SystemInterface.add_hosting_info(data_dict) data_dict = { 'key' : KEY, 'integration_level': 4 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) data_dict = { 'key' : KEY, 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } institute = SystemInterface.add_institute(data_dict) data_dict = { 'key' : KEY, - 'dis_name': 'Computer Science', - 'dis_id': 'CSE' + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } discipline = SystemInterface.add_discipline(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' - } - - asset1 = SystemInterface.add_asset(data_dict) + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' + } + developer = SystemInterface.add_developer(data_dict) data_dict = { - 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/icon.png', - } + 'key': KEY, + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, + 'sections': [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + 'inst_id': 'IITK', + 'dis_id': 'CSE' + } + + experiment = SystemInterface.add_experiment(data_dict) - asset2 = SystemInterface.add_asset(data_dict) data_dict = { - 'key': KEY, + 'key' : KEY, 'lab_name': 'Data Structures', 'lab_id': 'cse01', 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], 'integration_level': 4 } @@ -1857,7 +2481,22 @@ class TestGetLabsByAsset(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/icon.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], 'integration_level': 4 } @@ -1865,16 +2504,16 @@ class TestGetLabsByAsset(TestCase): lab = SystemInterface.add_lab(data_dict) lab1 = SystemInterface.add_lab(data_dict1) - labs = SystemInterface.get_labs_by_asset("Image") + labs = SystemInterface.get_labs_by_asset_type("Image") self.assertEqual(labs[0]['asset']['asset_type'], "Image") #+END_SRC -*** TestGetLabsByIntegrationstatus - #+NAME: test_class_get_labs_by_integrationstatus +*** TestGetLabsByIntegration_Status + #+NAME: test_class_get_labs_by_integration_status #+BEGIN_SRC python -class TestGetLabsByIntegrationstatus(TestCase): +class TestGetLabsByIntegration_Status(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -1887,30 +2526,29 @@ class TestGetLabsByIntegrationstatus(TestCase): db.session.remove() db.drop_all() - def test_get_labs_by_integrationstatus_in_system_interface(self): - print "test_get_labs_by_integrationstatus_in_system_interface" - - data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [] - } - - experiment = SystemInterface.add_experiment(data_dict) - + def test_get_labs_by_integration_status_in_system_interface(self): + print "test_get_labs_by_integration_status_in_system_interface" data_dict = { 'key' : KEY, 'integration_level': 4 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) + + data_dict = { + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY + } + + hosting_info = SystemInterface.add_hosting_info(data_dict) data_dict = { 'key' : KEY, 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } institute = SystemInterface.add_institute(data_dict) @@ -1918,27 +2556,66 @@ class TestGetLabsByIntegrationstatus(TestCase): data_dict = { 'key' : KEY, 'dis_name': 'Computer Science', - 'dis_id': 'CSE' + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } discipline = SystemInterface.add_discipline(data_dict) + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' + } + + developer = SystemInterface.add_developer(data_dict) + data_dict = { 'key' : KEY, 'asset_type': 'Image', 'path': 'vlabs.ac.in/images/static/logo.png' - } + } - asset1 = SystemInterface.add_asset(data_dict) + asset = SystemInterface.add_asset(data_dict) data_dict = { 'key' : KEY, 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/icon.png', + 'path': 'vlabs.ac.in/images/static/icon.png' } asset2 = SystemInterface.add_asset(data_dict) + + data_dict = { + 'key': KEY, + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, + 'sections': [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] + } + + experiment = SystemInterface.add_experiment(data_dict) + data_dict = { 'key': KEY, 'lab_name': 'Data Structures', @@ -1946,7 +2623,22 @@ class TestGetLabsByIntegrationstatus(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], 'integration_level': 4 } @@ -1958,7 +2650,22 @@ class TestGetLabsByIntegrationstatus(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/icon.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], 'integration_level': 4 } @@ -1966,13 +2673,13 @@ class TestGetLabsByIntegrationstatus(TestCase): lab = SystemInterface.add_lab(data_dict) lab1 = SystemInterface.add_lab(data_dict1) - labs = SystemInterface.get_labs_by_integrationstatus("4") + labs = SystemInterface.get_labs_by_integration_status("4") - self.assertEqual(labs[0]['integrationstatus']['integration_level'], "4") + self.assertEqual(labs[0]['integration_status']['integration_level'], "4") #+END_SRC - + ** Get Experiments #+NAME: class_get_experiments #+begin_src python @@ -2017,19 +2724,127 @@ class TestGetExperiments(TestCase): def test_get_experiments_in_system_interface(self): print "test_get_experiments_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + discipline = SystemInterface.add_discipline(data_dict) + + data_dict = { + 'key' : KEY, + 'integration_level': 4 + } + + integration_status = SystemInterface.add_integration_status(data_dict) + + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' + } + + developer = SystemInterface.add_developer(data_dict) + + data_dict = { + 'key' : KEY, + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud' + } + + hosting_info = SystemInterface.add_hosting_info(data_dict) + data_dict = {'exp_name': 'stack', 'exp_id': 'cse01', 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, 'sections': [], - 'key': KEY + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] + } + + data_dict1 = { + 'key' : KEY, + 'inst_name': 'IIT Kharagpur', + 'inst_id': 'IITKgp', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute1 = SystemInterface.add_institute(data_dict1) + + data_dict1 = { + 'key' : KEY, + 'dis_name': 'electronics and communication', + 'dis_id': 'ECE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } + discipline1 = SystemInterface.add_discipline(data_dict1) + data_dict1 = {'exp_name': "arrays", 'exp_id': 'cse02', 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, 'sections':[], - 'key': KEY - } + 'key': KEY, + 'inst_id': 'IITKgp', + 'dis_id': 'ECE', + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] + } exp1 = SystemInterface.add_experiment(data_dict) exp2 = SystemInterface.add_experiment(data_dict1) @@ -2090,13 +2905,23 @@ class TestGetInstitutes(TestCase): def test_get_institutes_in_system_interface(self): print "test_get_institutes_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + data_dict = {'inst_name': 'IIT Kharagpur', 'inst_id': 'IITKgp', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key' : KEY } data_dict1 = {'inst_name': "IIT Delhi", 'inst_id': 'IITD', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'key' : KEY } @@ -2193,7 +3018,7 @@ class TestGetSections(TestCase): for dis in disciplines: dis_x = dis.to_client() dis_dict_list.append(dis_x) - current_app.logger.debug("got discipline") + current_app.logger.debug("got disciplines") return dis_dict_list except (ArityError, TypeError, NotAuthorizedError, StateError) as err: @@ -2224,15 +3049,26 @@ class TestGetDisciplines(TestCase): def test_get_disciplines_in_system_interface(self): print "test_get_disciplines_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = {'dis_name': 'data structure', 'dis_id': 'cse01', - 'key' : KEY - } + 'key' : KEY, + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } data_dict1 = {'dis_name': "Automata", 'dis_id': 'DFA', - 'key' : KEY - } + 'key' : KEY, + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } dis = SystemInterface.add_discipline(data_dict) dis1 = SystemInterface.add_discipline(data_dict1) @@ -2249,20 +3085,20 @@ class TestGetDisciplines(TestCase): #+END_SRC -** Get HostingInfos -#+NAME: class_get_hostinginfos +** Get Hosting_Info +#+NAME: class_get_hosting_info #+begin_src python @staticmethod - def get_hostinginfos(): - hostinginfo_cls = System.delegate.entities['hostinginfo'] + def get_hosting_info(): + hosting_info_cls = System.delegate.entities['hosting_info'] try: - current_app.logger.debug("getting hostinginfos") - hostinginfos = hostinginfo_cls.get_all() + current_app.logger.debug("getting hosting_info") + hosting_info = hosting_info_cls.get_all() host_dict_list = [] - for host in hostinginfos: + for host in hosting_info: host_x = host.to_client() host_dict_list.append(host_x) - current_app.logger.debug("got hostinginfos") + current_app.logger.debug("got hosting_infos") return host_dict_list except (ArityError, TypeError, NotAuthorizedError, StateError) as err: @@ -2274,10 +3110,10 @@ class TestGetDisciplines(TestCase): raise err #+end_src -*** TestGetHostingInfos - #+NAME: test_class_get_hostinginfos +*** TestGetHosting_Info + #+NAME: test_class_get_hosting_info #+BEGIN_SRC python -class TestGetHostingInfos(TestCase): +class TestGetHosting_Info(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -2290,8 +3126,8 @@ class TestGetHostingInfos(TestCase): db.session.remove() db.drop_all() - def test_get_hostinginfos_in_system_interface(self): - print "test_get_hostinginfos_in_system_interface" + def test_get_hosting_info_in_system_interface(self): + print "test_get_hosting_info_in_system_interface" data_dict = {'hosting_status': 'hosted', 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', @@ -2305,10 +3141,10 @@ class TestGetHostingInfos(TestCase): 'key' : KEY } - host1 = SystemInterface.add_hostinginfo(data_dict) - host2 = SystemInterface.add_hostinginfo(data_dict1) + host1 = SystemInterface.add_hosting_info(data_dict) + host2 = SystemInterface.add_hosting_info(data_dict1) - host_list = SystemInterface.get_hostinginfos() + host_list = SystemInterface.get_hosting_info() self.assertEqual(host_list[0].get("hosting_status"), data_dict['hosting_status']) self.assertEqual(host_list[1].get("hosting_status"), data_dict1['hosting_status']) @@ -2456,7 +3292,7 @@ class TestGetEmails(TestCase): def get_developers(): developer_cls = System.delegate.entities['developer'] try: - current_app.logger.debug("getting developes") + current_app.logger.debug("getting developers") developers = developer_cls.get_all() developer_dict_list = [] for developer in developers: @@ -2493,13 +3329,70 @@ class TestGetDevelopers(TestCase): def test_get_developer_in_system_interface(self): print "test_get_developer_in_system_interface" - data_dict = {'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com', - 'key': KEY + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + discipline = SystemInterface.add_discipline(data_dict) + + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } + data_dict1 = { + 'key' : KEY, + 'asset_type': 'Icon', + 'path': 'vlabs.ac.in/images/static/icon.png' + } + + asset1 = SystemInterface.add_asset(data_dict1) + + data_dict1 = { + 'key' : KEY, + 'inst_name': 'IIT Kharagpur', + 'inst_id': 'IITKgp', + 'assets': ['vlabs.ac.in/images/static/icon.png'] + } + + institute1 = SystemInterface.add_institute(data_dict1) + + data_dict1 = { + 'key' : KEY, + 'dis_name': 'electronics and communication', + 'dis_id': 'ECE', + 'assets': ['vlabs.ac.in/images/static/icon.png'] + } + + discipline1 = SystemInterface.add_discipline(data_dict1) + data_dict1 = {'name': 'Prof. Yamraja', 'email': 'xyz@gmail.com', + 'inst_id': 'IITKgp', + 'dis_id': 'ECE', 'key': KEY } @@ -2516,20 +3409,20 @@ class TestGetDevelopers(TestCase): #+END_SRC -** Get IntegrationStatuss -#+NAME: class_get_integrationstatuss +** Get Integration_Status +#+NAME: class_get_integration_status #+begin_src python @staticmethod - def get_integrationstatuss(): - integrationstatus_cls = System.delegate.entities['integrationstatus'] + def get_integration_status(): + integration_status_cls = System.delegate.entities['integration_status'] try: - current_app.logger.debug("getting integrationstatuss") - integrationstatuss = integrationstatus_cls.get_all() + current_app.logger.debug("getting integration_status") + integration_status = integration_status_cls.get_all() intstatus_dict_list = [] - for intstatus in integrationstatuss: + for intstatus in integration_status: intstatus_x = intstatus.to_client() intstatus_dict_list.append(intstatus_x) - current_app.logger.debug("got integrationstatuss") + current_app.logger.debug("got integration_status") return intstatus_dict_list except (ArityError, TypeError, NotAuthorizedError, StateError) as err: @@ -2542,9 +3435,9 @@ class TestGetDevelopers(TestCase): #+end_src *** TestGetIntigrationStatuss - #+NAME: test_class_get_integrationstatuss + #+NAME: test_class_get_integration_status #+BEGIN_SRC python -class TestGetIntegrationStatuss(TestCase): +class TestGetIntegration_Status(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -2557,8 +3450,8 @@ class TestGetIntegrationStatuss(TestCase): db.session.remove() db.drop_all() - def test_get_integrationstatuss_in_system_interface(self): - print "test_get_integrationstatuss_in_system_interface" + def test_get_integration_status_in_system_interface(self): + print "test_get_integration_status_in_system_interface" data_dict = {'integration_level': 4, 'key' : KEY @@ -2568,10 +3461,10 @@ class TestGetIntegrationStatuss(TestCase): 'key' : KEY } - intstatus1 = SystemInterface.add_integrationstatus(data_dict) - intstatus2 = SystemInterface.add_integrationstatus(data_dict1) + intstatus1 = SystemInterface.add_integration_status(data_dict) + intstatus2 = SystemInterface.add_integration_status(data_dict1) - intstatus_list = SystemInterface.get_integrationstatuss() + intstatus_list = SystemInterface.get_integration_status() self.assertEqual(intstatus_list[0].get("integration_level"), data_dict['integration_level']) self.assertEqual(intstatus_list[1].get("integration_level"), data_dict1['integration_level']) @@ -2591,6 +3484,7 @@ class TestGetIntegrationStatuss(TestCase): if not lab: return ("No lab found with id: %s" % (id)) + current_app.logger.debug("got lab by id: %s" % id) return lab.to_client() except (ArityError, TypeError, NotAuthorizedError, StateError) as err: @@ -2622,26 +3516,34 @@ class TestGetLabById(TestCase): print "test_get_lab_by_id_in_system_interface" data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [] + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY } - experiment = SystemInterface.add_experiment(data_dict) - + hosting_info = SystemInterface.add_hosting_info(data_dict) + data_dict = { 'key' : KEY, 'integration_level': 4 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) data_dict = { 'key' : KEY, 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } institute = SystemInterface.add_institute(data_dict) @@ -2649,43 +3551,58 @@ class TestGetLabById(TestCase): data_dict = { 'key' : KEY, 'dis_name': 'computer science', - 'dis_id': 'CSE' + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } discipline = SystemInterface.add_discipline(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } - asset1 = SystemInterface.add_asset(data_dict) + developer = SystemInterface.add_developer(data_dict) data_dict = { 'key' : KEY, 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/icon.png', - } + 'path': 'vlabs.ac.in/images/static/icon.png' + } asset2 = SystemInterface.add_asset(data_dict) data_dict = { 'key': KEY, - 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, + 'sections': [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + 'inst_id': 'IITK', + 'dis_id': 'CSE' } - developer = SystemInterface.add_developer(data_dict) - - data_dict = { - 'hosting_status': 'hosted', - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'hosted_on': 'cloud', - 'key' : KEY - } - - hostinginfo = SystemInterface.add_hostinginfo(data_dict) + experiment = SystemInterface.add_experiment(data_dict) data_dict = { 'key' : KEY, @@ -2693,12 +3610,25 @@ class TestGetLabById(TestCase): 'lab_id': 'cse02', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'overview': 'overview', 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } data_dict1 = { @@ -2707,12 +3637,25 @@ class TestGetLabById(TestCase): 'lab_id': 'cse03', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/icon.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'overview': 'overview', 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } lab1 = SystemInterface.add_lab(data_dict) @@ -2744,6 +3687,7 @@ class TestGetLabById(TestCase): if not section: return ("No section found with id: %s" % (id)) + current_app.logger.debug("got section by id = %s" % id) return section.to_client() except (ArityError, TypeError, NotAuthorizedError, StateError) as err: @@ -2808,6 +3752,7 @@ class TestGetSectionById(TestCase): if not experiment: return ("No experiment found with id: %s" % (id)) + current_app.logger.debug("got experiment by id = %s" % id) return experiment.to_client() except (ArityError, TypeError, NotAuthorizedError, StateError) as err: @@ -2838,20 +3783,128 @@ class TestGetExperimentById(TestCase): def test_get_experiment_by_id_in_system_interface(self): print "test_get_experiment_by_id_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + discipline = SystemInterface.add_discipline(data_dict) + + data_dict1 = { + 'key' : KEY, + 'inst_name': 'IIT Kharagpur', + 'inst_id': 'IITKgp', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute1 = SystemInterface.add_institute(data_dict1) + + data_dict1 = { + 'key' : KEY, + 'dis_name': 'electronics and communication', + 'dis_id': 'ECE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + discipline1 = SystemInterface.add_discipline(data_dict1) + + data_dict = { + 'key' : KEY, + 'integration_level': 4 + } + + integration_status = SystemInterface.add_integration_status(data_dict) + + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' + } + + developer = SystemInterface.add_developer(data_dict) + + data_dict = { + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY + } + + hosting_info = SystemInterface.add_hosting_info(data_dict) + data_dict = { 'key': KEY, 'exp_name': 'array', 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, 'exp_id': 'cse02', - 'sections': [] + 'sections': [], + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } data_dict1 = { 'key': KEY, 'exp_name': 'stack', 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, 'exp_id': 'cse03', - 'sections': [] + 'sections': [], + 'inst_id': 'IITKgp', + 'dis_id': 'ECE', + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } exp1 = SystemInterface.add_experiment(data_dict) @@ -2862,11 +3915,9 @@ class TestGetExperimentById(TestCase): self.assertEqual(exp_data_one.get("exp_name"), data_dict['exp_name']) self.assertEqual(exp_data_two.get("exp_name"), data_dict1['exp_name']) - self.assertEqual(exp_data_one.get("exp_id"), - data_dict['exp_id']) - self.assertEqual(exp_data_two.get("exp_id"), - data_dict1['exp_id']) - + self.assertEqual(exp_data_one.get("exp_id"), data_dict['exp_id']) + self.assertEqual(exp_data_two.get("exp_id"), data_dict1['exp_id']) + #+END_SRC @@ -2882,6 +3933,7 @@ class TestGetExperimentById(TestCase): if not institute: return ("No institute found with id: %s" % (id)) + current_app.logger.debug("got institute by id = %s" % id) return institute.to_client() except (ArityError, TypeError, NotAuthorizedError, StateError) as err: @@ -2912,16 +3964,27 @@ class TestGetInstituteById(TestCase): def test_get_institute_by_id_in_system_interface(self): print "test_get_institute_by_id_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = { 'key' : KEY, 'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } data_dict1 = { 'key' : KEY, 'inst_name': 'IIT Delhi', 'inst_id': 'IITD', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } inst1 = SystemInterface.add_institute(data_dict) @@ -2952,6 +4015,7 @@ class TestGetInstituteById(TestCase): if not discipline: return ("No discipline found with id: %s" % (id)) + current_app.logger.debug("got discipline by id = %s" % id) return discipline.to_client() except (ArityError, TypeError, NotAuthorizedError, StateError) as err: @@ -2982,14 +4046,24 @@ class TestGetDisciplineById(TestCase): def test_get_discipline_by_id_in_system_interface(self): print "test_get_discipline_by_id_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + data_dict = {'dis_name': 'data structure', 'dis_id': 'cse01', - 'key' : KEY + 'key' : KEY, + 'assets': ['vlabs.ac.in/images/static/logo.png'] } data_dict1 = {'dis_name': "Automata", 'dis_id': 'DFA', - 'key' : KEY + 'key' : KEY, + 'assets': ['vlabs.ac.in/images/static/logo.png'] } dis = SystemInterface.add_discipline(data_dict) @@ -3008,12 +4082,86 @@ class TestGetDisciplineById(TestCase): #+END_SRC +** Get Name By Id + +#+NAME: class_get_name_by_id +#+begin_src python + @staticmethod + def get_name_by_id(id): + name_cls = System.delegate.entities['name'] + try: + current_app.logger.debug("getting name by id") + name = name_cls.get_by_id(id) + if not name: + return ("No name found with id: %s" % (id)) + + current_app.logger.debug("got developer name by id = %s" % id) + return name.to_client() + + except (ArityError, TypeError, NotAuthorizedError, StateError) as err: + current_app.logger.error("Exception = %s" % str(err)) + raise err + + except Exception as err: + current_app.logger.error("Exception = %s" % str(err)) + raise err +#+end_src + +*** TestGetNameById + #+NAME: test_class_get_name_by_id + #+BEGIN_SRC python +class TestGetNameById(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_name_by_id_in_system_interface(self): + print "test_get_name_by_id_in_system_interface" + + data_dict = { + 'key' : KEY, + 'name' : "Prof. Dharamraj" + } + + data_dict1 = { + 'key' : KEY, + 'name' : "Prof. Dharamrajuuuu" + } + + name1 = SystemInterface.add_name(data_dict) + name2 = SystemInterface.add_name(data_dict1) + + name_data_one = SystemInterface.get_name_by_id(1) + name_data_two = SystemInterface.get_name_by_id(2) + + self.assertEqual(name_data_one.get("name"), data_dict['name']) + self.assertEqual(name_data_two.get("name"), data_dict1['name']) + + #+END_SRC + + ** Update Lab #+NAME: class_update_lab #+begin_src python @staticmethod def update_lab(data_dict): session_cls = System.delegate.entities['session'] + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] + hosting_info_cls = System.delegate.entities['hosting_info'] + asset_cls = System.delegate.entities['asset'] + developer_cls = System.delegate.entities['developer'] + name_cls = System.delegate.entities['name'] + email_cls = System.delegate.entities['email'] + session = session_cls(key=data_dict['key']) lab_id = str(data_dict['lab_id']) @@ -3029,12 +4177,78 @@ class TestGetDisciplineById(TestCase): else: overview=data_dict['overview'] + if 'inst_id' not in data_dict: + inst=str(lab.get("institute")) + else: + inst = System.do("get_institute", inst_id= + data_dict['inst_id']) + + if 'dis_id' not in data_dict: + dis=str(lab.get("discipline")) + else: + dis = System.do("get_discipline", dis_id= + data_dict['dis_id']) + + if 'integration_level' not in data_dict: + integration_status=str(lab.get("integration_status")) + else: + integration_status = System.do("get_integration_status_by_IL", + integration_level=data_dict['integration_level']) + + hosting_info = data_dict['hosting_info'] + hosting_info_list = [] + for hosting_info_x in hosting_info: + hosting_info = System.do("get_hosting_info", + hosted_url= + hosting_info_x['hosted_url']) + if hosting_info is None: + hosting_info = hosting_info_cls(hosting_status=str(hosting_info_x['hosting_status']), \ + hosted_url=str(hosting_info_x['hosted_url']), hosted_on=str(hosting_info_x['hosted_on'])) + hosting_info = System.do("add_hosting_info", hosting_info=hosting_info, session=session) + hosting_info_list.append(hosting_info) + + assets = data_dict['assets'] + asset_list = [] + for asset_x in assets: + asset = System.do("get_asset", path=asset_x['path']) + if asset is None: + asset = asset_cls(asset_type=str(asset_x['asset_type']), \ + path=str(asset_x['path'])) + asset = System.do("add_asset", asset=asset, session=session) + asset_list.append(asset) + + developers = data_dict['developers'] + developer_list = [] + for developer_x in developers: + name = name_cls(name=developer_x['name']) + email = email_cls(email=developer_x['email']) + developer = System.do("get_developer", email=email) + institute = System.do("get_institute", inst_id=developer_x['inst_id']) + discipline = System.do("get_discipline", dis_id=developer_x['dis_id']) + if developer is None: + developer = developer_cls(name=name, email=email, institute=institute, discipline=discipline) + developer = System.do("add_developer", developer=developer, session=session) + developer_list.append(developer) + + experiments = data_dict['experiments'] + + exp_list = [] + for e_id in experiments: + experiment = System.do("get_experiment", exp_id=e_id) + exp_list.append(experiment) + try: current_app.logger.debug("running operation update_lab") lab = System.do("update_lab", lab=lab, - lab_name=lab_name, - overview=overview, - session=session) + lab_name=lab_name, + overview=overview, session=session, + institute=inst, + discipline=dis, + hosting_info=hosting_info_list, + assets=asset_list, + experiments=exp_list, + developers=developer_list, + integration_status=integration_status) current_app.logger.debug("completed operation update_lab") return lab.to_client() except (ArityError, TypeError, NotAuthorizedError, StateError) as err: @@ -3046,7 +4260,7 @@ class TestGetDisciplineById(TestCase): raise err #+end_src -*** TestUpateLab +*** TestUpdateLab #+NAME: test_class_update_lab #+BEGIN_SRC python class TestUpdateLab(TestCase): @@ -3062,23 +4276,31 @@ class TestUpdateLab(TestCase): db.session.remove() db.drop_all() - def test_update_lab_name_in_system_interface(self): + def test_update_lab_in_system_interface(self): print "test_update_lab_name_in_system_interface" data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections' : [] + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY } - experiment = SystemInterface.add_experiment(data_dict) + hosting_info = SystemInterface.add_hosting_info(data_dict) + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) data_dict = { 'key': KEY, 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } institute = SystemInterface.add_institute(data_dict) @@ -3088,39 +4310,57 @@ class TestUpdateLab(TestCase): 'integration_level': 4 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) data_dict = { 'key' : KEY, 'dis_name': 'computer science', - 'dis_id': 'CSE' + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } discipline = SystemInterface.add_discipline(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' - } - - asset = SystemInterface.add_asset(data_dict) - - data_dict = { - 'key': KEY, 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } developer = SystemInterface.add_developer(data_dict) + data_dict = { - 'hosting_status': 'hosted', - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'hosted_on': 'cloud', - 'key' : KEY + 'key' : KEY, + 'dis_name': 'computer science', + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, + 'sections' : [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) + experiment = SystemInterface.add_experiment(data_dict) data_dict = { 'key' : KEY, @@ -3129,116 +4369,151 @@ class TestUpdateLab(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } + lab = SystemInterface.add_lab(data_dict) + data_dict1 = { 'key' : KEY, - 'lab_name': 'Computer Programming', - 'lab_id': 'cse02' + 'dis_name': 'computer science', + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'exp_name': 'lists', + 'exp_id': 'exp234', + 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, + 'sections' : [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } - lab = SystemInterface.add_lab(data_dict) - lab1 = SystemInterface.update_lab(data_dict1) - - self.assertEqual(lab1.get("lab_name"), data_dict1['lab_name']) - self.assertEqual(lab1.get("lab_id"), data_dict['lab_id']) - self.assertEqual(lab1.get("overview"), data_dict['overview']) - - def test_update_lab_overview_in_system_interface(self): - print "test_update_lab_name_in_system_interface" - - data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [] - } + experiment1 = SystemInterface.add_experiment(data_dict1) - experiment = SystemInterface.add_experiment(data_dict) - data_dict = { + data_dict1 = { 'key' : KEY, - 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' - } + 'asset_type': 'Video', + 'path': 'vlabs.ac.in/images/video/icon.png' + } - institute = SystemInterface.add_institute(data_dict) + asset = SystemInterface.add_asset(data_dict1) - data_dict = { - 'key' : KEY, - 'integration_level': 4 + data_dict1 = { + 'key': KEY, + 'inst_name': 'IIT Kharagpur', + 'inst_id': 'IITKgp', + 'assets': ['vlabs.ac.in/images/video/icon.png'] } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) - - data_dict = { - 'key' : KEY, - 'dis_name': 'computer science', - 'dis_id': 'CSE' - } - - discipline = SystemInterface.add_discipline(data_dict) + institute = SystemInterface.add_institute(data_dict1) - data_dict = { + data_dict1 = { 'key' : KEY, - 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' - } - - developer = SystemInterface.add_developer(data_dict) - - data_dict = { - 'hosting_status': 'hosted', - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'hosted_on': 'cloud', - 'key' : KEY - } + 'dis_name': 'electronics engineering', + 'dis_id': 'ECE', + 'assets': ['vlabs.ac.in/images/video/icon.png'] + } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) + discipline = SystemInterface.add_discipline(data_dict1) - data_dict = { + data_dict1 = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' + 'integration_level': 3 } - asset = SystemInterface.add_asset(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict1) - data_dict = { - 'key': KEY, - 'lab_name': 'Data Structures', + data_dict1 = { + 'key' : KEY, + 'lab_name': 'Computer Programming', 'lab_id': 'cse02', 'overview': 'overview', - 'integration_level': 4 , - 'inst_id': 'IITK', - 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], - 'experiments': ['exp123'], - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' - } + 'integration_level': 3 , + 'inst_id': 'IITKgp', + 'dis_id': 'ECE', + 'experiments': ['exp234'], + 'hosting_info': [{'hosted_url':'http://cse13-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitk.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + 'assets': [{'path':'vlabs.ac.in/images/static/icon.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'xyz@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallav', + 'email': 'pallavi@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}] - data_dict1 = { - 'key' : KEY, - 'overview': 'Computer Programming overview', - 'lab_id': 'cse02' } - lab = SystemInterface.add_lab(data_dict) + lab1 = SystemInterface.update_lab(data_dict1) - - self.assertEqual(lab1.get("lab_id"), data_dict['lab_id']) - self.assertEqual(lab1.get("lab_name"), data_dict['lab_name']) - self.assertEqual(lab1.get("overview"), data_dict1['overview']) + self.assertEqual(lab1.get("lab_name"), data_dict1['lab_name']) + self.assertEqual(lab1.get("lab_id"), data_dict1['lab_id']) + self.assertEqual(lab1.get("overview"), data_dict1['overview']) + self.assertEqual(lab1.get("institute").get("inst_id"), + data_dict1['inst_id']) + self.assertEqual(lab1.get("discipline").get("dis_id"), + data_dict1['dis_id']) + self.assertEqual(lab1.get("integration_status").\ + get("integration_level"), + data_dict1['integration_level']) + self.assertEqual(lab1.get("hosting_info")[0].get("hosted_url"), + data_dict1['hosting_info'][0]['hosted_url']) + self.assertEqual(lab1.get("hosting_info")[1].get("hosted_url"), + data_dict1['hosting_info'][1]['hosted_url']) + self.assertEqual(lab1.get("developers")[0].get("email").get("email"), + data_dict1['developers'][0]['email']) + self.assertEqual(lab1.get("developers")[1].get("email").get("email"), + data_dict1['developers'][1]['email']) + self.assertEqual(lab1.get("assets")[0].get("path"), + data_dict1['assets'][0]['path']) + + self.assertEqual(lab1.get("developers")[0].get("email").get("email"), + data_dict1['developers'][0].get("email")) + self.assertEqual(lab1.get("assets")[0].get("path"), + data_dict1["assets"][0].get("path")) + self.assertEqual(lab1.get("experiments")[0].get("exp_id"), + experiment1.get("exp_id")) + #+END_SRC - ** Update Experiment #+NAME: class_update_experiment #+begin_src python @@ -3246,10 +4521,18 @@ class TestUpdateLab(TestCase): def update_experiment(data_dict): session_cls = System.delegate.entities['session'] exp_cls = System.delegate.entities['experiment'] - + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] + hosting_info_cls = System.delegate.entities['hosting_info'] + developer_cls = System.delegate.entities['developer'] + asset_cls = System.delegate.entities['asset'] + name_cls = System.delegate.entities['name'] + email_cls = System.delegate.entities['email'] + section_cls = System.delegate.entities['section'] session = session_cls(key=str(data_dict['key'])) exp_id = str(data_dict['exp_id']) experiment = System.do("get_experiment", exp_id=exp_id) + if 'exp_name' not in data_dict: exp_name=str(experiment.get("exp_name")) else: @@ -3262,12 +4545,90 @@ class TestUpdateLab(TestCase): else: overview=data_dict['overview'] + if 'inst_id' not in data_dict: + inst=str(experiment.get("institute")) + else: + inst= System.do("get_institute", inst_id=data_dict['inst_id']) + + if 'dis_id' not in data_dict: + disc=str(experiment.get("discipline")) + else: + disc= System.do("get_discipline", dis_id=data_dict['dis_id']) + + if 'integration_level' not in data_dict: + integration_status=str(experiment.get("integration_status")) + else: + integration_status= System.do("get_integration_status_by_IL", + integration_level=data_dict['integration_level']) + + hosting_info = data_dict['hosting_info'] + hosting_info_list = [] + for hosting_info_x in hosting_info: + hosting_info = System.do("get_hosting_info", + hosted_url= + hosting_info_x['hosted_url']) + if hosting_info is None: + hosting_info = hosting_info_cls(hosting_status=\ + str(hosting_info_x\ + ['hosting_status']), \ + hosted_url=\ + str(hosting_info_x\ + ['hosted_url']), \ + hosted_on=\ + str(hosting_info_x\ + ['hosted_on'])) + hosting_info = System.do("add_hosting_info", \ + hosting_info=hosting_info, \ + session=session) + hosting_info_list.append(hosting_info) + + assets = data_dict['assets'] + asset_list = [] + for asset_x in assets: + asset = System.do("get_asset", path=asset_x['path']) + if asset is None: + asset = asset_cls(asset_type=str(asset_x['asset_type']), \ + path=str(asset_x['path'])) + asset = System.do("add_asset", asset=asset, session=session) + asset_list.append(asset) + + developers = data_dict['developers'] + developer_list = [] + for developer_x in developers: + name = name_cls(name=developer_x['name']) + email = email_cls(email=developer_x['email']) + developer = System.do("get_developer", email=email) + institute = System.do("get_institute", inst_id=developer_x['inst_id']) + discipline = System.do("get_discipline", dis_id=developer_x['dis_id']) + if developer is None: + developer = developer_cls(name=name, email=email, + institute=institute, + discipline=discipline) + developer = System.do("add_developer", developer=developer, + session=session) + developer_list.append(developer) + + sections = data_dict['sections'] + section_list = [] + for section_x in sections: + section = System.do("get_section", name=section_x) + if section is None: + section = section_cls(name=str(section_x)) + section = System.do("add_section", section=section, session=session) + section_list.append(section) + + try: current_app.logger.debug("running operation update_experiment") exp = System.do("update_experiment", exp_name=exp_name, - experiment=experiment, - overview=overview, - session=session) + experiment=experiment, overview=overview, + session=session, institute=inst, + discipline=disc, + integration_status=integration_status, + hosting_info=hosting_info_list, + assets=asset_list, + developers=developer_list, + sections=section_list) current_app.logger.debug("completed operation update_experiment") return exp.to_client() except (ArityError, TypeError, NotAuthorizedError, StateError) as err: @@ -3279,7 +4640,7 @@ class TestUpdateLab(TestCase): raise err #+end_src -*** TestUpateExperiment +*** TestUpdateExperiment #+NAME: test_class_update_Experiment #+BEGIN_SRC python class TestUpdateExperiment(TestCase): @@ -3298,24 +4659,182 @@ class TestUpdateExperiment(TestCase): def test_update_experiment_name_in_system_interface(self): print "test_update_experiment_name_in_system_interface" + data_dict = { + 'key' : KEY, + 'integration_level': 4 + } + + integration_status = SystemInterface.add_integration_status(data_dict) + + data_dict = { + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY + } + + hosting_info = SystemInterface.add_hosting_info(data_dict) + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + discipline = SystemInterface.add_discipline(data_dict) + + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' + } + + developer = SystemInterface.add_developer(data_dict) + + data_dict = { + 'key' : KEY, + 'name': 'Theory' + } + section = SystemInterface.add_section(data_dict) + data_dict = { 'key': KEY, 'exp_name': 'Data Structures', 'overview': 'overview', - 'sections': [], - 'exp_id': 'cse02' + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, + 'exp_id': 'cse02', + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'sections': ['Theory', 'Procedure'], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } + exp = SystemInterface.add_experiment(data_dict) + data_dict1 = { 'key' : KEY, - 'exp_id': 'cse02', - 'exp_name': 'arrays' + 'integration_level': 3 + } + + integration_status = SystemInterface.add_integration_status(data_dict1) + + data_dict1 = { + 'key' : KEY, + 'asset_type': 'Video', + 'path': 'vlabs.ac.in/images/video/icon.png' } - exp = SystemInterface.add_experiment(data_dict) + asset = SystemInterface.add_asset(data_dict1) + + + data_dict1 = { + 'key' : KEY, + 'inst_name': 'IIT Kharagpur', + 'inst_id': 'IITKgp', + 'assets': ['vlabs.ac.in/images/video/icon.png'] + } + + institute = SystemInterface.add_institute(data_dict1) + + data_dict1 = { + 'key' : KEY, + 'dis_name': 'electronics & engineering', + 'dis_id': 'ECE', + 'assets': ['vlabs.ac.in/images/video/icon.png'] + } + + discipline = SystemInterface.add_discipline(data_dict1) + + data_dict1 = { + 'key' : KEY, + 'name': 'Aim' + } + section = SystemInterface.add_section(data_dict1) + + data_dict1 = { + 'key' : KEY, + 'exp_id': 'cse02', + 'exp_name': 'arrays', + 'overview': 'overview', + 'sections': [''], + 'inst_id': 'IITKgp', + 'dis_id': 'ECE', + 'integration_level': 3, + 'hosting_info': [{'hosted_url':'http://cse13-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitk.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], + 'assets': [{'path':'vlabs.ac.in/images/static/icon.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'xyz@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallav', + 'email': 'pallavi@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}] + } + exp1 = SystemInterface.update_experiment(data_dict1) self.assertEqual(exp1.get("exp_name"), data_dict1['exp_name']) + self.assertEqual(exp1.get("overview"), data_dict1['overview']) + self.assertEqual(exp1.get("exp_id"), data_dict1['exp_id']) + self.assertEqual(exp1.get("institute").get("inst_id"), + data_dict1['inst_id']) + self.assertEqual(exp1.get("discipline").get("dis_id"), + data_dict1['dis_id']) + self.assertEqual(exp1.get("integration_status").\ + get("integration_level"), + data_dict1['integration_level']) + self.assertEqual(exp1.get("hosting_info")[0].get("hosted_url"), + data_dict1['hosting_info'][0]['hosted_url']) + self.assertEqual(exp1.get("hosting_info")[1].get("hosted_url"), + data_dict1['hosting_info'][1]['hosted_url']) + self.assertEqual(exp1.get("developers")[0].get("email").get("email"), + data_dict1['developers'][0]['email']) + self.assertEqual(exp1.get("developers")[1].get("email").get("email"), + data_dict1['developers'][1]['email']) + self.assertEqual(exp1.get("assets")[0].get("path"), + data_dict1['assets'][0]['path']) + self.assertEqual(exp1.get("sections")[0].get("name"), + data_dict1['sections'][0]) #+END_SRC @@ -3326,10 +4845,20 @@ class TestUpdateExperiment(TestCase): @staticmethod def update_institute(data_dict): session_cls = System.delegate.entities['session'] - session = session_cls(key=data_dict['key']) + asset_cls = System.delegate.entities['asset'] + session = session_cls(key=str(data_dict['key'])) - inst_id = str(data_dict['inst_id']) - institute = System.do("get_institute", inst_id=inst_id) + institute = System.do("get_institute", inst_id=str(data_dict['inst_id'])) + + assets = data_dict['assets'] + asset_list = [] + for asset_x in assets: + asset = System.do("get_asset", path=asset_x) + if asset is None: + asset = asset_cls(asset_type=str(asset_x['asset_type']), \ + path=str(asset_x['path'])) + asset = System.do("add_asset", asset=asset, session=session) + asset_list.append(asset) if 'inst_name' not in data_dict: inst_name=str(inst.get("inst_name")) @@ -3340,9 +4869,9 @@ class TestUpdateExperiment(TestCase): current_app.logger.debug("running operation update_institute") institute = System.do("update_institute", institute=institute, inst_name=inst_name, - session=session) + session=session, assets=asset_list) current_app.logger.debug("completed operation update_institute") - return institute.to_client() + return institute except (ArityError, TypeError, NotAuthorizedError, StateError) as err: current_app.logger.error("Exception = %s" % str(err)) raise err @@ -3371,27 +4900,47 @@ class TestUpdateInstitute(TestCase): def test_update_institute_name_in_system_interface(self): print "test_update_institute_name_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + data_dict = { 'key' : KEY, 'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', - 'overview' : 'overview' + 'overview' : 'overview', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } + institute = SystemInterface.add_institute(data_dict) + + data_dict1 = { + 'key' : KEY, + 'asset_type': 'Video', + 'path': 'vlabs.ac.in/images/video/icon.png' + } + + asset = SystemInterface.add_asset(data_dict1) + data_dict1 = { 'key' : KEY, 'inst_name': 'IIT Delhi', - 'inst_id': 'IITK' + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/video/icon.png'] } - institute = SystemInterface.add_institute(data_dict) + institute1 = SystemInterface.update_institute(data_dict1) self.assertEqual(institute1.get("inst_name"), data_dict1['inst_name']) - + self.assertEqual(institute1.get("assets")[0].get("path"), + data_dict1['assets'][0]) #+END_SRC - ** Update Section #+NAME: class_update_section #+begin_src python @@ -3423,7 +4972,7 @@ class TestUpdateInstitute(TestCase): raise err #+end_src -*** TestUpateSection +*** TestUpdateSection #+NAME: test_class_update_Section #+BEGIN_SRC python class TestUpdateSection(TestCase): @@ -3460,18 +5009,28 @@ class TestUpdateSection(TestCase): #+END_SRC - ** Update Discipline #+NAME: class_update_discipline #+begin_src python @staticmethod def update_discipline(data_dict): session_cls = System.delegate.entities['session'] + asset_cls = System.delegate.entities['asset'] session = session_cls(key=data_dict['key']) dis_id = str(data_dict['dis_id']) discipline = System.do("get_discipline", dis_id=dis_id) + assets = data_dict['assets'] + asset_list = [] + for asset_x in assets: + asset = System.do("get_asset", path=asset_x) + if asset is None: + asset = asset_cls(asset_type=str(asset_x['asset_type']), \ + path=str(asset_x['path'])) + asset = System.do("add_asset", asset=asset, session=session) + asset_list.append(asset) + if "dis_name" not in data_dict: dis_name=str(discipline.get("dis_name")) else: @@ -3481,9 +5040,9 @@ class TestUpdateSection(TestCase): current_app.logger.debug("running operation update_discipline") discipline = System.do("update_discipline", discipline=discipline, dis_name=dis_name, - session=session) + session=session, assets=asset_list) current_app.logger.debug("completed operation update_discipline") - return discipline.to_client() + return discipline except (ArityError, TypeError, NotAuthorizedError, StateError) as err: current_app.logger.error("Exception = %s" % str(err)) raise err @@ -3511,52 +5070,73 @@ class TestUpdateDiscipline(TestCase): def test_update_discipline_name_in_system_interface(self): print "test_update_discipline_name_in_system_interface" + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) data_dict = {'dis_name': 'Computer Science', 'dis_id': 'CSE', - 'key' : KEY + 'key' : KEY, + 'assets': ['vlabs.ac.in/images/static/logo.png'] } + data_dict1 = { + 'key' : KEY, + 'asset_type': 'Video', + 'path': 'vlabs.ac.in/images/video/icon.png' + } + + asset = SystemInterface.add_asset(data_dict1) + data_dict1 = {'dis_name': 'Computer Science and Engineering', - 'dis_id': 'CSE', - 'key' : KEY - } + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'key' : KEY + } + dis1 = SystemInterface.add_discipline(data_dict) dis = SystemInterface.update_discipline(data_dict1) self.assertEqual(dis.get("dis_name"), data_dict1['dis_name']) + self.assertEqual(dis.get("assets")[0].get("path"), + data_dict1['assets'][0]) #+END_SRC -** Update HostingInfo -#+NAME: class_update_hostinginfo +** Update Hosting_Info +#+NAME: class_update_hosting_info #+begin_src python @staticmethod - def update_hostinginfo(data_dict): + def update_hosting_info(data_dict): session_cls = System.delegate.entities['session'] session = session_cls(key=data_dict['key']) hosted_url = str(data_dict['hosted_url']) - hostinginfo = System.do("get_hostinginfo", hosted_url=hosted_url) + hosting_info = System.do("get_hosting_info", hosted_url=hosted_url) if 'hosting_status' not in data_dict: - hosting_status=str(hostinginfo.get("hosting_status")) + hosting_status=str(hosting_info.get("hosting_status")) else: hosting_status=data_dict['hosting_status'] if 'hosted_on' not in data_dict: - hosted_on=str(hostinginfo.get("hosted_on")) + hosted_on=str(hosting_info.get("hosted_on")) else: hosted_on=data_dict['hosted_on'] try: - current_app.logger.debug("running operation update_hostinginfo") - hostinginfo = System.do("update_hostinginfo", hostinginfo=hostinginfo, + current_app.logger.debug("running operation update_hosting_info") + hosting_info = System.do("update_hosting_info", hosting_info=hosting_info, hosting_status=hosting_status, hosted_on=hosted_on, session=session) - current_app.logger.debug("completed operation update_hostinginfo") - return hostinginfo.to_client() + current_app.logger.debug("completed operation update_hosting_info") + return hosting_info.to_client() except (ArityError, TypeError, NotAuthorizedError, StateError) as err: current_app.logger.error("Exception = %s" % str(err)) raise err @@ -3566,10 +5146,10 @@ class TestUpdateDiscipline(TestCase): raise err #+end_src -*** TestUpateHostingInfo - #+NAME: test_class_update_hostinginfo +*** TestUpateHosting_Info + #+NAME: test_class_update_hosting_info #+BEGIN_SRC python -class TestUpdateHostingInfo(TestCase): +class TestUpdateHosting_Info(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -3582,8 +5162,8 @@ class TestUpdateHostingInfo(TestCase): db.session.remove() db.drop_all() - def test_update_hostinginfo_in_system_interface(self): - print "test_update_hostinginfo_in_system_interface" + def test_update_hosting_info_in_system_interface(self): + print "test_update_hosting_info_in_system_interface" data_dict = { 'key' : KEY, @@ -3599,11 +5179,11 @@ class TestUpdateHostingInfo(TestCase): 'hosted_on': 'server' } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) - hostinginfo1 = SystemInterface.update_hostinginfo(data_dict1) + hosting_info = SystemInterface.add_hosting_info(data_dict) + hosting_info1 = SystemInterface.update_hosting_info(data_dict1) - self.assertEqual(hostinginfo1.get("hosting_status"), data_dict1['hosting_status']) - self.assertEqual(hostinginfo1.get("hosted_on"), data_dict1['hosted_on']) + self.assertEqual(hosting_info1.get("hosting_status"), data_dict1['hosting_status']) + self.assertEqual(hosting_info1.get("hosted_on"), data_dict1['hosted_on']) #+END_SRC @@ -3619,19 +5199,29 @@ class TestUpdateHostingInfo(TestCase): developer_cls = System.delegate.entities['developer'] session = session_cls(key=str(data_dict['key'])) - email = email_cls(email=data_dict['email']) + email = email_cls(email=str(data_dict['email'])) developer = System.do("get_developer", email=email) if 'name' not in data_dict: - name=str(developer.get("name")) + name=developer.get("name") else: - name=name_cls(name=str(data_dict['name'])) + name=name_cls(name=data_dict['name']) + + if 'inst_id' not in data_dict: + inst=developer.get("institute") + else: + inst = System.do("get_institute", inst_id=data_dict['inst_id']) + + if 'dis_id' not in data_dict: + disc=developer.get("discipline") + else: + disc = System.do("get_discipline", dis_id=data_dict['dis_id']) try: current_app.logger.debug("running operation update_developer") developer = System.do("update_developer", name=name, - developer=developer, - session=session) + developer=developer, institute=inst, + discipline=disc, session=session) current_app.logger.debug("completed operation update_developer") return developer @@ -3642,6 +5232,7 @@ class TestUpdateHostingInfo(TestCase): except Exception as err: current_app.logger.error("Exception = %s" % str(err)) raise err + #+end_src *** TestUpateDeveloper @@ -3664,26 +5255,148 @@ class TestUpdateDeveloper(TestCase): print "test_update_developer_name_in_system_interface" data_dict = { - 'key': KEY, - 'name': 'Prof. Dharamaraja', - 'email': 'dharamaraj@gmail.com' + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + discipline = SystemInterface.add_discipline(data_dict) + + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } + developer = SystemInterface.add_developer(data_dict) + + data_dict1 = { + 'key': KEY, + 'inst_name': 'IIT Kharagpur', + 'inst_id': 'IITKgp', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute1 = SystemInterface.add_institute(data_dict1) + + data_dict1 = { + 'key' : KEY, + 'dis_name': 'electronics engineering', + 'dis_id': 'ece', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + + discipline1 = SystemInterface.add_discipline(data_dict1) + + data_dict1 = { 'key': KEY, - 'email': 'dharamaraj@gmail.com', - 'name': 'Prof. Raja' + 'email': 'abc@gmail.com', + 'name': 'Prof. Raja', + 'inst_id': 'IITKgp', + 'dis_id': 'ece' } - developer = SystemInterface.add_developer(data_dict) developer1 = SystemInterface.update_developer(data_dict1) self.assertEqual(developer1.get("name").get("name"), data_dict1['name']) + self.assertEqual(developer1.get("institute").get("inst_id"), data_dict1['inst_id']) + self.assertEqual(developer1.get("discipline").get("dis_id"), data_dict1['dis_id']) #+END_SRC +** Update Name +#+NAME: class_update_name +#+begin_src python + @staticmethod + def update_name(data_dict): + session_cls = System.delegate.entities['session'] + name_cls = System.delegate.entities['name'] + + session = session_cls(key=data_dict['key']) + name = name_cls.get_by_id(data_dict['n_id']) + + if 'name' not in data_dict: + n_name=str(name.get("name")) + else: + n_name=data_dict['name'] + + try: + current_app.logger.debug("running operation update_name") + name = System.do("update_name", name=name, n_name=n_name,\ + session=session) + current_app.logger.debug("completed operation update_name") + return name.to_client() + except (ArityError, TypeError, NotAuthorizedError, StateError) as err: + current_app.logger.error("Exception = %s" % str(err)) + raise err + + except Exception as err: + current_app.logger.error("Exception = %s" % str(err)) + raise err +#+end_src + +*** TestUpdateName + #+NAME: test_class_update_Name + #+BEGIN_SRC python +class TestUpdateName(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_update_name_in_system_interface(self): + print "test_update_name_in_system_interface" + + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamraj' + } + + data_dict1 = { + 'key' : KEY, + 'n_id': 1, + 'name': 'Prof. Dharam' + } + + name = SystemInterface.add_name(data_dict) + name1 = SystemInterface.update_name(data_dict1) + + self.assertEqual(name1.get("name"), data_dict1['name']) + + #+END_SRC + + ** Delete Lab #+NAME: class_delete_lab #+begin_src python @@ -3725,26 +5438,34 @@ class TestDeleteLab(TestCase): print "test_delete_lab_in_system_interface" data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [] - } + 'key' : KEY, + 'integration_level': 4 + } - experiment = SystemInterface.add_experiment(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) data_dict = { 'key' : KEY, - 'integration_level': 4 + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + asset1 = SystemInterface.add_asset(data_dict) + + data_dict = { + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY + } + + hosting_info = SystemInterface.add_hosting_info(data_dict) data_dict = { 'key' : KEY, 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } institute = SystemInterface.add_institute(data_dict) @@ -3752,43 +5473,58 @@ class TestDeleteLab(TestCase): data_dict = { 'key' : KEY, 'dis_name': 'computer science', - 'dis_id': 'CSE' + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } discipline = SystemInterface.add_discipline(data_dict) - + data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' - } + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' + } - asset1 = SystemInterface.add_asset(data_dict) + developer = SystemInterface.add_developer(data_dict) data_dict = { 'key' : KEY, 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/icon.png', + 'path': 'vlabs.ac.in/images/static/icon.png' } asset2 = SystemInterface.add_asset(data_dict) data_dict = { 'key': KEY, - 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' - } - - developer = SystemInterface.add_developer(data_dict) - - data_dict = { - 'hosting_status': 'hosted', - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'hosted_on': 'cloud', - 'key' : KEY + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, + 'sections': [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) + experiment = SystemInterface.add_experiment(data_dict) data_dict = { 'key' : KEY, @@ -3796,12 +5532,25 @@ class TestDeleteLab(TestCase): 'lab_id': 'cse01', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'overview': 'overview', 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } data_dict1 = { @@ -3810,12 +5559,25 @@ class TestDeleteLab(TestCase): 'lab_id': 'cse02', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/icon.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'overview': 'overview', 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } lab = SystemInterface.add_lab(data_dict) @@ -3869,20 +5631,110 @@ class TestDeleteExperiment(TestCase): def test_delete_experiment_in_system_interface(self): print "test_delete_experiment_in_system_interface" + data_dict = { + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY + } + + hosting_info = SystemInterface.add_hosting_info(data_dict) + + data_dict = { + 'key' : KEY, + 'integration_level': 4 + } + + integration_status = SystemInterface.add_integration_status(data_dict) + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + discipline = SystemInterface.add_discipline(data_dict) + + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' + } + + developer = SystemInterface.add_developer(data_dict) + data_dict = { 'key' : KEY, 'exp_name': 'Data Structures', 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, 'exp_id': 'cse01', - 'sections': [] + 'sections': [], + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } data_dict1 = { 'key': KEY, 'exp_name': 'Computer Programming', 'overview': 'overview', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, 'exp_id': 'cse02', - 'sections':[] + 'sections':[], + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } exp = SystemInterface.add_experiment(data_dict) @@ -3936,16 +5788,26 @@ class TestDeleteInstitute(TestCase): def test_delete_institute_in_system_interface(self): print "test_delete_institute_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + data_dict = { 'key' : KEY, 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } data_dict1 = { 'key' : KEY, 'inst_name': 'IIT Kharagpur', - 'inst_id': 'IITKgp' + 'inst_id': 'IITKgp', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } institute = SystemInterface.add_institute(data_dict) @@ -4060,33 +5922,49 @@ class TestDeleteDiscipline(TestCase): def test_delete_discipline_name_in_system_interface(self): print "test_update_discipline_name_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + data_dict = {'dis_name': 'Computer Science', 'dis_id': 'CSE', - 'key' : KEY - } + 'key' : KEY, + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } - dis1 = SystemInterface.add_discipline(data_dict) - dis_id = SystemInterface.delete_discipline('CSE', KEY) - - self.assertEqual(dis_id, data_dict['dis_id']) + data_dict1 = {'dis_name': 'Electronics and Communication', + 'dis_id': 'ECE', + 'key' : KEY, + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + dis = SystemInterface.add_discipline(data_dict) + dis1 = SystemInterface.add_discipline(data_dict1) + dis_id = SystemInterface.delete_discipline('ECE', KEY) + + self.assertEqual(dis_id,'ECE') #+END_SRC -** Delete HostingInfo -#+NAME: class_delete_hostinginfo +** Delete Hosting_Info +#+NAME: class_delete_hosting_info #+begin_src python @staticmethod - def delete_hostinginfo(hosted_url, key): + def delete_hosting_info(hosted_url, key): session_cls = System.delegate.entities['session'] session = session_cls(key=str(key)) try: - current_app.logger.debug("running operation delete_hostinginfo") - hostinginfo_id = System.do("delete_hostinginfo", hosted_url=str(hosted_url), + current_app.logger.debug("running operation delete_hosting_info") + hosting_info_id = System.do("delete_hosting_info", hosted_url=str(hosted_url), session=session) - current_app.logger.debug("completed operation delete_hostinginfo") - return hostinginfo_id + current_app.logger.debug("completed operation delete_hosting_info") + return hosting_info_id except (ArityError, TypeError, NotAuthorizedError, StateError) as err: current_app.logger.error("Exception = %s" % str(err)) raise err @@ -4097,9 +5975,9 @@ class TestDeleteDiscipline(TestCase): #+end_src *** TestDeleteHostedInfo - #+NAME: test_class_delete_hostinginfo + #+NAME: test_class_delete_hosting_info #+BEGIN_SRC python -class TestDeleteHostingInfo(TestCase): +class TestDeleteHosting_Info(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -4112,8 +5990,8 @@ class TestDeleteHostingInfo(TestCase): db.session.remove() db.drop_all() - def test_delete_hostinginfo_in_system_interface(self): - print "test_delete_hostinginfo_in_system_interface" + def test_delete_hosting_info_in_system_interface(self): + print "test_delete_hosting_info_in_system_interface" data_dict = { 'key' : KEY, @@ -4122,16 +6000,16 @@ class TestDeleteHostingInfo(TestCase): 'hosted_on': 'cloud' } + hosting_info = SystemInterface.add_hosting_info(data_dict) + data_dict1 = { 'key' : KEY, 'hosting_status': 'not hosted', 'hosted_url': 'http://cse12-iiith.vlabs.ac.in', 'hosted_on': 'server' } - - hostinginfo = SystemInterface.add_hostinginfo(data_dict) - hostinginfo1 = SystemInterface.add_hostinginfo(data_dict1) - hosted_url = SystemInterface.delete_hostinginfo("http://cse14-iiith.vlabs.ac.in", KEY) + hosting_info1 = SystemInterface.add_hosting_info(data_dict1) + hosted_url = SystemInterface.delete_hosting_info("http://cse14-iiith.vlabs.ac.in", KEY) self.assertEqual(hosted_url, "http://cse14-iiith.vlabs.ac.in") @@ -4142,15 +6020,13 @@ class TestDeleteHostingInfo(TestCase): #+NAME: class_delete_name #+begin_src python @staticmethod - def delete_name(name, key): + def delete_name(id): session_cls = System.delegate.entities['session'] - name_cls = System.delegate.entities['name'] - session = session_cls(key=str(key)) - name = name_cls(name=str(name)) + session = session_cls(key=KEY) try: current_app.logger.debug("running operation delete_name") - name = System.do("delete_name", name=name, session=session) + name = System.do("delete_name", n_id=int(id), session=session) current_app.logger.debug("completed operation delete_name") return name except (ArityError, TypeError, NotAuthorizedError, StateError) as err: @@ -4193,10 +6069,9 @@ class TestDeleteName(TestCase): name = SystemInterface.add_name(data_dict) name1 = SystemInterface.add_name(data_dict1) - name_id = SystemInterface.delete_name(data_dict1['name'], - data_dict1['key']) + name_id = SystemInterface.delete_name(1) - self.assertEqual(name_id.get("name"), data_dict1["name"]) + self.assertEqual(name_id, 1) #+END_SRC @@ -4313,15 +6188,46 @@ class TestDeleteDeveloper(TestCase): print "test_delete_developer_in_system_interface" data_dict = { - 'key': KEY, - 'name': 'Prof. Dharmaraj', - 'email': 'abc@gmail.com' + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + discipline = SystemInterface.add_discipline(data_dict) + + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } data_dict1 = { 'key': KEY, 'name' : 'Prof. Raja', - 'email': 'xyz@gmail.com' + 'email': 'xyz@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } developer = SystemInterface.add_developer(data_dict) @@ -4334,21 +6240,21 @@ class TestDeleteDeveloper(TestCase): #+END_SRC -** Delete IntegrationStatus -#+NAME: class_delete_integrationstatus +** Delete Integration_Status +#+NAME: class_delete_integration_status #+begin_src python @staticmethod - def delete_integrationstatus(integration_level, key): + def delete_integration_status(integration_level, key): session_cls = System.delegate.entities['session'] session = session_cls(key=str(key)) try: - current_app.logger.debug("running operation delete_integrationstatus") - integrationstatus_id = System.do("delete_integrationstatus", + current_app.logger.debug("running operation delete_integration_status") + integration_status_id = System.do("delete_integration_status", integration_level=int(integration_level), session=session) - current_app.logger.debug("completed operation delete_integrationstatus") - return integrationstatus_id + current_app.logger.debug("completed operation delete_integration_status") + return integration_status_id except (ArityError, TypeError, NotAuthorizedError, StateError) as err: current_app.logger.error("Exception = %s" % str(err)) @@ -4359,10 +6265,10 @@ class TestDeleteDeveloper(TestCase): raise err #+end_src -*** TestDeleteIntegrationStatus - #+NAME: test_class_delete_integrationstatus +*** TestDeleteIntegration_Status + #+NAME: test_class_delete_integration_status #+BEGIN_SRC python -class TestDeleteIntegrationStatus(TestCase): +class TestDeleteIntegration_Status(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -4375,8 +6281,8 @@ class TestDeleteIntegrationStatus(TestCase): db.session.remove() db.drop_all() - def test_delete_integrationstatus_in_system_interface(self): - print "test_delete_integrationstatus_in_system_interface" + def test_delete_integration_status_in_system_interface(self): + print "test_delete_integration_status_in_system_interface" data_dict = { 'key' : KEY, @@ -4388,9 +6294,9 @@ class TestDeleteIntegrationStatus(TestCase): 'integration_level': 2 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) - integrationstatus1 = SystemInterface.add_integrationstatus(data_dict1) - integration_level = SystemInterface.delete_integrationstatus(2, KEY) + integration_status = SystemInterface.add_integration_status(data_dict) + integration_status1 = SystemInterface.add_integration_status(data_dict1) + integration_level = SystemInterface.delete_integration_status(2, KEY) self.assertEqual(integration_level, 2) @@ -4439,16 +6345,26 @@ class TestGetInstituteByInstituteId(TestCase): def test_get_institute_by_instituteid_in_system_interface(self): print "test_get_institute_by_instituteid_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + data_dict = { 'key' : KEY, 'inst_name': 'IIT Delhi', - 'inst_id': 'IITD' + 'inst_id': 'IITD', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } data_dict1 = { 'key' : KEY, 'inst_name': 'IIT Kanpur', 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] } institute = SystemInterface.add_institute(data_dict) @@ -4504,71 +6420,89 @@ class TestGetLabByLabId(TestCase): def test_get_lab_by_labid_in_system_interface(self): print "test_get_lab_by_labid_in_system_interface" - data_dict = { - 'key': KEY, - 'exp_name': 'arrays', - 'exp_id': 'exp123', - 'overview': 'overview', - 'sections': [] - } - - experiment = SystemInterface.add_experiment(data_dict) - data_dict = { 'key' : KEY, 'integration_level': 4 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) + integration_status = SystemInterface.add_integration_status(data_dict) data_dict = { 'key' : KEY, - 'inst_name': 'IIT Kanpur', - 'inst_id': 'IITK' + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' } - institute = SystemInterface.add_institute(data_dict) + asset = SystemInterface.add_asset(data_dict) data_dict = { - 'key' : KEY, - 'dis_name': 'computer science', - 'dis_id': 'CSE' + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY } - discipline = SystemInterface.add_discipline(data_dict) + hosting_info = SystemInterface.add_hosting_info(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/logo.png' - } + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } - asset1 = SystemInterface.add_asset(data_dict) + institute = SystemInterface.add_institute(data_dict) data_dict = { 'key' : KEY, - 'asset_type': 'Image', - 'path': 'vlabs.ac.in/images/static/icon.png', - } + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } - asset2 = SystemInterface.add_asset(data_dict) + discipline = SystemInterface.add_discipline(data_dict) data_dict = { 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'], 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } developer = SystemInterface.add_developer(data_dict) data_dict = { - 'hosting_status': 'hosted', - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', - 'hosted_on': 'cloud', - 'key' : KEY + 'key': KEY, + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, + 'sections': [], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } - hostinginfo = SystemInterface.add_hostinginfo(data_dict) + experiment = SystemInterface.add_experiment(data_dict) data_dict = { 'key' : KEY, @@ -4577,11 +6511,24 @@ class TestGetLabByLabId(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } data_dict1 = { @@ -4591,11 +6538,24 @@ class TestGetLabByLabId(TestCase): 'overview': 'overview', 'inst_id': 'IITK', 'dis_id': 'CSE', - 'assets': ['vlabs.ac.in/images/static/icon.png'], + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}], 'experiments': ['exp123'], - 'integration_level': 4, - 'developers': ['abc@gmail.com'], - 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + 'integration_level': 4 } lab = SystemInterface.add_lab(data_dict) @@ -4623,48 +6583,139 @@ class TestGetLabByLabId(TestCase): return ("No exp found with expid: %s" % (exp_id)) return exp.to_client() - except (ArityError, TypeError, NotAuthorizedError, StateError) as err: - current_app.logger.error("Exception = %s" % str(err)) - raise err + except (ArityError, TypeError, NotAuthorizedError, StateError) as err: + current_app.logger.error("Exception = %s" % str(err)) + raise err + + except Exception as err: + current_app.logger.error("Exception = %s" % str(err)) + raise err +#+end_src + +*** TestGetExpByExpId + #+NAME: test_class_get_exp_by_expid + #+BEGIN_SRC python +class TestGetExpByExpId(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_exp_by_expid_in_system_interface(self): + print "test_get_exp_by_expid_in_system_interface" + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + discipline = SystemInterface.add_discipline(data_dict) - except Exception as err: - current_app.logger.error("Exception = %s" % str(err)) - raise err -#+end_src + data_dict = { + 'key' : KEY, + 'name': 'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' + } -*** TestGetExpByExpId - #+NAME: test_class_get_exp_by_expid - #+BEGIN_SRC python -class TestGetExpByExpId(TestCase): - TESTING = True - def create_app(self): - app = create_app(config) - return app + developer = SystemInterface.add_developer(data_dict) - def setUp(self): - db.create_all() + data_dict = { + 'key' : KEY, + 'integration_level': 4 + } - def tearDown(self): - db.session.remove() - db.drop_all() + integration_status = SystemInterface.add_integration_status(data_dict) - def test_get_exp_by_expid_in_system_interface(self): - print "test_get_exp_by_expid_in_system_interface" + data_dict = { + 'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY + } + + hosting_info = SystemInterface.add_hosting_info(data_dict) data_dict = { 'exp_name': 'Number Systems', 'exp_id': 'EE99777', 'overview': 'This is linked list experiment', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, 'sections': [], - 'key': KEY + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } data_dict1 = { 'exp_name': 'Binary Systems', 'exp_id': 'EE99778', 'overview': 'This is linked list experiment', + 'assets': [{'path':'vlabs.ac.in/images/static/logo.png', + 'asset_type': 'image'}, + {'path':'vlabs.ac.in/images/static/image.png', + 'asset_type': 'image'}], + 'integration_level': 4, 'sections': [], - 'key': KEY + 'key': KEY, + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'developers': [{'name':'Prof. Dharamaja', + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}, + {'name':'Prof. Pallavi Pawar', + 'email': 'pallavi.pawar@gmail.com', + 'inst_id': 'IITK', 'dis_id': 'CSE'}], + 'hosting_info': [{'hosted_url':'http://cse14-iiith.vlabs.ac.in', + 'hosting_status': 'hosted', + 'hosted_on': 'cloud'}, + {'hosted_url':'http://iitkgp.vlab.co.in/', + 'hosting_status': 'hosted', + 'hosted_on': 'server'}] } exp = SystemInterface.add_experiment(data_dict) @@ -4720,14 +6771,25 @@ class TestGetDisciplineByDisciplineId(TestCase): def test_get_discipline_by_disid_in_system_interface(self): print "test_get_discipline_by_disid_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = {'dis_name': 'Computer Science', 'dis_id': 'CSE', - 'key' : KEY + 'key' : KEY, + 'assets': ['vlabs.ac.in/images/static/logo.png'] } data_dict1 = {'dis_name': 'Electronics', 'dis_id': 'ECE', - 'key' : KEY + 'key' : KEY, + 'assets': ['vlabs.ac.in/images/static/logo.png'] } dis = SystemInterface.add_discipline(data_dict) @@ -4786,10 +6848,38 @@ class TestGetDeveloperByEmail(TestCase): def test_get_developer_by_email_in_system_interface(self): print "test_get_developer_by_email_in_system_interface" + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'computer science', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'] + } + + discipline = SystemInterface.add_discipline(data_dict) + data_dict = { 'key' : KEY, 'name': 'Prof. Dharamaja', - 'email': 'abc@gmail.com' + 'email': 'abc@gmail.com', + 'inst_id': 'IITK', + 'dis_id': 'CSE' } developer = SystemInterface.add_developer(data_dict) @@ -4801,17 +6891,19 @@ class TestGetDeveloperByEmail(TestCase): #+END_SRC -** Get IntegrationStatus by IL -#+NAME: class_get_integrationstatus_by_IL +** Get Integration_Status by IL +#+NAME: class_get_integration_status_by_IL #+begin_src python @staticmethod - def get_integrationstatus_by_IL(integration_level): + def get_integration_status_by_IL(integration_level): try: - current_app.logger.debug("running operation get_integrationstatus_by_integration_level") - integrationstatus_id = System.do("get_integrationstatus_by_IL", + current_app.logger.debug("running operation get_integration_status_" + " by_integration_level") + integration_status_id = System.do("get_integration_status_by_IL", integration_level=int(integration_level)) - current_app.logger.debug("completed operation get_integrationstatus_by_integration_level") - return integrationstatus_id + current_app.logger.debug("completed operation get_integration_" + " status_by_integration_level") + return integration_status_id except (ArityError, TypeError, NotAuthorizedError, StateError) as err: current_app.logger.error("Exception = %s" % str(err)) @@ -4822,10 +6914,10 @@ class TestGetDeveloperByEmail(TestCase): raise err #+end_src -*** TestGetIntegrationStatusByIL - #+NAME: test_class_get_integrationstatus_by_IL +*** TestGetIntegration_StatusByIL + #+NAME: test_class_get_integration_status_by_IL #+BEGIN_SRC python -class TestGetIntegrationStatusByIL(TestCase): +class TestGetIntegration_StatusByIL(TestCase): TESTING = True def create_app(self): app = create_app(config) @@ -4838,8 +6930,8 @@ class TestGetIntegrationStatusByIL(TestCase): db.session.remove() db.drop_all() - def test_get_integrationstatus_by_IL_in_system_interface(self): - print "test_get_integrationstatus_by_IL_in_system_interface" + def test_get_integration_status_by_IL_in_system_interface(self): + print "test_get_integration_status_by_IL_in_system_interface" data_dict = { 'key' : KEY, @@ -4851,9 +6943,9 @@ class TestGetIntegrationStatusByIL(TestCase): 'integration_level': 2 } - integrationstatus = SystemInterface.add_integrationstatus(data_dict) - integrationstatus1 = SystemInterface.add_integrationstatus(data_dict1) - integration_status = SystemInterface.get_integrationstatus_by_IL(2) + integration_status = SystemInterface.add_integration_status(data_dict) + integration_status1 = SystemInterface.add_integration_status(data_dict1) + integration_status = SystemInterface.get_integration_status_by_IL(2) self.assertEqual(integration_status.get("integration_level"), 2) @@ -4867,7 +6959,7 @@ class TestGetIntegrationStatusByIL(TestCase): def add_asset(data_dict): session_cls = System.delegate.entities['session'] asset_cls = System.delegate.entities['asset'] - + session = session_cls(key=data_dict['key']) del(data_dict['key']) @@ -4912,10 +7004,11 @@ class TestAddAsset(TestCase): data_dict = { 'key' : KEY, 'asset_type': 'Image', - 'path': 'vlabs.ac.in/static/images/icon.png' - } + 'path': 'vlabs.ac.in/images/static/logo.png' + } asset = SystemInterface.add_asset(data_dict) + asset_cls = System.delegate.entities['asset'] asset = asset_cls.get_all()[0] @@ -4932,8 +7025,8 @@ class TestAddAsset(TestCase): @staticmethod def update_asset(data_dict): session_cls = System.delegate.entities['session'] - session = session_cls(key=data_dict['key']) - + session = session_cls(key=str(data_dict['key'])) + path = str(data_dict['path']) asset = System.do("get_asset", path=path) @@ -4973,8 +7066,8 @@ class TestUpdateAsset(TestCase): db.session.remove() db.drop_all() - def test_update_asset_name_in_system_interfaceinterface(self): - print "test_update_asset_name_in_system_interface" + def test_update_asset_type_in_system_interface(self): + print "test_update_asset_type_in_system_interface" data_dict = { 'key' : KEY, @@ -5065,6 +7158,7 @@ class TestDeleteAsset(TestCase): @staticmethod def get_assets(): asset_cls = System.delegate.entities['asset'] + try: current_app.logger.debug("getting assets") assets = asset_cls.get_all() @@ -5084,6 +7178,207 @@ class TestDeleteAsset(TestCase): raise err #+end_src +*** TestGetAssets + #+NAME: test_class_get_assets + #+BEGIN_SRC python +class TestGetAssets(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_assets_in_system_interface(self): + print "test_get_assets_in_system_interface" + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict1 = { + 'key' : KEY, + 'asset_type': 'Video', + 'path': 'vlabs.ac.in/images/static/icon.png' + } + + asset1 = SystemInterface.add_asset(data_dict1) + + asset_dict_list = SystemInterface.get_assets() + + self.assertEqual(asset_dict_list[0].get("asset_type"), data_dict['asset_type']) + self.assertEqual(asset_dict_list[1].get("asset_type"), data_dict1['asset_type']) + self.assertEqual(asset_dict_list[0].get("path"), + data_dict['path']) + self.assertEqual(asset_dict_list[1].get("path"), + data_dict1['path']) + + #+END_SRC + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +** Get Asset By Path +#+NAME: class_get_asset_by_path +#+begin_src python + @staticmethod + def get_asset_by_path(path): + asset_cls = System.delegate.entities['asset'] + + try: + current_app.logger.debug("running get_asset_by_path") + asset = System.do("get_asset", path=str(path)) + current_app.logger.debug("completed operation get_asset_by_path") + if not asset: + return ("No asset found with path: %s" % (path)) + return asset.to_client() + + except (ArityError, TypeError, NotAuthorizedError, StateError) as err: + current_app.logger.error("Exception = %s" % str(err)) + raise err + + except Exception as err: + current_app.logger.error("Exception = %s" % str(err)) + raise err +#+end_src + +*** TestGetAssetByPath + #+NAME: test_class_get_asset_by_path + #+BEGIN_SRC python +class TestGetAssetByPath(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_asset_by_path_in_system_interface(self): + print "test_get_asset_by_path_in_system_interface" + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset = SystemInterface.add_asset(data_dict) + + data_dict1 = { + 'key' : KEY, + 'asset_type': 'Video', + 'path': 'vlabs.ac.in/images/static/icon.png' + } + + asset1 = SystemInterface.add_asset(data_dict1) + + asset_data_one = SystemInterface.get_asset_by_path(data_dict['path']) + + self.assertEqual(asset_data_one.get("path"), data_dict['path']) + #+END_SRC + +** Get Hosting_Info_by_hosted_URL +#+NAME: class_get_hosting_info_by_hosted_URL +#+begin_src python + @staticmethod + def get_hosting_info_by_hosted_url(hosted_url): + hosting_info_cls = System.delegate.entities['hosting_info'] + try: + current_app.logger.debug("getting hosting_info by hosted URL") + hosting_info = System.do("get_hosting_info", hosted_url=str(hosted_url)) + current_app.logger.debug("completed operation get_hosting_info_by_hosted_url") + if not hosting_info: + return ("No hosting_info found with hosted_url: %s" % (hosted_url)) + return hosting_info.to_client() + + except (ArityError, TypeError, NotAuthorizedError, StateError) as err: + current_app.logger.error("Exception = %s" % str(err)) + raise err + + except Exception as err: + current_app.logger.error("Exception = %s" % str(err)) + raise err +#+end_src + +*** TestGetHosting_Info_by hosted_url + #+NAME: test_class_get_hosting_info_by_hosted_url + #+BEGIN_SRC python +class TestGetHosting_Info_by_hosted_url(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_hosting_info_by_hosted_url_in_system_interface(self): + print "test_get_hosting_info_by_hosted_url_in_system_interface" + + data_dict = {'hosting_status': 'hosted', + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in', + 'hosted_on': 'cloud', + 'key' : KEY + } + + data_dict1 = {'hosting_status': 'not hosted', + 'hosted_url': 'http://cse12-iiith.vlabs.ac.in', + 'hosted_on': 'server', + 'key' : KEY + } + + host1 = SystemInterface.add_hosting_info(data_dict) + host2 = SystemInterface.add_hosting_info(data_dict1) + + host_list = SystemInterface.get_hosting_info_by_hosted_url('http://cse12-iiith.vlabs.ac.in') + + self.assertEqual(host_list.get("hosted_url"), data_dict1['hosted_url']) + + #+END_SRC + * Infra :boilerplate: @@ -5144,8 +7439,8 @@ if __name__ == '__main__': <> <> <> -<> -<> +<> +<> <> <> @@ -5153,32 +7448,31 @@ if __name__ == '__main__': <> <> <> -<> +<> <> - <> <> <> <> <> <> -<> -<> +<> +<> <> <> <> <> <> -<> +<> <> <> <> <> <> -<> -<> +<> +<> <> <> @@ -5187,7 +7481,8 @@ if __name__ == '__main__': <> <> <> - +<> +<> <> <> <> @@ -5200,6 +7495,9 @@ if __name__ == '__main__': <> <> <> +<> +<> +<> #+end_src @@ -5215,27 +7513,28 @@ if __name__ == '__main__': <> <> <> -<> -<> +<> +<> <> <> <> <> <> -<> -<> +<> +<> <> <> <> <> <> -<> -<> - +<> +<> +<> <> +<> <> <> <> @@ -5245,7 +7544,7 @@ if __name__ == '__main__': <> <> <> -<> +<> <> <> @@ -5264,11 +7563,15 @@ if __name__ == '__main__': <> <> <> -<> +<> <> <> <> <> +<> +<> +<> +<> <> #+end_src diff --git a/src/runtime/system/system-interface.org_archive b/src/runtime/system/system-interface.org_archive new file mode 100644 index 0000000..7115945 --- /dev/null +++ b/src/runtime/system/system-interface.org_archive @@ -0,0 +1,120 @@ +# -*- mode: org -*- + + +Archived entries from file /home/osboxes/vlabs/lab-data-service/src/runtime/system/system-interface.org + + +* TestGetLabsByAsset + :PROPERTIES: + :ARCHIVE_TIME: 2017-02-22 Wed 11:45 + :ARCHIVE_FILE: ~/vlabs/lab-data-service/src/runtime/system/system-interface.org + :ARCHIVE_OLPATH: The =SystemInterface= class/Get Labs by Asset + :ARCHIVE_CATEGORY: system-interface + :END: +#+NAME: test_class_get_labs_by_asset +#+BEGIN_SRC python +class TestGetLabsByAsset(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_labs_by_asset_in_system_interface(self): + print "test_get_labs_by_asset_in_system_interface" + + + data_dict = { + 'key' : KEY, + 'integration_level': 4 + } + + integrationstatus = SystemInterface.add_integrationstatus(data_dict) + + data_dict = { + 'key' : KEY, + 'inst_name': 'IIT Kanpur', + 'inst_id': 'IITK' + } + + institute = SystemInterface.add_institute(data_dict) + + data_dict = { + 'key' : KEY, + 'dis_name': 'Computer Science', + 'dis_id': 'CSE' + } + + discipline = SystemInterface.add_discipline(data_dict) + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/logo.png' + } + + asset1 = SystemInterface.add_asset(data_dict) + + + data_dict = { + 'key' : KEY, + 'asset_type': 'Image', + 'path': 'vlabs.ac.in/images/static/icon.png', + } + + asset2 = SystemInterface.add_asset(data_dict) + + + data_dict = { + 'key': KEY, + 'exp_name': 'arrays', + 'exp_id': 'exp123', + 'overview': 'overview', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'integration_level': 4, + 'sections': [], + 'developers': ['abc@gmail.com'], + 'hosted_url': 'http://cse14-iiith.vlabs.ac.in' + } + + experiment = SystemInterface.add_experiment(data_dict + + data_dict = { + 'key': KEY, + 'lab_name': 'Data Structures', + 'lab_id': 'cse01', + 'overview': 'overview', + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/logo.png'], + 'experiments': ['exp123'], + 'integration_level': 4 + } + + data_dict1 = { + 'key': KEY, + 'lab_name': 'Computer Programming', + 'lab_id': 'cse02', + 'overview': 'overview', + 'inst_id': 'IITK', + 'dis_id': 'CSE', + 'assets': ['vlabs.ac.in/images/static/icon.png'], + 'experiments': ['exp123'], + 'integration_level': 4 + } + + lab = SystemInterface.add_lab(data_dict) + lab1 = SystemInterface.add_lab(data_dict1) + + labs = SystemInterface.get_labs_by_asset("Image") + + self.assertEqual(labs[0]['asset']['asset_type'], "Image") + +#+END_SRC + diff --git a/src/runtime/system/system-with-persistence.org b/src/runtime/system/system-with-persistence.org index aafdf1f..8e8b1c3 100755 --- a/src/runtime/system/system-with-persistence.org +++ b/src/runtime/system/system-with-persistence.org @@ -1,3 +1,4 @@ +` #+TITLE: Test System with Persistence #+AUTHOR: VLEAD #+DATE: [2016-06-07 Tue] @@ -41,52 +42,55 @@ class TestAddLab(TestCase): discipline_cls = System.delegate.entities['discipline'] asset_cls = System.delegate.entities['asset'] experiment_cls = System.delegate.entities['experiment'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] + integration_status_cls = System.delegate.entities['integration_status'] name_cls = System.delegate.entities['name'] email_cls = System.delegate.entities['email'] developer_cls = System.delegate.entities['developer'] - hostinginfo_cls = System.delegate.entities['hostinginfo'] - - exp_name = "arrays" - exp_id = "cse02" - overview = "overview" - experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) - experiment.save() + hosting_info_cls = System.delegate.entities['hosting_info'] integration_level = 4 - integrationstatus = integrationstatus_cls(integration_level=integration_level) - integrationstatus.save() - - dev_name = name_cls(name="Mohit Tahiliani") - dev_name.save() - - email_id = email_cls(email="mohit.tahiliani@gmail.com") - email_id.save() + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() - dev = developer_cls(name=dev_name, email=email_id) - dev.save() + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() inst_name = "IIT Kanpur" inst_id = "IITK" - inst = institute_cls(inst_name=inst_name, inst_id=inst_id) + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = asset_cls(asset_type=asset_type, path=path) - asset.save() + dev_name = name_cls(name="Mohit Tahiliani") + dev_name.save() + email_id = email_cls(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = hostinginfo_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) host.save() + + exp_name = "arrays" + exp_id = "cse02" + overview = "overview" + experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], + developers=[dev], hosting_info=[host]) + experiment.save() lab_name1="Computer Programming" lab_id1="CSE01" @@ -95,8 +99,8 @@ class TestAddLab(TestCase): session = session_cls(key=key) lab = lab_cls(lab_id=lab_id1, lab_name=lab_name1, institute=inst, discipline=discipline, assets=[asset], - overview=overview, integrationstatus=integrationstatus, - experiments=[experiment], developers=[dev], hostinginfo=host) + overview=overview, integration_status=integration_status, + experiments=[experiment], developers=[dev], hosting_info=[host]) lab1 = System.do("add_lab", lab=lab, session=session) new_lab = lab_cls.get_by_id(1) @@ -127,11 +131,59 @@ class TestAddExperiment(TestCase): print "test_add_experiment_in_system_persistence" session_cls = System.delegate.entities['session'] experiment_cls = System.delegate.entities['experiment'] + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] + integration_status_cls = System.delegate.entities['integration_status'] + asset_cls = System.delegate.entities['asset'] + name_cls = System.delegate.entities['name'] + email_cls = System.delegate.entities['email'] + developer_cls = System.delegate.entities['developer'] + hosting_info_cls = System.delegate.entities['hosting_info'] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) + discipline.save() + + dev_name = name_cls(name="Mohit Tahiliani") + dev_name.save() + email_id = email_cls(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host.save() + exp_name = "arrays" exp_id = "cse02" overview = "overview" + + integration_level = 4 + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() + experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], + developers=[dev], hosting_info=[host]) + key = KEY session = session_cls(key=key) experiment = System.do("add_experiment", experiment=experiment, \ @@ -165,9 +217,16 @@ class TestAddInstitute(TestCase): print "test_add_institute_in_system_persistence" session_cls = System.delegate.entities['session'] institute_cls = System.delegate.entities['institute'] + asset_cls = System.delegate.entities['asset'] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - institute = institute_cls(inst_name=inst_name, inst_id=inst_id) + institute = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) key = KEY session = session_cls(key=key) @@ -200,9 +259,17 @@ class TestAddDiscipline(TestCase): print "test_add_discipline_in_system_persistence" session_cls = System.delegate.entities['session'] discipline_cls = System.delegate.entities['discipline'] + asset_cls = System.delegate.entities['asset'] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + dis_name = "arrays" dis_id = "cse02" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) + key = KEY session = session_cls(key=key) discipline = System.do("add_discipline", discipline=discipline, session=session) @@ -234,12 +301,58 @@ class TestAddSectionsToExperiment(TestCase): session_cls = System.delegate.entities['session'] section_cls = System.delegate.entities['section'] experiment_cls = System.delegate.entities['experiment'] + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] + integration_status_cls = System.delegate.entities['integration_status'] + asset_cls = System.delegate.entities['asset'] + name_cls = System.delegate.entities['name'] + email_cls = System.delegate.entities['email'] + developer_cls = System.delegate.entities['developer'] + hosting_info_cls = System.delegate.entities['hosting_info'] + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host.save() + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + dis_name = "computer science" + dis_id = "cse" + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) + discipline.save() + + dev_name = name_cls(name="Mohit Tahiliani") + dev_name.save() + email_id = email_cls(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + integration_level = 4 + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() + exp_name = "arrays" exp_id = "cse02" overview = "overview" experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], + developers=[dev], hosting_info=[host]) + key = KEY session = session_cls(key=key) experiment = System.do("add_experiment", experiment=experiment, \ @@ -287,9 +400,14 @@ class TestAddLabsToInstitute(TestCase): lab_cls = System.delegate.entities['lab'] institute_cls = System.delegate.entities['institute'] + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + inst_name = "arrays" inst_id = "cse02" - institute = institute_cls(inst_name=inst_name, inst_id=inst_id) + institute = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) key = KEY session = session_cls(key=key) @@ -412,10 +530,10 @@ class TestAddEmail(TestCase): #+END_SRC -* Test AddHostingInfo -#+NAME: test_add_hostinginfo +* Test AddHosting_Info +#+NAME: test_add_hosting_info #+BEGIN_SRC python -class TestAddHostingInfo(TestCase): +class TestAddHosting_Info(TestCase): TESTING = True @@ -430,22 +548,22 @@ class TestAddHostingInfo(TestCase): db.session.remove() db.drop_all() - def test_add_hostinginfo(self): - print "test_add_hostinginfo_in_system_persistence" + def test_add_hosting_info(self): + print "test_add_hosting_info_in_system_persistence" session_cls = System.delegate.entities['session'] - hostinginfo_cls = System.delegate.entities['hostinginfo'] + hosting_info_cls = System.delegate.entities['hosting_info'] hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - hostinginfo = hostinginfo_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + hosting_info = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) key = KEY session = session_cls(key=key) - hostinginfo = System.do("add_hostinginfo", hostinginfo=hostinginfo, \ + hosting_info = System.do("add_hosting_info", hosting_info=hosting_info, \ session=session) - hostinginfo1 = hostinginfo_cls.get_by_id(1) - self.assertEqual(hostinginfo1.get("hosting_status"), hosting_status) - self.assertEqual(hostinginfo1.get("hosted_on"), hosted_on) + hosting_info1 = hosting_info_cls.get_by_id(1) + self.assertEqual(hosting_info1.get("hosting_status"), hosting_status) + self.assertEqual(hosting_info1.get("hosted_on"), hosted_on) #+END_SRC @@ -473,13 +591,32 @@ class TestAddDeveloper(TestCase): developer_cls = System.delegate.entities['developer'] email_cls = System.delegate.entities['email'] name_cls = System.delegate.entities['name'] + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] + asset_cls = System.delegate.entities['asset'] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) + discipline.save() name = name_cls(name="Prof. S. Dharmaraja") name.save() email = email_cls(email="dharmar@maths.iitd.ac.in") email.save() - developer = developer_cls(name=name, email=email) + developer = developer_cls(name=name, email=email, + institute=inst, discipline=discipline) key = KEY session = session_cls(key=key) @@ -490,10 +627,10 @@ class TestAddDeveloper(TestCase): #+END_SRC -* Test AddIntegrationStatus -#+NAME: test_add_integrationstatus +* Test AddIntegration_Status +#+NAME: test_add_integration_status #+BEGIN_SRC python -class TestAddIntegrationStatus(TestCase): +class TestAddIntegration_Status(TestCase): TESTING = True @@ -508,26 +645,26 @@ class TestAddIntegrationStatus(TestCase): db.session.remove() db.drop_all() - def test_add_integrationstatus(self): - print "test_add_integrationstatus_in_system_persistence" + def test_add_integration_status(self): + print "test_add_integration_status_in_system_persistence" session_cls = System.delegate.entities['session'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] + integration_status_cls = System.delegate.entities['integration_status'] integration_level = 4 - integrationstatus = integrationstatus_cls(integration_level=integration_level) + integration_status = integration_status_cls(integration_level=integration_level) key = KEY session = session_cls(key=key) - integrationstatus = System.do("add_integrationstatus", integrationstatus=integrationstatus, \ + integration_status = System.do("add_integration_status", integration_status=integration_status, \ session=session) - integrationstatus1 = integrationstatus_cls.get_by_id(1) - self.assertEqual(integrationstatus1.get("integration_level"), integration_level) + integration_status1 = integration_status_cls.get_by_id(1) + self.assertEqual(integration_status1.get("integration_level"), integration_level) #+END_SRC * Test UpdateLab #+NAME: test_update_lab #+BEGIN_SRC python -class TestUpdateLab(TestCase): +class TestUpdateLabt(TestCase): TESTING = True def create_app(self): @@ -545,82 +682,158 @@ class TestUpdateLab(TestCase): print "test_update_lab_in_system_persistence" session_cls = System.delegate.entities['session'] - lab_cls = System.delegate.entities['lab'] - institute_cls = System.delegate.entities['institute'] - discipline_cls = System.delegate.entities['discipline'] + exp_cls = System.delegate.entities['experiment'] + integration_status_cls = System.delegate.entities['integration_status'] asset_cls = System.delegate.entities['asset'] - experiment_cls = System.delegate.entities['experiment'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] name_cls = System.delegate.entities['name'] email_cls = System.delegate.entities['email'] developer_cls = System.delegate.entities['developer'] - hostinginfo_cls = System.delegate.entities['hostinginfo'] + hosting_info_cls = System.delegate.entities['hosting_info'] + institute_cls = System.delegate.entities['institute'] + experiment_cls = System.delegate.entities['experiment'] + discipline_cls = System.delegate.entities['discipline'] + lab_cls = System.delegate.entities['lab'] - exp_name = "arrays" - exp_id = "cse02" - overview = "overview" - experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) - experiment.save() + session = session_cls(key=KEY) + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() inst_name = "IIT Kanpur" inst_id = "IITK" - inst = institute_cls(inst_name=inst_name, inst_id=inst_id) + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() integration_level = 4 - integrationstatus = integrationstatus_cls(integration_level=integration_level) - integrationstatus.save() + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = asset_cls(asset_type=asset_type, path=path) - asset.save() - dev_name = name_cls(name="Mohit Tahiliani") dev_name.save() email_id = email_cls(email="mohit.tahiliani@gmail.com") email_id.save() - dev = developer_cls(name=dev_name, email=email_id) + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() - hosting_status = "hosted" - hosted_url = "http://cse14-iiith.vlabs.ac.in" - hosted_on = "cloud" - host = hostinginfo_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) - host.save() + exp_name = "arrays" + exp_id = "cse02" + overview = "overview" + experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], + developers=[dev], hosting_info=[host]) + experiment.save() - lab_name1="Computer Programming" - lab_id1="CSE01" - key = KEY + lab_name = "Computer Programming" + lab_id = "CSE01" overview = "overview" - session = session_cls(key=key) + lab = lab_cls(lab_id=lab_id, lab_name=lab_name, + institute=inst, discipline=discipline, + assets=[asset], overview=overview, + integration_status=integration_status, + experiments=[experiment], developers=[dev], + hosting_info=[host]) + lab.save() - lab = lab_cls(lab_id=lab_id1, lab_name=lab_name1, - institute=inst, discipline=discipline, assets=[asset], - overview=overview, integrationstatus=integrationstatus, - experiments=[experiment], developers=[dev], hostinginfo=host) + lab_name1 = "two dimentional arrays" + overview1 = "exp overview" - lab.save() - lab_name2="Computer Programming" - overview2="CSE01 overview" + asset_type1 = "Video" + path1 = "vlabs.ac.in/images/video/icon.png" + asset1 = asset_cls(asset_type=asset_type1, path=path1) + asset1.save() - lab1 = System.do("update_lab", lab_name=lab_name2, - lab=lab, overview=overview2, - session=session) + inst_name1 = "IIT Kharagpur" + inst_id1 = "IITKgp" + inst1 = institute_cls(inst_name=inst_name1, inst_id=inst_id1, assets=[asset]) + inst1.save() + + dis_name1 = "Computer Science & Engineering" + dis_id1 = "CSE02" + discipline1 = discipline_cls(dis_name=dis_name1, dis_id=dis_id1, assets=[asset]) + discipline1.save() + + integration_level1 = 2 + integration_status1 = integration_status_cls(integration_level=integration_level1) + integration_status1.save() + + dev_name1 = name_cls(name="pallavi pawar") + dev_name1.save() + email_id1 = email_cls(email="pallavi.pawar@gmail.com") + email_id1.save() + dev1 = developer_cls(name=dev_name1, email=email_id1, + institute=inst1, discipline=discipline1) + dev1.save() + + hosting_status1 = "hosted" + hosted_url1 = "http://cse13-iiith.vlabs.ac.in" + hosted_on1 = "cloud" + host1 = hosting_info_cls(hosting_status=hosting_status1, + hosted_url=hosted_url1, hosted_on=hosted_on1) + host1.save() + + exp_name1 = "Computer Programming" + overview1 = "overveiw exp" + exp_id1 = "cse03" + experiment1 = experiment_cls(exp_name=exp_name1, exp_id=exp_id1, + overview=overview1, sections=[], + institute=inst1, discipline=discipline1, + integration_status=integration_status1, + assets=[asset1], + developers=[dev1], hosting_info=[host1]) + experiment1.save() + + dev_name1 = name_cls(name="Tahiliani") + dev_name1.save() + email_id1 = email_cls(email="tahiliani@gmail.com") + email_id1.save() + dev1 = developer_cls(name=dev_name1, email=email_id1, + institute=inst1, discipline=discipline1) + dev1.save() + + lab1 = System.do("update_lab", lab=lab, lab_name=lab_name1, + overview=overview1, institute=inst1, + discipline=discipline1, hosting_info=[host1], + integration_status=integration_status1, + session=session, developers=[dev1], + assets=[asset1], experiments=[experiment1]) new_lab = lab_cls.get_by_id(1) - self.assertEqual(new_lab.get("lab_name"), lab_name2) - self.assertEqual(new_lab.get("overview"), overview2) - + self.assertEqual(new_lab.get("lab_name"), lab_name1) + self.assertEqual(new_lab.get("overview"), overview1) + self.assertEqual(new_lab.get("lab_id"), lab_id) + self.assertEqual(new_lab.get("institute").get("inst_id"), inst_id1) + self.assertEqual(new_lab.get("discipline").get("dis_id"), dis_id1) + self.assertEqual(new_lab.get("integration_status"). + get("integration_level"), integration_level1) + self.assertEqual(new_lab.get("hosting_info")[0].get("hosted_url"), + hosted_url1) + self.assertEqual(new_lab.get("developers")[0].get("email").get("email"), + email_id1.get("email")) + self.assertEqual(new_lab.get("assets")[0].get("path"), + path1) + self.assertEqual(new_lab.get("experiments")[0].get("exp_id"), + experiment1.get("exp_id")) + #+END_SRC - + * Test UpdateExperiment #+NAME: test_update_experiment @@ -644,30 +857,150 @@ class TestUpdateExperiment(TestCase): print "test_update_exp_in_system_persistence" session_cls = System.delegate.entities['session'] exp_cls = System.delegate.entities['experiment'] + integration_status_cls = System.delegate.entities['integration_status'] + asset_cls = System.delegate.entities['asset'] + name_cls = System.delegate.entities['name'] + email_cls = System.delegate.entities['email'] + developer_cls = System.delegate.entities['developer'] + hosting_info_cls = System.delegate.entities['hosting_info'] + institute_cls = System.delegate.entities['institute'] + experiment_cls = System.delegate.entities['experiment'] + discipline_cls = System.delegate.entities['discipline'] + lab_cls = System.delegate.entities['lab'] + section_cls = System.delegate.entities['section'] session = session_cls(key=KEY) + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = institute_cls(inst_name=inst_name, inst_id=inst_id,\ + assets=[asset]) + inst.save() + + integration_level = 4 + integration_status = integration_status_cls(integration_level=\ + integration_level) + integration_status.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = hosting_info_cls(hosting_status=hosting_status, + hosted_url=hosted_url, + hosted_on=hosted_on) + host.save() + + dis_name = "computer science" + dis_id = "cse" + discipline = discipline_cls(dis_name=dis_name, + dis_id=dis_id, assets=[asset]) + discipline.save() + + dev_name = name_cls(name="Mohit Tahiliani") + dev_name.save() + email_id = email_cls(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + name = "Theory" + section = section_cls(name=name) + section.save() + exp_name = "arrays" exp_id = "cse02" overview = "overview" - experiment = exp_cls(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) + experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, + overview=overview, sections=[section], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset],developers=[dev], + hosting_info=[host]) experiment.save() - exp_name2 = "two dimentional arrays" - overview2 = "exp overview" + exp_name1 = "Computer Programming" + overview1 = "overveiw exp" + + asset_type1 = "Video" + path1 = "vlabs.ac.in/images/video/icon.png" + asset1 = asset_cls(asset_type=asset_type1, path=path1) + asset1.save() + + inst_name1 = "IIT Kharagpur" + inst_id1 = "IITKgp" + inst1 = institute_cls(inst_name=inst_name1, inst_id=inst_id1, + assets=[asset1]) + inst1.save() + + dis_name1 = "electronics and communication" + dis_id1 = "ece" + discipline1 = discipline_cls(dis_name=dis_name1, + dis_id=dis_id1, assets=[asset1]) + discipline1.save() + + dev_name1 = name_cls(name="Palavi Pawar") + dev_name1.save() + email_id1 = email_cls(email="pallavipawar@gmail.com") + email_id1.save() + dev1 = developer_cls(name=dev_name1, email=email_id1, + institute=inst1, discipline=discipline1) + dev1.save() + + integration_level1 = 3 + integration_status1 = integration_status_cls(integration_level=\ + integration_level1) + integration_status1.save() - exp1 = System.do("update_experiment", exp_name=exp_name2, - experiment=experiment, overview=overview2, - session=session) + hosting_status1 = "hosted" + hosted_url1 = "http://cse13-iiith.vlabs.ac.in" + hosted_on1 = "cloud" + host1 = hosting_info_cls(hosting_status=hosting_status1, + hosted_url=hosted_url1, + hosted_on=hosted_on1) + host1.save() - new_exp = exp_cls.get_by_id(1) + key = KEY + session = session_cls(key=key) - self.assertEqual(new_exp.get("exp_name"), exp_name2) - self.assertEqual(new_exp.get("overview"), overview2) - self.assertEqual(new_exp.get("exp_id"), exp_id) + name1 = "Procedure" + section1 = section_cls(name=name1) + section1.save() + + exp2 = System.do("update_experiment", exp_name=exp_name1, + overview=overview1, institute=inst1, + session=session, discipline=discipline1, + integration_status=integration_status1, + sections=[section1], + hosting_info=[host1], experiment=experiment, + developers=[dev1], assets=[asset1]) + exp2 = exp_cls.get_by_id(1) + + self.assertEqual(exp2.get("exp_name"), exp_name1) + self.assertEqual(exp2.get("overview"), overview1) + self.assertEqual(exp2.get("exp_id"), exp_id) + self.assertEqual(exp2.get("institute").get("inst_id"), + inst1.get("inst_id")) + self.assertEqual(exp2.get("discipline").get("dis_id"), + discipline1.get("dis_id")) + self.assertEqual(exp2.get("integration_status").\ + get("integration_level"), + integration_status1.get("integration_level")) + self.assertEqual(exp2.get("hosting_info")[0].get("hosted_url"), + hosted_url1) + self.assertEqual(exp2.get("developers")[0].get("email").get("email"), + email_id1.get("email")) + self.assertEqual(exp2.get("assets")[0].get("path"), path1) + self.assertEqual(exp2.get("sections")[0].get("name"), name1) + #+END_SRC - + * Test UpdateInstitute #+NAME: test_update_institute @@ -691,27 +1024,41 @@ class TestUpdateInstitute(TestCase): print "test_update_institute_in_system_persistence" session_cls = System.delegate.entities['session'] institute_cls = System.delegate.entities['institute'] + asset_cls = System.delegate.entities['asset'] + + asset_type1 = "Image" + path1 = "vlabs.ac.in/images/static/logo.png" + asset1 = asset_cls(asset_type=asset_type1, path=path1) + asset1.save() inst_name1="IIT Kanpur" inst_id1="IITK" key = KEY session = session_cls(key=key) - institute = institute_cls(inst_id=inst_id1, inst_name=inst_name1) + institute = institute_cls(inst_id=inst_id1, inst_name=inst_name1, assets=[asset1]) institute.save() + asset_type1 = "Video" + path1 = "vlabs.ac.in/images/video/icon.png" + asset1 = asset_cls(asset_type=asset_type1, path=path1) + asset1.save() + inst_name2="IIT Kharagpur" institute1 = System.do("update_institute", inst_name=inst_name2, - institute=institute, session=session) + institute=institute, assets=[asset1], session=session) new_institute = institute_cls.get_by_id(1) self.assertEqual(new_institute.get("inst_name"), inst_name2) + self.assertEqual(new_institute.get("assets")[0].get("path"), + asset1.get("path")) + #+END_SRC -* Test UpdateDiscipline + * Test UpdateDiscipline #+NAME: test_update_discipline #+BEGIN_SRC python class TestUpdateDisciplilne(TestCase): @@ -733,20 +1080,33 @@ class TestUpdateDisciplilne(TestCase): print "test_update_discipline_in_system_persistence" session_cls = System.delegate.entities['session'] discipline_cls = System.delegate.entities['discipline'] + asset_cls = System.delegate.entities['asset'] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() dis_name = "arrays" dis_id = "cse02" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) discipline.save() key = KEY session = session_cls(key=key) + asset_type1 = "Video" + path1 = "vlabs.ac.in/images/video/icon.png" + asset1 = asset_cls(asset_type=asset_type1, path=path1) + asset1.save() + dis_name1 = "lists" discipline1 = System.do("update_discipline", dis_name=dis_name1, - discipline=discipline, session=session) + discipline=discipline, assets=[asset1], session=session) self.assertEqual(discipline1.get("dis_name"), dis_name1) + self.assertEqual(discipline1.get("assets")[0].get("path"), + asset1.get("path")) #+END_SRC @@ -778,10 +1138,10 @@ class TestUpdateSection(TestCase): #+END_SRC -* Test UpdateHostingInfo -#+NAME: test_update_hostinginfo +* Test UpdateHosting_Info +#+NAME: test_update_hosting_info #+BEGIN_SRC python -class TestUpdateHostingInfo(TestCase): +class TestUpdateHosting_Info(TestCase): TESTING = True def create_app(self): @@ -795,30 +1155,30 @@ class TestUpdateHostingInfo(TestCase): db.session.remove() db.drop_all() - def test_update_hostinginfo(self): + def test_update_hosting_info(self): - print "test_update_hostinginfo_in_system_persistence" + print "test_update_hosting_info_in_system_persistence" session_cls = System.delegate.entities['session'] - hostinginfo_cls = System.delegate.entities['hostinginfo'] + hosting_info_cls = System.delegate.entities['hosting_info'] hosting_status1 = "hosted" hosted_url1 = "http://cse14-iiith.vlabs.ac.in" hosted_on1 = "cloud" key = KEY session = session_cls(key=key) - hostinginfo = hostinginfo_cls(hosting_status=hosting_status1, hosted_url=hosted_url1, hosted_on=hosted_on1) + hosting_info = hosting_info_cls(hosting_status=hosting_status1, hosted_url=hosted_url1, hosted_on=hosted_on1) - hostinginfo.save() + hosting_info.save() hosting_status2 ="not hosted" hosted_on2 = "server" - hostinginfo1 = System.do("update_hostinginfo", hosting_status=hosting_status2, hosted_on=hosted_on2, - hostinginfo=hostinginfo, session=session) + hosting_info1 = System.do("update_hosting_info", hosting_status=hosting_status2, hosted_on=hosted_on2, + hosting_info=hosting_info, session=session) - new_hostinginfo = hostinginfo_cls.get_by_id(1) + new_hosting_info = hosting_info_cls.get_by_id(1) - self.assertEqual(new_hostinginfo.get("hosting_status"), hosting_status2) - self.assertEqual(new_hostinginfo.get("hosted_on"), hosted_on2) + self.assertEqual(new_hosting_info.get("hosting_status"), hosting_status2) + self.assertEqual(new_hosting_info.get("hosted_on"), hosted_on2) #+END_SRC @@ -845,14 +1205,58 @@ class TestDeleteExperiment(TestCase): print "test_delete_exp_in_system_persistence" session_cls = System.delegate.entities['session'] experiment_cls = System.delegate.entities['experiment'] + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] + integration_status_cls = System.delegate.entities['integration_status'] + asset_cls = System.delegate.entities['asset'] + name_cls = System.delegate.entities['name'] + email_cls = System.delegate.entities['email'] + developer_cls = System.delegate.entities['developer'] + hosting_info_cls = System.delegate.entities['hosting_info'] + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host.save() + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "computer science" + dis_id = "cse" + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) + discipline.save() + + dev_name = name_cls(name="Mohit Tahiliani") + dev_name.save() + email_id = email_cls(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + integration_level = 4 + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() exp_name = "arrays" exp_id = "cse02" overview = "overview" key = KEY experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) - + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], + developers=[dev], hosting_info=[host]) experiment.save() session = session_cls(key=key) exp_id1 = System.do("delete_experiment", exp_id = exp_id, @@ -887,24 +1291,58 @@ class TestUpdateDeveloper(TestCase): name_cls = System.delegate.entities['name'] email_cls = System.delegate.entities['email'] dev_cls = System.delegate.entities['developer'] + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] + asset_cls = System.delegate.entities['asset'] session = session_cls(key=KEY) + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "computer science" + dis_id = "cse" + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) + discipline.save() + dev_name = name_cls(name="Prof. Dharmaraja") dev_name.save() email_id = email_cls(email="raja@gmail.com") email_id.save() - developer = dev_cls(name=dev_name, email=email_id) + developer = dev_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) developer.save() + + inst_name1 = "IIT Kharagpur" + inst_id1 = "IITKgp" + inst1 = institute_cls(inst_name=inst_name1, inst_id=inst_id1, assets=[asset]) + inst1.save() + + dis_name1 = "Computer Science & Engineering" + dis_id1 = "CSE02" + discipline1 = discipline_cls(dis_name=dis_name1, dis_id=dis_id1, assets=[asset]) + discipline1.save() + dev_name2 = name_cls(name="Prof. Raja") dev_name2.save() dev1 = System.do("update_developer", developer=developer, - name=dev_name2, session=session) + name=dev_name2, institute=inst1, + discipline=discipline1, session=session) new_dev = dev_cls.get_by_id(1) self.assertEqual(new_dev.get("name").get("name"), dev_name2.get('name')) + self.assertEqual(new_dev.get("institute").get("inst_id"), inst_id1) + self.assertEqual(new_dev.get("discipline").get("dis_id"), dis_id1) #+END_SRC @@ -931,21 +1369,66 @@ class TestDeleteInstitute(TestCase): print "test_delete_institute_in_system_persistence" session_cls = System.delegate.entities['session'] institute_cls = System.delegate.entities['institute'] + asset_cls = System.delegate.entities['asset'] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() inst_name= "IIT Kanpur" inst_id= "IITK" key = KEY session = session_cls(key=key) - institute = institute_cls(inst_id=inst_id, inst_name=inst_name) + institute = institute_cls(inst_id=inst_id, inst_name=inst_name, assets=[asset]) institute.save() institute = System.do("delete_institute", inst_id = inst_id, session=session) - self.assertEqual(institute, inst_id) - -#+END_SRC + self.assertEqual(institute, inst_id) + +#+END_SRC + + + +* Test DeleteSection +#+NAME: test_delete_section +#+BEGIN_SRC python +class TestDeleteSection(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_delete_section(self): + print "test_delete_section_in_system_persistence" + session_cls = System.delegate.entities['session'] + section_cls = System.delegate.entities['section'] + + name = "theory" + key = KEY + session = session_cls(key=key) + section1 = section_cls(name=name) + section1.save() + + name1 = "procedure" + section2 = section_cls(name=name1) + section2.save() + section3 = System.do("delete_section", s_id=1, session=session) + + self.assertEqual(len(section_cls.get_all()), 1) +#+END_SRC * Test DeleteName @@ -975,10 +1458,14 @@ class TestDeleteName(TestCase): key = KEY session = session_cls(key=key) name1 = name_cls(name=name) - name1.save() - name2 = System.do("delete_name", name=name1, session=session) - self.assertEqual(name, name2.get("name")) + + name2 = "Prof. Raja" + name3 = name_cls(name=name2) + name3.save() + name4 = System.do("delete_name", n_id=1, session=session) + + self.assertEqual(len(name_cls.get_all()), 1) #+END_SRC @@ -1009,51 +1496,57 @@ class TestDeleteLab(TestCase): discipline_cls = System.delegate.entities['discipline'] asset_cls = System.delegate.entities['asset'] experiment_cls = System.delegate.entities['experiment'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] + integration_status_cls = System.delegate.entities['integration_status'] name_cls = System.delegate.entities['name'] email_cls = System.delegate.entities['email'] developer_cls = System.delegate.entities['developer'] - hostinginfo_cls = System.delegate.entities['hostinginfo'] - - exp_name = "arrays" - exp_id = "cse02" - overview = "overview" - experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) - experiment.save() + hosting_info_cls = System.delegate.entities['hosting_info'] integration_level = 4 - integrationstatus = integrationstatus_cls(integration_level=integration_level) - integrationstatus.save() + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() inst_name = "IIT Kanpur" inst_id = "IITK" - inst = institute_cls(inst_name=inst_name, inst_id=inst_id) + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) discipline.save() - - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = asset_cls(asset_type=asset_type, path=path) - asset.save() dev_name = name_cls(name="Mohit Tahiliani") dev_name.save() email_id = email_cls(email="mohit.tahiliani@gmail.com") email_id.save() - dev = developer_cls(name=dev_name, email=email_id) + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = hostinginfo_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) host.save() + exp_name = "arrays" + exp_id = "cse02" + overview = "overview" + experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], + developers=[dev], hosting_info=[host]) + + experiment.save() + lab_name1="Computer Programming" lab_id1="CSE01" key = KEY @@ -1062,9 +1555,9 @@ class TestDeleteLab(TestCase): lab = lab_cls(lab_id=lab_id1, lab_name=lab_name1, institute=inst, discipline=discipline, assets=[asset], - overview=overview, integrationstatus=integrationstatus, + overview=overview, integration_status=integration_status, experiments=[experiment], developers=[dev], - hostinginfo=host) + hosting_info=[host]) lab.save() lab_id = System.do("delete_lab", lab_id = lab_id1, session=session) @@ -1131,10 +1624,16 @@ class TestDeleteDiscipline(TestCase): print "test_delete_discipline_in_system_persistence" session_cls = System.delegate.entities['session'] discipline_cls = System.delegate.entities['discipline'] + asset_cls = System.delegate.entities['asset'] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() dis_name = "arrays" dis_id = "cse02" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) discipline.save() key = KEY session = session_cls(key=key) @@ -1171,6 +1670,24 @@ class TestDeleteDeveloper(TestCase): name_cls = System.delegate.entities['name'] email_cls = System.delegate.entities['email'] developer_cls = System.delegate.entities['developer'] + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] + asset_cls = System.delegate.entities['asset'] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "computer science" + dis_id = "cse" + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) + discipline.save() dev_name = name_cls(name="Prof. Dharmaraj") dev_name.save() @@ -1180,7 +1697,8 @@ class TestDeleteDeveloper(TestCase): key = KEY session = session_cls(key=key) - developer = developer_cls(name=dev_name, email=email_id) + developer = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) developer.save() email = System.do("delete_developer", email=email_id, session=session) @@ -1190,10 +1708,10 @@ class TestDeleteDeveloper(TestCase): #+END_SRC -* Test DeleteHostingInfo -#+NAME: test_delete_hostinginfo +* Test DeleteHosting_Info +#+NAME: test_delete_hosting_info #+BEGIN_SRC python -class TestDeleteHostingInfo(TestCase): +class TestDeleteHosting_Info(TestCase): TESTING = True @@ -1208,32 +1726,32 @@ class TestDeleteHostingInfo(TestCase): db.session.remove() db.drop_all() - def test_delete_hostinginfo(self): + def test_delete_hosting_info(self): - print "test_delete_hostinginfo_in_system_persistence" + print "test_delete_hosting_info_in_system_persistence" session_cls = System.delegate.entities['session'] - hostinginfo_cls = System.delegate.entities['hostinginfo'] + hosting_info_cls = System.delegate.entities['hosting_info'] hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" key = KEY session = session_cls(key=key) - hostinginfo = hostinginfo_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + hosting_info = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) - hostinginfo.save() - hostinginfo = System.do("delete_hostinginfo", hosted_url = hosted_url, + hosting_info.save() + hosting_info = System.do("delete_hosting_info", hosted_url = hosted_url, session=session) - self.assertEqual(hostinginfo, hosted_url) + self.assertEqual(hosting_info, hosted_url) #+END_SRC -* Test DeleteIntegrationStatus -#+NAME: test_delete_integrationstatus +* Test DeleteIntegration_Status +#+NAME: test_delete_integration_status #+BEGIN_SRC python -class TestDeleteIntegrationStatus(TestCase): +class TestDeleteIntegration_Status(TestCase): TESTING = True def create_app(self): @@ -1247,22 +1765,22 @@ class TestDeleteIntegrationStatus(TestCase): db.session.remove() db.drop_all() - def test_delete_integrationstatus(self): + def test_delete_integration_status(self): - print "test_delete_integrationstatus_in_system_persistence" + print "test_delete_integration_status_in_system_persistence" session_cls = System.delegate.entities['session'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] + integration_status_cls = System.delegate.entities['integration_status'] integration_level= 4 key = KEY session = session_cls(key=key) - integrationstatus = integrationstatus_cls(integration_level=integration_level) + integration_status = integration_status_cls(integration_level=integration_level) - integrationstatus.save() - integrationstatus = System.do("delete_integrationstatus", integration_level = integration_level, + integration_status.save() + integration_status = System.do("delete_integration_status", integration_level = integration_level, session=session) - self.assertEqual(integrationstatus, integration_level) + self.assertEqual(integration_status, integration_level) #+END_SRC @@ -1290,48 +1808,49 @@ class TestGetLab(TestCase): print "test_get_lab_in_system_persistence" lab_cls = System.delegate.entities['lab'] institute_cls = System.delegate.entities['institute'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] + integration_status_cls = System.delegate.entities['integration_status'] discipline_cls = System.delegate.entities['discipline'] asset_cls = System.delegate.entities['asset'] name_cls = System.delegate.entities['name'] email_cls = System.delegate.entities['email'] developer_cls = System.delegate.entities['developer'] - hostinginfo_cls = System.delegate.entities['hostinginfo'] + hosting_info_cls = System.delegate.entities['hosting_info'] lab_name1="Computer Programming" lab_id1="CSE01" overview = "overview" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = institute_cls(inst_name=inst_name, inst_id=inst_id) + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() integration_level = 4 - integrationstatus = integrationstatus_cls(integration_level=integration_level) - integrationstatus.save() + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() - dis_name = "IIT Kanpur" - dis_id = "IITK" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + dis_name = "computer science" + dis_id = "cse" + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = asset_cls(asset_type=asset_type, path=path) - asset.save() - dev_name = name_cls(name="Mohit Tahiliani") dev_name.save() email_id = email_cls(email="mohit.tahiliani@gmail.com") email_id.save() - dev = developer_cls(name=dev_name, email=email_id) + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = hostinginfo_cls(hosting_status=hosting_status, + host = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) host.save() @@ -1339,7 +1858,7 @@ class TestGetLab(TestCase): lab = lab_cls(lab_id=lab_id1, lab_name=lab_name1, institute=inst, discipline=discipline, assets=[asset], overview=overview, experiments=[], developers=[dev], - hostinginfo=host, integrationstatus=integrationstatus) + hosting_info=[host], integration_status=integration_status) lab.save() @@ -1375,53 +1894,54 @@ class TestGetLabByInstitute(TestCase): lab_cls = System.delegate.entities['lab'] institute_cls = System.delegate.entities['institute'] discipline_cls = System.delegate.entities['discipline'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] + integration_status_cls = System.delegate.entities['integration_status'] asset_cls = System.delegate.entities['asset'] name_cls = System.delegate.entities['name'] email_cls = System.delegate.entities['email'] developer_cls = System.delegate.entities['developer'] - hostinginfo_cls = System.delegate.entities['hostinginfo'] + hosting_info_cls = System.delegate.entities['hosting_info'] lab_name1="Computer Programming" lab_id1="CSE01" overview = "overview" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = institute_cls(inst_name=inst_name, inst_id=inst_id) + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() integration_level = 4 - integrationstatus = integrationstatus_cls(integration_level=integration_level) - integrationstatus.save() + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() dis_name = "Computer Science" dis_id = "CS" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = asset_cls(asset_type=asset_type, path=path) - asset.save() - dev_name = name_cls(name="Mohit Tahiliani") dev_name.save() email_id = email_cls(email="mohit.tahiliani@gmail.com") email_id.save() - dev = developer_cls(name=dev_name, email=email_id) + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = hostinginfo_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) host.save() lab = lab_cls(lab_id=lab_id1, lab_name=lab_name1, institute=inst, discipline=discipline, assets=[asset], - overview=overview, experiments=[], integrationstatus=integrationstatus, - hostinginfo=host, developers=[dev]) + overview=overview, experiments=[], integration_status=integration_status, + hosting_info=[host], developers=[dev]) lab.save() @@ -1457,54 +1977,55 @@ class TestGetLabByDiscipline(TestCase): lab_cls = System.delegate.entities['lab'] institute_cls = System.delegate.entities['institute'] discipline_cls = System.delegate.entities['discipline'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] + integration_status_cls = System.delegate.entities['integration_status'] asset_cls = System.delegate.entities['asset'] name_cls = System.delegate.entities['name'] email_cls = System.delegate.entities['email'] developer_cls = System.delegate.entities['developer'] - hostinginfo_cls = System.delegate.entities['hostinginfo'] + hosting_info_cls = System.delegate.entities['hosting_info'] lab_name1="Computer Programming" lab_id1="CSE01" overview = "overview" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = institute_cls(inst_name=inst_name, inst_id=inst_id) + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() integration_level = 4 - integrationstatus = integrationstatus_cls(integration_level=integration_level) - integrationstatus.save() + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() dis_name = "Computer Science" - dis_id = "CS" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + dis_id = "cse" + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = asset_cls(asset_type=asset_type, path=path) - asset.save() - dev_name = name_cls(name="Mohit Tahiliani") dev_name.save() email_id = email_cls(email="mohit.tahiliani@gmail.com") email_id.save() - dev = developer_cls(name=dev_name, email=email_id) + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = hostinginfo_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) host.save() lab = lab_cls(lab_id=lab_id1, lab_name=lab_name1, institute=inst, discipline=discipline, - hostinginfo=host, assets=[asset], + hosting_info=[host], assets=[asset], overview=overview, experiments=[], developers=[dev], - integrationstatus=integrationstatus) + integration_status=integration_status) lab.save() @@ -1541,54 +2062,55 @@ class TestGetLabByLabName(TestCase): lab_cls = System.delegate.entities['lab'] institute_cls = System.delegate.entities['institute'] discipline_cls = System.delegate.entities['discipline'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] + integration_status_cls = System.delegate.entities['integration_status'] asset_cls = System.delegate.entities['asset'] name_cls = System.delegate.entities['name'] email_cls = System.delegate.entities['email'] developer_cls = System.delegate.entities['developer'] - hostinginfo_cls = System.delegate.entities['hostinginfo'] + hosting_info_cls = System.delegate.entities['hosting_info'] lab_name1="Computer Programming" lab_id1="CSE01" overview = "overview" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = institute_cls(inst_name=inst_name, inst_id=inst_id) + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() integration_level = 4 - integrationstatus = integrationstatus_cls(integration_level=integration_level) - integrationstatus.save() + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() - dis_name = "IIT Kanpur" - dis_id = "IITK" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + dis_name = "computer science" + dis_id = "cse" + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = asset_cls(asset_type=asset_type, path=path) - asset.save() - dev_name = name_cls(name="Mohit Tahiliani") dev_name.save() email_id = email_cls(email="mohit.tahiliani@gmail.com") email_id.save() - dev = developer_cls(name=dev_name, email=email_id) + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) dev.save() hosting_status = "hosted" hosted_url = "http://cse14-iiith.vlabs.ac.in" hosted_on = "cloud" - host = hostinginfo_cls(hosting_status=hosting_status, + host = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) host.save() lab = lab_cls(lab_id=lab_id1, lab_name=lab_name1, - integrationstatus=integrationstatus, + integration_status=integration_status, institute=inst, discipline=discipline, - hostinginfo=host, assets=[asset], + hosting_info=[host], assets=[asset], overview=overview, experiments=[], developers=[dev]) @@ -1626,35 +2148,52 @@ class TestGetLabByAsset(TestCase): institute_cls = System.delegate.entities['institute'] discipline_cls = System.delegate.entities['discipline'] asset_cls = System.delegate.entities['asset'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] + integration_status_cls = System.delegate.entities['integration_status'] lab_name1="Computer Programming" lab_id1="CSE01" overview = "overview" + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + inst_name = "IIT Kanpur" inst_id = "IITK" - inst = institute_cls(inst_name=inst_name, inst_id=inst_id) + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() integration_level = 4 - integrationstatus = integrationstatus_cls(integration_level=integration_level) - integrationstatus.save() + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() dis_name = "Computer Science" dis_id = "CS" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = asset_cls(asset_type=asset_type, path=path) - asset.save() + dev_name = name_cls(name="Mohit Tahiliani") + dev_name.save() + email_id = email_cls(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = hosting_info_cls(hosting_status=hosting_status, + hosted_url=hosted_url, hosted_on=hosted_on) + host.save() lab = lab_cls(lab_id=lab_id1, lab_name=lab_name1, - institute=inst, discipline=discipline, assets=[asset], - overview=overview, experiments=[], - integrationstatus=integrationstatus) + integration_status=integration_status, + institute=inst, discipline=discipline, + hosting_info=[host], assets=[asset], + overview=overview, experiments=[], developers=[dev]) + lab.save() @@ -1665,10 +2204,10 @@ class TestGetLabByAsset(TestCase): #+END_SRC -* Test GetIntegrationStatusByIL -#+NAME: test_get_integrationstatus_by_IL +* Test GetIntegration_StatusByIL +#+NAME: test_get_integration_status_by_IL #+BEGIN_SRC python -class TestGetIntegrationStatusByIL(TestCase): +class TestGetIntegration_StatusByIL(TestCase): TESTING = True def create_app(self): @@ -1682,22 +2221,22 @@ class TestGetIntegrationStatusByIL(TestCase): db.session.remove() db.drop_all() - def test_get_integrationstatus_by_IL(self): - print "test_get_integrationstatus_by_IL_in_system_persistence" + def test_get_integration_status_by_IL(self): + print "test_get_integration_status_by_IL_in_system_persistence" session_cls = System.delegate.entities['session'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] + integration_status_cls = System.delegate.entities['integration_status'] integration_level = 4 - integrationstatus = integrationstatus_cls(integration_level=integration_level) + integration_status = integration_status_cls(integration_level=integration_level) key = KEY session = session_cls(key=key) - integrationstatus = System.do("add_integrationstatus", integrationstatus=integrationstatus, \ + integration_status = System.do("add_integration_status", integration_status=integration_status, \ session=session) - integrationstatus = System.do("get_integrationstatus_by_IL", + integration_status = System.do("get_integration_status_by_IL", integration_level=integration_level) - self.assertEqual(integrationstatus.get("integration_level"), integration_level) + self.assertEqual(integration_status.get("integration_level"), integration_level) #+END_SRC @@ -1761,13 +2300,59 @@ class TestGetExp(TestCase): print "test_get_exp_in_system_persistence" exp_cls = System.delegate.entities['experiment'] - + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] + name_cls = System.delegate.entities['name'] + email_cls = System.delegate.entities['email'] + developer_cls = System.delegate.entities['developer'] + hosting_info_cls = System.delegate.entities['hosting_info'] experiment_cls = System.delegate.entities['experiment'] + integration_status_cls = System.delegate.entities['integration_status'] + asset_cls = System.delegate.entities['asset'] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "computer science" + dis_id = "cse" + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) + discipline.save() + + integration_level = 4 + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() + + dev_name = name_cls(name="Mohit Tahiliani") + dev_name.save() + email_id = email_cls(email="mohit.tahiliani@gmail.com") + email_id.save() + dev = developer_cls(name=dev_name, email=email_id, + institute=inst, discipline=discipline) + dev.save() + + hosting_status = "hosted" + hosted_url = "http://cse14-iiith.vlabs.ac.in" + hosted_on = "cloud" + host = hosting_info_cls(hosting_status=hosting_status, hosted_url=hosted_url, hosted_on=hosted_on) + host.save() + exp_name = "arrays" exp_id = "cse02" overview = "overview" experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) + overview=overview, sections=[], + institute=inst, discipline=discipline, + integration_status=integration_status, + assets=[asset], + developers=[dev], hosting_info=[host]) + experiment.save() experiment1 = System.do("get_experiment", exp_id=exp_id) @@ -1838,10 +2423,16 @@ class TestGetInstitute(TestCase): print "test_get_institute_in_system_persistence" session_cls = System.delegate.entities['session'] institute_cls = System.delegate.entities['institute'] + asset_cls = System.delegate.entities['asset'] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() inst_name1= "IIT Kanpur" inst_id1= "IITK" - institute = institute_cls(inst_id=inst_id1, inst_name=inst_name1) + institute = institute_cls(inst_id=inst_id1, inst_name=inst_name1, assets=[asset]) institute.save() institute1 = System.do("get_institute", inst_id=inst_id1) @@ -1873,10 +2464,16 @@ class TestGetDiscipline(TestCase): print "test_get_discipline_in_system_persistence" discipline_cls = System.delegate.entities['discipline'] + asset_cls = System.delegate.entities['asset'] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() dis_name = "arrays" dis_id = "cse02" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) discipline.save() exp1 = System.do("get_discipline", dis_id=dis_id) @@ -1912,6 +2509,24 @@ class TestGetDeveloper(TestCase): name_cls = System.delegate.entities['name'] email_cls = System.delegate.entities['email'] dev_cls = System.delegate.entities['developer'] + institute_cls = System.delegate.entities['institute'] + discipline_cls = System.delegate.entities['discipline'] + asset_cls = System.delegate.entities['asset'] + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() + + inst_name = "IIT Kanpur" + inst_id = "IITK" + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) + inst.save() + + dis_name = "IIT Kanpur" + dis_id = "IITK" + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) + discipline.save() dev_name1 = name_cls(name="Prof. Dharmaraj") dev_name1.save() @@ -1919,7 +2534,8 @@ class TestGetDeveloper(TestCase): email_id1.save() key = KEY session = session_cls(key=key) - developer = dev_cls(name=dev_name1, email=email_id1) + developer = dev_cls(name=dev_name1, email=email_id1, + institute=inst, discipline=discipline) developer.save() developer1 = System.do("get_developer", email=email_id1) @@ -1929,10 +2545,10 @@ class TestGetDeveloper(TestCase): #+END_SRC -* Test GetHostingInfo -#+NAME: test_get_hostinginfo +* Test GetHosting_Info +#+NAME: test_get_hosting_info #+BEGIN_SRC python -class TestGetHostingInfo(TestCase): +class TestGetHosting_Info(TestCase): TESTING = True @@ -1947,31 +2563,31 @@ class TestGetHostingInfo(TestCase): db.session.remove() db.drop_all() - def test_get_hostinginfo(self): + def test_get_hosting_info(self): - print "test_get_hostinginfo_in_system_persistence" + print "test_get_hosting_info_in_system_persistence" session_cls = System.delegate.entities['session'] - hostinginfo_cls = System.delegate.entities['hostinginfo'] + hosting_info_cls = System.delegate.entities['hosting_info'] hosting_status1 = "hosted" hosted_url1 = "http://cse14-iiith.vlabs.ac.in" hosted_on1 = "cloud" - hostinginfo = hostinginfo_cls(hosting_status=hosting_status1, hosted_url=hosted_url1, hosted_on=hosted_on1) - hostinginfo.save() + hosting_info = hosting_info_cls(hosting_status=hosting_status1, hosted_url=hosted_url1, hosted_on=hosted_on1) + hosting_info.save() - hostinginfo1 = System.do("get_hostinginfo", hosted_url=hosted_url1) + hosting_info1 = System.do("get_hosting_info", hosted_url=hosted_url1) - self.assertEqual(hostinginfo1.get("hosting_status"), hosting_status1) - self.assertEqual(hostinginfo1.get("hosted_url"), hosted_url1) - self.assertEqual(hostinginfo1.get("hosted_on"), hosted_on1) + self.assertEqual(hosting_info1.get("hosting_status"), hosting_status1) + self.assertEqual(hosting_info1.get("hosted_url"), hosted_url1) + self.assertEqual(hosting_info1.get("hosted_on"), hosted_on1) #+END_SRC -* Test GetIntegrationStatus -#+NAME: test_get_integrationstatus +* Test GetIntegration_Status +#+NAME: test_get_integration_status #+BEGIN_SRC python -class TestGetIntegrationStatus(TestCase): +class TestGetIntegration_Status(TestCase): TESTING = True @@ -1986,19 +2602,19 @@ class TestGetIntegrationStatus(TestCase): db.session.remove() db.drop_all() - def test_get_integrationstatus(self): + def test_get_integration_status(self): - print "test_get_integrationstatus_in_system_persistence" + print "test_get_integration_status_in_system_persistence" session_cls = System.delegate.entities['session'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] + integration_status_cls = System.delegate.entities['integration_status'] integration_level1= 4 - integrationstatus = integrationstatus_cls(integration_level=integration_level1) - integrationstatus.save() + integration_status = integration_status_cls(integration_level=integration_level1) + integration_status.save() - integrationstatus1 = System.do("get_integrationstatus", integration_level=integration_level1) + integration_status1 = System.do("get_integration_status", integration_level=integration_level1) - self.assertEqual(integrationstatus1.get("integration_level"), integration_level1) + self.assertEqual(integration_status1.get("integration_level"), integration_level1) #+END_SRC @@ -2180,33 +2796,34 @@ class TestAddAssetsToLab(TestCase): discipline_cls = System.delegate.entities['discipline'] asset_cls = System.delegate.entities['asset'] experiment_cls = System.delegate.entities['experiment'] - integrationstatus_cls = System.delegate.entities['integrationstatus'] - - exp_name = "arrays" - exp_id = "cse02" - overview = "overview" - experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, - overview=overview, sections=[]) - experiment.save() - + integration_status_cls = System.delegate.entities['integration_status'] + integration_level = 4 - integrationstatus = integrationstatus_cls(integration_level=integration_level) - integrationstatus.save() + integration_status = integration_status_cls(integration_level=integration_level) + integration_status.save() + + asset_type = "Image" + path = "vlabs.ac.in/images/static/logo.png" + asset = asset_cls(asset_type=asset_type, path=path) + asset.save() inst_name = "IIT Kanpur" inst_id = "IITK" - inst = institute_cls(inst_name=inst_name, inst_id=inst_id) + inst = institute_cls(inst_name=inst_name, inst_id=inst_id, assets=[asset]) inst.save() dis_name = "IIT Kanpur" dis_id = "IITK" - discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id) + discipline = discipline_cls(dis_name=dis_name, dis_id=dis_id, assets=[asset]) discipline.save() - asset_type = "Image" - path = "vlabs.ac.in/images/static/logo.png" - asset = asset_cls(asset_type=asset_type, path=path) - asset.save() + exp_name = "arrays" + exp_id = "cse02" + overview = "overview" + experiment = experiment_cls(exp_name=exp_name, exp_id=exp_id, + overview=overview, sections=[], + institute=inst, discipline=discipline) + experiment.save() lab_name1="Computer Programming" lab_id1="CSE01" @@ -2216,7 +2833,7 @@ class TestAddAssetsToLab(TestCase): lab = lab_cls(lab_id=lab_id1, lab_name=lab_name1, institute=inst, discipline=discipline, assets=[asset], - overview=overview, integrationstatus=integrationstatus, + overview=overview, integration_status=integration_status, experiments=[experiment]) lab.save() @@ -2238,6 +2855,69 @@ class TestAddAssetsToLab(TestCase): #+END_SRC +* Test GetSection +#+NAME: test_get_section +#+BEGIN_SRC python +class TestGetName(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_section(self): + + print "test_get_section_in_system_persistence" + session_cls = System.delegate.entities['session'] + section_cls = System.delegate.entities['section'] + + name1="Theory" + key = KEY + session = session_cls(key=key) + name = section_cls(name=name1) + + name.save() + + name2 = System.do("get_section", name=name, session=session) + + self.assertEqual(name2.get("name"), name1) +#+END_SRC + + +* Test UpdateName +#+NAME: test_update_name +#+BEGIN_SRC python +class TestUpdateName(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_update_name(self): + + print "test_update_name_in_system_persistence" + session_cls = System.delegate.entities['session'] + name_cls = System.delegate.entities['name'] + + +#+END_SRC + + * Infra :boilerplate: ** Tests *** Imports @@ -2271,6 +2951,7 @@ if __name__ == '__main__': * Tangling :boilerplate: #+BEGIN_SRC python :tangle test_persistence_system.py :eval no :noweb yes + <> <> <> @@ -2278,7 +2959,7 @@ if __name__ == '__main__': <> <> <> -<> +<> <> <> <> @@ -2286,20 +2967,20 @@ if __name__ == '__main__': <> <> <> -<> +<> <> <> <> <> <> <> -<> -<> +<> +<> <> <> <> <> -<> +<> <> <> <> @@ -2308,8 +2989,8 @@ if __name__ == '__main__': <> <> <> -<> -<> +<> +<> <> #<> <> @@ -2318,7 +2999,9 @@ if __name__ == '__main__': <> <> <> -<> +<> +<> +<> <> #+end_src diff --git a/src/runtime/system/system.org b/src/runtime/system/system.org index 833c6bd..a3ff880 100755 --- a/src/runtime/system/system.org +++ b/src/runtime/system/system.org @@ -373,11 +373,11 @@ class AddDiscipline(): -** =AddHostingInfo= -#+NAME: class_add_hostinginfo +** =AddHosting_Info= +#+NAME: class_add_hosting_info #+begin_src python -class AddHostingInfo(): - arg_types = {"hostinginfo": is_hostinginfo, "session": is_session} +class AddHosting_Info(): + arg_types = {"hosting_info": is_hosting_info, "session": is_session} arity_and_type_checks_needed = True @staticmethod @@ -388,16 +388,16 @@ class AddHostingInfo(): @staticmethod def state_check(args): - hostinginfo = args["hostinginfo"] - if System.delegate.hostinginfo_exists(hostinginfo): - raise StateError("hostinginfo %s already exists in System" - % hostinginfo.to_client()) + hosting_info = args["hosting_info"] + if System.delegate.hosting_info_exists(hosting_info): + raise StateError("hosting_info %s already exists in System" + % hosting_info.to_client()) @staticmethod def action(args): - hostinginfo = args["hostinginfo"] - hostinginfo = System.delegate.add_hostinginfo(hostinginfo) - return hostinginfo + hosting_info = args["hosting_info"] + hosting_info = System.delegate.add_hosting_info(hosting_info) + return hosting_info #+end_src @@ -492,11 +492,11 @@ class AddDeveloper(): #+end_src -** =AddIntegrationStatus= -#+NAME: class_add_integrationstatus +** =AddIntegration_Status= +#+NAME: class_add_integration_status #+begin_src python -class AddIntegrationStatus(): - arg_types = {"integrationstatus": is_integrationstatus, "session": is_session} +class AddIntegration_Status(): + arg_types = {"integration_status": is_integration_status, "session": is_session} arity_and_type_checks_needed = True @staticmethod @@ -507,16 +507,16 @@ class AddIntegrationStatus(): @staticmethod def state_check(args): - integrationstatus = args["integrationstatus"] - if System.delegate.integrationstatus_exists(integrationstatus): - raise StateError("integrationstatus %s already exists in System" - % integrationstatus.to_client()) + integration_status = args["integration_status"] + if System.delegate.integration_status_exists(integration_status): + raise StateError("integration_status %s already exists in System" + % integration_status.to_client()) @staticmethod def action(args): - integrationstatus = args["integrationstatus"] - integrationstatus = System.delegate.add_integrationstatus(integrationstatus) - return integrationstatus + integration_status = args["integration_status"] + integration_status = System.delegate.add_integration_status(integration_status) + return integration_status #+end_src @@ -528,7 +528,15 @@ class AddIntegrationStatus(): #+begin_src python class UpdateLab(): arg_types = {"lab": is_lab, "lab_name": is_str, - "overview" : is_str, "session": is_session} + "overview" : is_str, + "session": is_session, + "institute" : is_institute, + "discipline" : is_discipline, + "hosting_info": are_hosting_info, + "developers": are_developers, + "assets": are_assets, "experiments":are_experiments, + "integration_status" : is_integration_status} + arity_and_type_checks_needed = True @staticmethod @@ -549,7 +557,17 @@ class UpdateLab(): lab = args["lab"] lab_name = args["lab_name"] overview = args["overview"] - lab = System.delegate.update_lab(lab, lab_name, overview) + institute = args["institute"] + discipline = args["discipline"] + integration_status = args["integration_status"] + hosting_info = args["hosting_info"] + developers = args["developers"] + assets = args["assets"] + experiments = args["experiments"] + lab = System.delegate.update_lab(lab, lab_name, overview, institute, + discipline, integration_status, + hosting_info, developers, assets, + experiments) return lab #+end_src @@ -563,7 +581,14 @@ class UpdateExperiment(): arg_types = {"exp_name": is_str_or_none, "experiment": is_experiment, "overview" : is_str, - "session": is_session} + "session": is_session, + "institute": is_institute, + "discipline": is_discipline, + "integration_status": is_integration_status, + "hosting_info": are_hosting_info, + "developers": are_developers, + "assets": are_assets, + "sections": are_sections} arity_and_type_checks_needed = True @staticmethod @@ -584,7 +609,18 @@ class UpdateExperiment(): experiment = args["experiment"] exp_name=args["exp_name"] overview = args["overview"] - exp = System.delegate.update_experiment(experiment, exp_name, overview) + institute = args["institute"] + discipline = args["discipline"] + integration_status = args["integration_status"] + hosting_info = args["hosting_info"] + developers = args["developers"] + assets = args["assets"] + sections = args["sections"] + exp = System.delegate.update_experiment(experiment, exp_name, overview, + institute, discipline, + integration_status, + hosting_info, developers, + assets, sections) return exp #+end_src @@ -632,7 +668,7 @@ class UpdateSection(): #+begin_src python class UpdateDiscipline(): arg_types = {"discipline": is_discipline, "dis_name": is_str_or_none, - "session": is_session} + "session": is_session, "assets": are_assets} arity_and_type_checks_needed = True @staticmethod @@ -652,7 +688,8 @@ class UpdateDiscipline(): def action(args): discipline = args["discipline"] dis_name=args["dis_name"] - dis = System.delegate.update_discipline(discipline, dis_name) + assets = args["assets"] + dis = System.delegate.update_discipline(discipline, dis_name, assets) return dis #+end_src @@ -664,7 +701,7 @@ class UpdateDiscipline(): #+begin_src python class UpdateInstitute(): arg_types = {"institute": is_institute, "inst_name": is_str_or_none, - "session": is_session} + "session": is_session, "assets": are_assets} arity_and_type_checks_needed = True @staticmethod @@ -685,7 +722,8 @@ class UpdateInstitute(): def action(args): inst_name = args["inst_name"] institute = args["institute"] - institute = System.delegate.update_institute(institute, inst_name) + assets = args["assets"] + institute = System.delegate.update_institute(institute, inst_name, assets) return institute #+end_src @@ -696,7 +734,7 @@ class UpdateInstitute(): #+NAME: class_update_name #+begin_src python class UpdateName(): - arg_types = {"name": is_name, "session": is_session} + arg_types = {"name": is_name, "n_name": is_str, "session": is_session} arity_and_type_checks_needed = True @staticmethod @@ -715,12 +753,12 @@ class UpdateName(): @staticmethod def action(args): name = args["name"] - if not "name" in args: - name=name.get("name") + if not "n_name" in args: + n_name=name.get("name") else: - name=args["name"] + n_name=args["n_name"] - section = System.delegate.update_name(name, name) + name = System.delegate.update_name(name, n_name) return name #+end_src @@ -767,7 +805,8 @@ class UpdateEmail(): #+begin_src python class UpdateDeveloper(): arg_types = {"developer": is_developer, "name": is_name, - "session": is_session} + "session": is_session, "institute": is_institute, + "discipline" : is_discipline} arity_and_type_checks_needed = True @staticmethod @@ -791,17 +830,19 @@ class UpdateDeveloper(): else: name=args["name"] - section = System.delegate.update_developer(developer, name) + institute = args["institute"] + discipline = args["discipline"] + developer = System.delegate.update_developer(developer, name, institute, discipline) return developer #+end_src -** =UpdateHostingInfo= -#+NAME: class_update_hostinginfo +** =UpdateHosting_Info= +#+NAME: class_update_hosting_info #+begin_src python -class UpdateHostingInfo(): - arg_types = {"hostinginfo": is_hostinginfo, "hosting_status": is_str_or_none, "hosted_on": is_str_or_none, "session": is_session} +class UpdateHosting_Info(): + arg_types = {"hosting_info": is_hosting_info, "hosting_status": is_str_or_none, "hosted_on": is_str_or_none, "session": is_session} arity_and_type_checks_needed = True @staticmethod @@ -819,9 +860,9 @@ class UpdateHostingInfo(): def action(args): hosting_status = args["hosting_status"] hosted_on = args["hosted_on"] - hostinginfo = args["hostinginfo"] - hostinginfo = System.delegate.update_hostinginfo(hostinginfo, hosting_status, hosted_on) - return hostinginfo + hosting_info = args["hosting_info"] + hosting_info = System.delegate.update_hosting_info(hosting_info, hosting_status, hosted_on) + return hosting_info #+end_src @@ -983,7 +1024,7 @@ class DeleteSection(): #+NAME: class_delete_name #+begin_src python class DeleteName(): - arg_types = {"name": is_name, "session": is_session} + arg_types = {"n_id": is_int, "session": is_session} arity_and_type_checks_needed = True @staticmethod @@ -994,16 +1035,13 @@ class DeleteName(): @staticmethod def state_check(args): - name = args['name'] - if not System.delegate.name_exists(name): - raise StateError("name %s does not exists in System" - % name.to_client()) + pass @staticmethod def action(args): - name = args["name"] - name1 = System.delegate.delete_name(name) - return name1 + n_id = args["n_id"] + n_id = System.delegate.delete_name(n_id) + return n_id #+end_src @@ -1066,10 +1104,10 @@ class DeleteDeveloper(): -** =DeleteHostingInfo= -#+NAME: class_delete_hostinginfo +** =DeleteHosting_Info= +#+NAME: class_delete_hosting_info #+begin_src python -class DeleteHostingInfo(): +class DeleteHosting_Info(): arg_types = {"hosted_url": is_url, "session": is_session} arity_and_type_checks_needed = True @@ -1082,25 +1120,25 @@ class DeleteHostingInfo(): @staticmethod def state_check(args): hosted_url = args['hosted_url'] - hostinginfo = System.delegate.get_hostinginfo(hosted_url=hosted_url) - if not System.delegate.hostinginfo_exists(hostinginfo): - raise StateError("hostinginfo %s does not exists in System" - % hostinginfo.to_client()) + hosting_info = System.delegate.get_hosting_info(hosted_url=hosted_url) + if not System.delegate.hosting_info_exists(hosting_info): + raise StateError("hosting_info %s does not exists in System" + % hosting_info.to_client()) @staticmethod def action(args): hosted_url = args["hosted_url"] - hosted_url = System.delegate.delete_hostinginfo(hosted_url) + hosted_url = System.delegate.delete_hosting_info(hosted_url) return hosted_url #+end_src -** =DeleteIntegrationStatus= -#+NAME: class_delete_integrationstatus +** =DeleteIntegration_Status= +#+NAME: class_delete_integration_status #+begin_src python -class DeleteIntegrationStatus(): +class DeleteIntegration_Status(): arg_types = {"integration_level": is_int, "session": is_session} arity_and_type_checks_needed = True @@ -1113,15 +1151,15 @@ class DeleteIntegrationStatus(): @staticmethod def state_check(args): integration_level = args['integration_level'] - integrationstatus = System.delegate.get_integrationstatus(integration_level=integration_level) - if not System.delegate.integrationstatus_exists(integrationstatus): - raise StateError("integrationstatus %s does not exists in System" - % integrationstatus.to_client()) + integration_status = System.delegate.get_integration_status(integration_level=integration_level) + if not System.delegate.integration_status_exists(integration_status): + raise StateError("integration_status %s does not exists in System" + % integration_status.to_client()) @staticmethod def action(args): integration_level = args["integration_level"] - integration_level = System.delegate.delete_integrationstatus(integration_level) + integration_level = System.delegate.delete_integration_status(integration_level) return integration_level #+end_src @@ -1199,11 +1237,7 @@ class GetInstitute(): @staticmethod def state_check(args): - inst_id = args['inst_id'] - institute = System.delegate.get_institute(inst_id=inst_id) - if not System.delegate.institute_exists(institute): - raise StateError("institute %s does not exists in System" - % institute.to_client()) + pass @staticmethod def action(args): @@ -1279,12 +1313,8 @@ class GetDiscipline(): @staticmethod def state_check(args): - dis_id = args['dis_id'] - discipline = System.delegate.get_discipline(dis_id=dis_id) - if not System.delegate.discipline_exists(discipline): - raise StateError("discipline %s does not exists in System" - % discipline.to_client()) - + pass + @staticmethod def action(args): dis_id = args["dis_id"] @@ -1296,10 +1326,10 @@ class GetDiscipline(): -** =GetHostingInfo= -#+NAME: class_get_hostinginfo +** =GetHosting_Info= +#+NAME: class_get_hosting_info #+begin_src python -class GetHostingInfo(): +class GetHosting_Info(): arg_types = {"hosted_url": is_url} arity_and_type_checks_needed = True @@ -1309,17 +1339,13 @@ class GetHostingInfo(): @staticmethod def state_check(args): - hosted_url = args['hosted_url'] - hostinginfo = System.delegate.get_hostinginfo(hosted_url=hosted_url) - if not System.delegate.hostinginfo_exists(hostinginfo): - raise StateError("hostinginfo %s does not exists in System" - % hostinginfo.to_client()) + pass @staticmethod def action(args): hosted_url = args["hosted_url"] - hostinginfo = System.delegate.get_hostinginfo(hosted_url=hosted_url) - return hostinginfo + hosting_info = System.delegate.get_hosting_info(hosted_url=hosted_url) + return hosting_info #+end_src @@ -1396,10 +1422,10 @@ class GetLabsByDiscipline(): #+end_src -** =GetIntegrationStatusByIL= -#+NAME: class_get_integrationstatus_by_IL +** =GetIntegration_StatusByIL= +#+NAME: class_get_integration_status_by_IL #+begin_src python -class GetIntegrationStatusby_IL(): +class GetIntegration_Statusby_IL(): arg_types = {"integration_level": is_int} arity_and_type_checks_needed = True @@ -1414,7 +1440,7 @@ class GetIntegrationStatusby_IL(): @staticmethod def action(args): integration_level = args["integration_level"] - integration_level = System.delegate.get_integrationstatus\ + integration_level = System.delegate.get_integration_status\ (integration_level=integration_level) return integration_level @@ -1591,10 +1617,10 @@ class GetDeveloper(): -** =GetIntegrationStatus= -#+NAME: class_get_integrationstatus +** =GetIntegration_Status= +#+NAME: class_get_integration_status #+begin_src python -class GetIntegrationStatus(): +class GetIntegration_Status(): arg_types = {"integration_level": is_int} arity_and_type_checks_needed = True @@ -1609,8 +1635,8 @@ class GetIntegrationStatus(): @staticmethod def action(args): integration_level = args["integration_level"] - integrationstatus = System.delegate.get_integrationstatus(integration_level=integration_level) - return integrationstatus + integration_status = System.delegate.get_integration_status(integration_level=integration_level) + return integration_status #+end_src @@ -1720,13 +1746,10 @@ class GetAsset(): @staticmethod def auth_check(args): pass + @staticmethod def state_check(args): - path = args['path'] - asset = System.delegate.get_asset(path=path) - if not System.delegate.asset_exists(asset): - raise StateError("asset %s does not exists in System" - % asset.to_client()) + pass @staticmethod def action(args): @@ -1779,6 +1802,80 @@ class AddAssetsToLab(): +** =GetLabsByAsset= +#+NAME: class_get_labs_by_asset +#+begin_src python +class GetLabsByAsset(): + arg_types = {"asset": is_asset} + arity_and_type_checks_needed = True + + @staticmethod + def auth_check(args): + pass + + @staticmethod + def state_check(args): + pass + + @staticmethod + def action(args): + asset = args['asset'] + labs = System.delegate.get_labs(asset=asset) + return labs + +#+end_src + + +** =GetAssetByAssetType= +#+NAME: class_get_asset_by_asset_type +#+begin_src python +class GetAssetByAssetType(): + arg_types = {"asset_type": is_str} + arity_and_type_checks_needed = True + + @staticmethod + def auth_check(args): + pass + + @staticmethod + def state_check(args): + pass + + @staticmethod + def action(args): + asset_type = args['asset_type'] + asset = System.delegate.get_asset(asset_type=asset_type) + return asset + +#+end_src + + +** =GetSection= +#+NAME: class_get_section +#+begin_src python +class GetSection(): + arg_types = {"name": is_str} + arity_and_type_checks_needed = True + + @staticmethod + def auth_check(args): + pass + + @staticmethod + def state_check(args): + pass + + @staticmethod + def action(args): + name = args["name"] + section = System.delegate.get_section(name=name) + return section + +#+end_src + + + + ** Operations Table Each operation has a corresponding implementation defined as a class. @@ -1801,7 +1898,7 @@ ops_table = {'add_lab' : AddLab, 'get_institute' : GetInstitute, 'get_institute_by_institute_name' : GetInstituteByInstituteName, 'get_discipline_by_discipline_name' : GetDisciplineByDisciplineName, - 'get_integrationstatus_by_IL': GetIntegrationStatusby_IL, + 'get_integration_status_by_IL': GetIntegration_Statusby_IL, 'add_section' : AddSection, 'update_section' : UpdateSection, 'delete_section' : DeleteSection, @@ -1820,18 +1917,22 @@ ops_table = {'add_lab' : AddLab, 'get_name': GetName, 'get_email': GetEmail, 'get_developer': GetDeveloper, - 'add_hostinginfo' : AddHostingInfo, - 'get_hostinginfo': GetHostingInfo, - 'update_hostinginfo': UpdateHostingInfo, - 'delete_hostinginfo': DeleteHostingInfo, - 'add_integrationstatus' : AddIntegrationStatus, - 'get_integrationstatus': GetIntegrationStatus, - 'delete_integrationstatus': DeleteIntegrationStatus, + 'add_hosting_info' : AddHosting_Info, + 'get_hosting_info': GetHosting_Info, + 'update_hosting_info': UpdateHosting_Info, + 'delete_hosting_info': DeleteHosting_Info, + 'add_integration_status' : AddIntegration_Status, + 'get_integration_status': GetIntegration_Status, + 'delete_integration_status': DeleteIntegration_Status, 'add_asset':AddAsset, 'delete_asset': DeleteAsset, 'get_asset': GetAsset, 'update_asset': UpdateAsset, - 'add_assets_to_lab': AddAssetsToLab + 'add_assets_to_lab': AddAssetsToLab, + 'get_section': GetSection, + 'update_name': UpdateName, + 'get_labs_by_asset': GetLabsByAsset, + 'get_asset_by_asset_type': GetAssetByAssetType } #+END_SRC @@ -1850,7 +1951,8 @@ from runtime.objects.entities import is_str, is_lab, are_labs,\ is_date, is_session, is_section, is_int, is_experiment,\ are_experiments, are_sections, is_name, is_email, is_developer,\ is_institute, are_institutes, is_discipline, are_disciplines,\ - is_url, is_hostinginfo, is_integrationstatus, is_asset, are_assets + is_url, is_hosting_info, is_integration_status, is_asset, are_assets,\ + are_hosting_info, are_developers from runtime.utils.type_utils import is_str_or_none from runtime.config.system_config import KEY @@ -1929,14 +2031,14 @@ if __name__ == '__main__': <> <> <> -<> -<> -<> -<> -<> -<> -<> -<> +<> +<> +<> +<> +<> +<> +<> +<> <> <> <> @@ -1945,6 +2047,10 @@ if __name__ == '__main__': <> <> <> +<> +<> +<> +<> <> #+end_src