type="Release", product="Red Hat Enterprise Linux 6", version="6.2") # Link all automated test cases from the general plan info("Linking automated test cases from the general plan") for testcase in general_plan: if testcase.automated: release_plan.testcases.add(testcase) release_plan.update() # Create a new test case info("Creating a new test case") testcase = tcms_api.TestCase( summary="New performance test", product="Red Hat Enterprise Linux 6", category="Performance", script="/CoreOS/python/Performance/base") # Set status, priority, default tester, add tags, attach bugs, link plans info("Setting status, priority, tester, tags, bugs and plans") testcase.status = tcms_api.CaseStatus("CONFIRMED") testcase.priority = tcms_api.Priority("P1") testcase.tester = tcms_api.User("psplicha") testcase.tags.add(tcms_api.Tag("Tier1")) testcase.bugs.add(tcms_api.Bug(bug=123)) testcase.testplans.add([general_plan, release_plan]) testcase.update() # List all general plan's children including their status info("Listing child test plans of the general test plan")
type="Performance", product="MESSAGING", version="1.2", text='simple text') # Link all automated test cases from the general plan info("Linking automated test cases from the general plan") for testcase in general_plan: if testcase.automated: release_plan.testcases.add(testcase) release_plan.update() # Create a new test case info("Creating a new test case") testcase = tcms_api.TestCase(summary="New performance test", product="MESSAGING", category="MESSAGING category", script="/CoreOS/python/Performance/base") # Set status, priority, default tester, add tags, attach bugs, link plans info("Setting status, priority, tester, tags, bugs and plans") testcase.status = tcms_api.CaseStatus("CONFIRMED") testcase.priority = tcms_api.Priority("P1") testcase.tester = tcms_api.User("plivo") # testcase.tags.add(tcms_api.Tag("Tier1")) # testcase.bugs.add(tcms_api.Bug(bug=123)) testcase.testplans.add([general_plan, release_plan]) testcase.update() # List all general plan's children including their status info("Listing child test plans of the general test plan") for testplan in general_plan.children:
def _fixture_setup(self): # restore the serialized data from initial migrations # this includes default groups and permissions super(BaseAPIClient_TestCase, self)._fixture_setup() # initial cache reset to avoid storing anything in cache tcms_api.config.set_cache_level(tcms_api.config.CACHE_NONE) # reset connection to server b/c the address changes for # every test and the client caches this as a class attribute tcms_api.TCMS._connection = None # also the config is a singleton so reset that too # to force config reload tcms_api.Config._instance = None # API user self.api_user, _ = User.objects.get_or_create(username='******', email='*****@*****.**') self.api_user.set_password('testing') initiate_user_with_default_setups(self.api_user) # WARNING: for now we override the config file # until we can pass the testing configuration # TODO: change config values instead of overwriting files on disk conf_path = os.path.expanduser('~/.tcms.conf') conf_fh = open(conf_path, 'w') conf_fh.write("""[tcms] url = %s/xml-rpc/ username = %s password = %s """ % (self.live_server_url, self.api_user.username, 'testing')) conf_fh.close() # create the product first so we can fetch it via API f_product = ProductFactory() self.product = tcms_api.Product(name=f_product.name) f_version = VersionFactory(product=f_product) self.version = tcms_api.Version(product=self.product, version=f_version.value) self.plantype = tcms_api.PlanType(name="Function") TestCaseCategoryFactory(name='Security', product=f_product) TestCaseCategoryFactory(name='Sanity', product=f_product) f_category = TestCaseCategoryFactory(product=f_product) self.category = tcms_api.Category(category=f_category.name, product=self.product) f_component = ComponentFactory(product=f_product) self.component = tcms_api.Component(name=f_component.name, product=self.product) self.CASESTATUS = tcms_api.CaseStatus("CONFIRMED") self.build = tcms_api.Build(product=self.product, build="unspecified") f_tags = [TestTagFactory() for i in range(20)] self.tags = [tcms_api.Tag(t.pk) for t in f_tags] f_users = [UserFactory() for i in range(50)] self.TESTERS = [tcms_api.User(u.pk) for u in f_users] # Create test cases self.cases = [] for case_count in range(self.num_cases): testcase = tcms_api.TestCase( category=self.category, product=self.product, summary="Test Case {0}".format(case_count + 1), status=self.CASESTATUS) # Add a couple of random tags and the default tester testcase.tags.add( [random.choice(self.tags) for counter in range(10)]) testcase.tester = random.choice(self.TESTERS) testcase.update() self.cases.append(testcase) # Create master test plan (parent of all) self.master = tcms_api.TestPlan(name="API client Test Plan", text='Master TP created from API', product=self.product, version=self.version, type=self.plantype) self.master.owner = self.api_user self.master.testcases.add(self.cases) self.master.update() # Create child test plans self.testruns = [] for plan_count in range(self.num_plans): testplan = tcms_api.TestPlan( name="Test Plan {0}".format(plan_count + 1), text='Child TP created from API', product=self.product, version=self.version, parent=self.master, type=self.plantype) # Link all test cases to the test plan testplan.testcases.add(self.cases) testplan.update() # Create test runs for run_count in range(self.num_runs): testrun = tcms_api.TestRun( testplan=testplan, build=self.build, product=self.product, summary="Test Run {0}".format(run_count + 1), version=self.version.name) self.testruns.append(testrun) # Create a TestCaseRun object self.caserun = TestCaseRunFactory() self.caserun.add_bug(1234, TestCaseBugSystem.objects.first().pk)