def _fixture_setup(self): # restore the serialized data from initial migrations # this includes default groups and permissions super(XmlrpcAPIBaseTest, self)._fixture_setup() self.api_user = UserFactory() self.api_user.set_password('api-testing') initiate_user_with_default_setups(self.api_user) # 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 # 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, 'api-testing')) conf_fh.close() # this is the XML-RPC ServerProxy with cookies support self.rpc_client = tcms_api.TCMS()
def test_user_in_default_group_sees_comments(self): # test for https://github.com/kiwitcms/Kiwi/issues/74 initiate_user_with_default_setups(self.tester) self.login_tester() url = reverse('caserun-detail-pane', args=[self.case_run_1.case_id]) response = self.client.get( url, { 'case_run_id': self.case_run_1.pk, 'case_text_version': self.case_run_1.case.latest_text_version() }) self.assertEqual(http.client.OK, response.status_code) self.assertContains( response, '<textarea name="comment" cols="40" id="id_comment" maxlength="10000" ' 'rows="10">\n</textarea>', html=True) for status in TestCaseRunStatus.objects.all(): self.assertContains( response, "<input type=\"submit\" class=\"btn btn_%s btn_status js-status-button\" " "title=\"%s\"" % (status.name.lower(), status.name), html=False)
def save(self, commit=True): user = super(RegistrationForm, self).save(commit=False) user.email = self.cleaned_data['email'] user.is_active = False user.set_password(self.cleaned_data["password1"]) if commit: user.save() initiate_user_with_default_setups(user) return user
def test_view_loads_fine(self): initiate_user_with_default_setups(self.tester) url = reverse('plan-choose_run', args=[self.plan.pk]) response = self.client.get(url, follow=True) self.assertEqual(HTTPStatus.OK, response.status_code) # assert basic data is shown self.assertContains(response, self.plan.name) for test_run in self.plan.run.all(): self.assertContains(response, test_run.summary)
def setUpTestData(cls): super(TestPlanEnvironmentGroupTests, cls).setUpTestData() cls.product = ProductFactory() cls.product_version = VersionFactory(product=cls.product) cls.env_group = EnvGroupFactory() cls.new_env_group = EnvGroupFactory(name='Laptop hardware') cls.tester = UserFactory() cls.tester.set_password('password') initiate_user_with_default_setups(cls.tester)
def setUpTestData(cls): super(Test_TestCaseUpdateActions, cls).setUpTestData() initiate_user_with_default_setups(cls.tester)
def setUpTestData(cls): super().setUpTestData() initiate_user_with_default_setups(cls.tester) cls.url = reverse('ajax.update.cases-actor')
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)