def clone(resource_type, sid, dirname="./"): output = "" if resource_type == "caseversion": query = str(sid) logging.info("Downloading CaseVersion " + query + " ...") result = downloadCaseversionById(query) output = orm.formatCaseversion(result) elif resource_type == "suite": query = str(sid) logging.info("Downloading Suite " + query + " ...") result = downloadSuiteById(query) sname = getSuiteName(sid) output = orm.formatSuite(result, sname) elif resource_type == "case": query = str(sid) logging.info("Downloading Case " + query + " ...") logging.warning("Only the CaseVersion for {v} was downloaded".format( v=productversion)) result = downloadCaseversionByCaseId(query) output = orm.formatCaseversion(result) filename = dirname + resource_type + "_" + str(sid) + ".txt" if not os.path.exists(os.path.dirname(filename)): os.makedirs(os.path.dirname(filename)) with open(filename, 'w') as file_: file_.write(output) logging.info(filename + " created") return filename
def clone(resource_type, sid, dirname="./"): output = "" if resource_type == "caseversion": query = str(sid) logging.info("Downloading CaseVersion " + query + " ...") result = downloadCaseversionById(query) output = orm.formatCaseversion(result) elif resource_type == "suite": query = str(sid) logging.info("Downloading Suite " + query + " ...") result = downloadSuiteById(query) output = orm.formatSuite(result, sid) elif resource_type == "case": query = str(sid) logging.info("Downloading Case " + query + " ...") logging.warning("Only the CaseVersion for {v} was downloaded".format(v=productversion)) result = downloadCaseversionByCaseId(query) output = orm.formatCaseversion(result) filename = dirname + resource_type + "_" + str(sid) + ".txt" if not os.path.exists(os.path.dirname(filename)): os.makedirs(os.path.dirname(filename)) with open(filename, 'w') as file_: file_.write(output) logging.info(filename + " created") return filename
def forcePushSuite(sid, newsuite, requestlib, credental): oldsuite = downloadSuiteById(sid) if len(oldsuite['objects']) != len(newsuite['objects']): raise Exception("You can't add or remove cases from a suite yet. Remote version has {0} cases, local version has {1} cases".format(len(oldsuite['objects']), len(newsuite['objects']))) # FIXME: potential ordering problem, text is sorted by id for (oldcaseversion, newcaseversion) in map(None, sorted(oldsuite['objects'], key=lambda x: x['id']), newsuite['objects']): rtype, rid = orm.parseURL(oldcaseversion['resource_uri']) #print(newcaseversion['name']) oldcaseversionCmp = copy.deepcopy(oldcaseversion) oldcaseversionCmp.pop('resource_uri', None) #FIXME: don't do this after resource_uri is parsed if(orm.formatCaseversion(oldcaseversionCmp) == orm.formatCaseversion(newcaseversion)): logging.info("No change for caseversion {0}, skipping".format(oldcaseversion['id'])) else: forcePushCaseversion(rid, newcaseversion, requestlib, credental)
def forcePushSuite(sid, newsuite, requestlib, credental): oldsuite = downloadSuiteById(sid) if len(oldsuite['objects']) != len(newsuite['objects']): raise Exception( "You can't add or remove cases from a suite yet. Remote version has {0} cases, local version has {1} cases" .format(len(oldsuite['objects']), len(newsuite['objects']))) # FIXME: potential ordering problem, text is sorted by id for (oldcaseversion, newcaseversion) in map( None, sorted(oldsuite['objects'], key=lambda x: x['id']), newsuite['objects']): rtype, rid = orm.parseURL(oldcaseversion['resource_uri']) ##print(newcaseversion['name']) oldcaseversionCmp = copy.deepcopy(oldcaseversion) oldcaseversionCmp.pop( 'resource_uri', None) #FIXME: don't do this after resource_uri is parsed if (orm.formatCaseversion(oldcaseversionCmp) == orm.formatCaseversion( newcaseversion)): logging.info("No change for caseversion {0}, skipping".format( oldcaseversion['id'])) else: forcePushCaseversion(rid, newcaseversion, requestlib, credental)
def test_formatCaseversion(self): caseversion_in = json.loads(self.json_in) self.assertEqual(orm.formatCaseversion(caseversion_in), self.txt)