def find_testcase_by_reference(ref): """Find a testcase by using the data in the testcase reference This method uses an iterative approach to the information in the reference. Meaning that it looks at each piece of data, in a particular order, and tries to find the testcase by that information. The order the properties are searched in are: 1. testcaseId 2. automationId 3. automationKey 4. name The automationTool property is not considered unique, so it is not used for finding the testcase. :param ref: The TestcaseReference object that will be used to try to find the Testcase :return: A slickqaweb.model.testcase.Testcase instance on success, None on failure """ assert isinstance(ref, TestcaseReference) testcase = None if hasattr(ref, 'testcaseId') and ref.testcaseId is not None: testcase = Testcase.objects(id=ref.testcaseId).first() if testcase is None and hasattr(ref, 'automationId') and ref.automationId is not None and ref.automationId != '': testcase = Testcase.objects(automationId=ref.automationId).first() if testcase is None and hasattr(ref, 'automationKey') and ref.automationKey is not None and ref.automationKey != '': testcase = Testcase.objects(automationKey=ref.automationKey).first() if testcase is None and hasattr(ref, 'name') and ref.name is not None and ref.name != '': testcase = Testcase.objects(name=ref.name).first() return testcase
def update_testcase(testcase_id): """Update the properties of a testcase.""" orig = Testcase.objects(id=testcase_id).first() deserialize_that(read_request(), orig) orig.save() return JsonResponse(orig)
def get_testcase_by_id(testcase_id): """Retrieve a testcase by it's id.""" return JsonResponse(Testcase.objects(id=testcase_id).first())