def test_dumping_pipe_full(cls): """ Tests creating python instances > dumping JSON-LD > translate into N-TRIPLES :return: """ print " --- full test for generating components and dumping them in JSON-LD" jsons = [SubSystem.generate_py_instance(k, v) for k, v in tech_constrains.items()] jsonlds = [SubSystem.generate_jsonld(c) for c in jsons] print json.dumps(jsonlds, indent=4) print " --- Translating the component into ntriples via RDFtranslator" from scripts.remote.remote import post_curling url = 'http://rdf-translator.appspot.com/convert/json-ld/nt/content' post_curling(url, {'content': json.dumps(jsonlds)}, display=True)
def test_generate_json_ld_single(self): """ Tests SubSystem.generate_jsonld(obj) :return: """ obj = self.test_generate_py_object(self.kind, self.specs) print json.dumps(SubSystem.generate_jsonld(obj), indent=4)
def test_generate_json_ld_all_kinds(self): """ Tests SubSystem.generate_jsonld(obj) for all the subsytems kinds :return: """ for k, v in tech_constrains.items(): obj = self.test_generate_py_object(k, v) s = SubSystem.generate_jsonld(obj) print json.dumps(s, indent=4) print '-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-'
def test_generate_py_object(cls, kind, specs): """ Tests SubSystem.generate_py_instance(kind, specs) :param kind: :param specs: :return: """ obj = SubSystem.generate_py_instance(kind, specs) print obj BasicComponentCreation.test_created_object(obj) return obj
def generate_metaclasses(): """ NOTED FUNCTION - not implemented :return: """ classes = {} for k, v in tech_constrains.items(): # doc for type > https://docs.python.org/2/library/functions.html#type # usage http://stackoverflow.com/a/15247202/2536357 classname = "%s" % SubSystem.stringify(k) print classname classes[classname] = (type(classname, (SubSystem,), v)) return classes
def _upload_subsystems(n, url=_COMPONENTS_URL): """ upload to server the subsystems instances NOTE: dumped via a REST endpoint /database that has not been created yet endpoint: POST /database/cots/store {"pwd": ***, "data": {...} } :param url: the server endpoint :param n: number of iteration per family to be generated :return: """ try: int(n) except ValueError: raise ValueError('Argument must be an integer') for i in range(0, int(n)): # generate py instance components and translate in JSON-LD format instances = [SubSystem.generate_py_instance(k, v) for k, v in tech_constrains.items()] jsonlds = [SubSystem.generate_jsonld(c) for c in instances] for j in jsonlds: # upload to datastore (under construction) post_curling(url=url, params={'pwd': _TEMP_SECRET, 'data': json.dumps(j)}, display=True)
def test_generate_py_objects_from_constraints(cls): jsons = [SubSystem.generate_py_instance(k, v) for k, v in tech_constrains.items()] print jsons[1].__dict__ return None