def setUpClass(cls): global TEST_RUN_ID cls.doc = Document.create(DEFAULT_PROJ, "Testing", DOC_NAME, "Attribute_Test", ["testcase"], "testspecification") cls.testrun = TestRun.create(DEFAULT_PROJ, TEST_RUN_ID, "example", TEST_RUN_TITLE) TEST_RUN_ID = cls.testrun.test_run_id # arch is a custom field defined by global admins for test runs. # It is set here for a test on custom fields that requires at least two # valid values. If in the future, this custom field is removed, or the # number of valid values is lowered to 1, a different custom field will # have to be used. valid_values = cls.testrun.get_valid_field_values("arch") cls.testrun.arch = valid_values[1] cls.testrun.update() cls.tc = TestCase.create(DEFAULT_PROJ, "regression", "regression", caseimportance="high", caselevel="component", caseautomation="notautomated", caseposneg="positive", testtype="functional", subtype1="-") cls.TEST_CASE_ID = cls.tc.work_item_id
def update_document(self, space, doc_name, doc_title, wi_types=None, doc_type=None, structure_link_role="parent", content=''): cl = CmdList() if cl.list_documents_by_query(doc_name): print("Exit - Found same name '%s/%s'" % (space, doc_name)) return file_path = "" # the content could be file or data if os.path.exists(content): file_path = content with open(content, mode='r') as check_file: content = check_file.read() doc = Document.create(Document.default_project, space, doc_name, doc_title, wi_types, doc_type, structure_link_role, content) if cl.list_documents_by_query(doc_name): print("Created document '%s/%s'" % (space, doc_name)) print(" - document author : %s" % doc.author) print(" - document type : %s" % doc.type) print(" - allowed workitem type: %s" % wi_types) print(" - created date : %s" % doc.created) if file_path != "": print(" - document content is from: %s" % file_path) else: print(" - document content : %s" % content) return True else: print("Failed to create document '%s/%s'" % (space, doc_name)) return False
def setUpClass(cls): cls.doc_create = Document.create( Document.default_project, "Testing", DOC_NAME, "Document_Test", ["testcase"], "testspecification")