def _fixture_setup(self): super(BuildUpdate, self)._fixture_setup() self.product = ProductFactory() self.another_product = ProductFactory() self.build_1 = BuildFactory(product=self.product) self.build_2 = BuildFactory(product=self.product) self.build_3 = BuildFactory(product=self.product)
def _fixture_setup(self): super(TestCategory, self)._fixture_setup() self.product_nitrate = ProductFactory(name='nitrate') self.product_xmlrpc = ProductFactory(name='xmlrpc') self.case_categories = [ CategoryFactory(name='auto', product=self.product_nitrate), CategoryFactory(name='manual', product=self.product_nitrate), CategoryFactory(name='pending', product=self.product_xmlrpc), ]
def _fixture_setup(self): super()._fixture_setup() self.product_nitrate = ProductFactory(name="nitrate") self.product_xmlrpc = ProductFactory(name="xmlrpc") self.case_categories = [ CategoryFactory(name="auto", product=self.product_nitrate), CategoryFactory(name="manual", product=self.product_nitrate), CategoryFactory(name="pending", product=self.product_xmlrpc), ]
def setUpTestData(cls): cls.product_nitrate = ProductFactory(name='nitrate') cls.product_xmlrpc = ProductFactory(name='xmlrpc') cls.case_categories = [ TestCaseCategoryFactory(name='auto', product=cls.product_nitrate), TestCaseCategoryFactory(name='manual', product=cls.product_nitrate), TestCaseCategoryFactory(name='pending', product=cls.product_xmlrpc), ]
def _fixture_setup(self): super(TestCheckComponent, self)._fixture_setup() self.product_nitrate = ProductFactory(name='nitrate') self.product_xmlrpc = ProductFactory(name='xmlrpc') self.components = [ ComponentFactory(name='application', product=self.product_nitrate), ComponentFactory(name='database', product=self.product_nitrate), ComponentFactory(name='documentation', product=self.product_xmlrpc), ]
def setUpTestData(cls): cls.admin = UserFactory() cls.admin_request = make_http_request(user=cls.admin, user_perm='management.change_testbuild') cls.staff = UserFactory() cls.staff_request = make_http_request(user=cls.staff) cls.product = ProductFactory() cls.another_product = ProductFactory() cls.build_1 = TestBuildFactory(product=cls.product) cls.build_2 = TestBuildFactory(product=cls.product) cls.build_3 = TestBuildFactory(product=cls.product)
def setUpTestData(cls): super().setUpTestData() cls.plan_name = "TestNewTestPlanView" cls.product = ProductFactory() cls.product_version = VersionFactory(product=cls.product) cls.plan_type = PlanTypeFactory() cls.test_plan = TestPlanFactory() user_should_have_perm(cls.tester, perm="testplans.add_testplan") user_should_have_perm(cls.tester, perm="testplans.view_testplan") cls.location = reverse("plans-new") cls.request = { "author": cls.tester.pk, "product": cls.product.pk, "product_version": cls.product_version.pk, "type": cls.plan_type.pk, "name": cls.plan_name, "email_settings-0-auto_to_plan_author": "on", "email_settings-0-auto_to_case_owner": "on", "email_settings-0-auto_to_case_default_tester": "on", "email_settings-0-notify_on_case_update": "on", "email_settings-0-notify_on_plan_update": "on", "email_settings-0-id": cls.test_plan.emailing.pk, "email_settings-TOTAL_FORMS": "1", "email_settings-INITIAL_FORMS": "1", "email_settings-MIN_NUM_FORMS": "0", "email_settings-MAX_NUM_FORMS": "1", "is_active": True, }
def setUpTestData(cls): cls.user = UserFactory(username="******", email="*****@*****.**") cls.user.set_password("admin") cls.user.is_superuser = True cls.user.is_staff = True cls.user.save() cls.classification = ClassificationFactory(name="Auto") cls.product = ProductFactory(name="Kiwi", classification=cls.classification) cls.product_version = VersionFactory(value="0.1", product=cls.product) cls.plan_type = PlanTypeFactory() cls.test_plan = TestPlanFactory( name="another test plan for testing", product_version=cls.product_version, author=cls.user, product=cls.product, type=cls.plan_type, ) # add TestCases to plan with status CONFIRMED for _i in range(5): TestCaseFactory( plan=[cls.test_plan], case_status=TestCaseStatus.objects.get(name="CONFIRMED"), ) # also add a few PROPOSED TestCases for _i in range(3): TestCaseFactory(plan=[cls.test_plan]) cls.plan_id = cls.test_plan.pk cls.child_plan = TestPlanFactory(parent=cls.test_plan)
def setUpTestData(cls): cls.product = ProductFactory(name='StarCraft') cls.builds_count = 3 cls.builds = [ TestBuildFactory(product=cls.product) for i in range(cls.builds_count) ]
def _fixture_setup(self): super()._fixture_setup() self.product = ProductFactory() self.version = VersionFactory(product=self.product) self.build = BuildFactory(version=self.version) self.plan = TestPlanFactory(author=self.api_user, product=self.product) self.test_runs = [ TestRunFactory( product_version=self.version, build=self.build, default_tester=None, plan=self.plan, ), TestRunFactory( product_version=self.version, build=self.build, default_tester=None, plan=self.plan, ), ] self.tag0 = TagFactory(name="xmlrpc_test_tag_0") self.tag1 = TagFactory(name="xmlrpc_test_tag_1") for tag in [self.tag0, self.tag1]: self.test_runs[0].add_tag(tag) self.test_runs[1].add_tag(tag)
def test_create_plan_with_different_user(self): product = ProductFactory() version = VersionFactory(product=product) plan_type = PlanTypeFactory() user = UserFactory() params = { "product": product.pk, "product_version": version.pk, "name": "test plan", "type": plan_type.pk, "text": "Testing TCMS", "parent": None, "author": user.pk, } result = self.rpc_client.TestPlan.create(params) self.assertIn("id", result) self.assertEqual(params["name"], result["name"]) self.assertEqual(params["text"], result["text"]) self.assertIn("create_date", result) self.assertTrue(result["is_active"]) self.assertIn("extra_link", result) self.assertEqual(params["product_version"], result["product_version"]) self.assertEqual(params["product"], result["product"]) self.assertEqual(user.pk, result["author"]) self.assertEqual(params["type"], result["type"]) self.assertEqual(params["parent"], result["parent"])
def setUpTestData(cls): cls.product_name = 'StarCraft' cls.versions = ['0.6', '0.7', '0.8', '0.9', '1.0'] cls.product = ProductFactory(name=cls.product_name) cls.product_versions = [VersionFactory(product=cls.product, value=version) for version in cls.versions]
def _fixture_setup(self): super(TestCreateComponent, self)._fixture_setup() self.product = ProductFactory() # Any added component in tests will be added to this list and then remove them all self.components_to_delete = []
def setUpTestData(cls): super().setUpTestData() user_should_have_perm(cls.tester, perm="testplans.change_testplan") user_should_have_perm(cls.tester, perm="testplans.view_testplan") cls.product = ProductFactory() cls.product_version = VersionFactory(product=cls.product) cls.test_plan_type = PlanTypeFactory() cls.test_plan_1 = TestPlanFactory() cls.testplan_edit_url = reverse("plan-edit", args=[cls.test_plan_1.pk]) cls.testplan_edit_data = { "author": cls.tester.pk, "product": cls.product.pk, "product_version": cls.product_version.pk, "type": cls.test_plan_type.pk, "name": cls.test_plan_1.name, "email_settings-0-auto_to_plan_author": "on", "email_settings-0-auto_to_case_owner": "on", "email_settings-0-auto_to_case_default_tester": "on", "email_settings-0-notify_on_case_update": "on", "email_settings-0-notify_on_plan_update": "on", "email_settings-0-id": cls.test_plan_1.emailing.pk, "email_settings-TOTAL_FORMS": "1", "email_settings-INITIAL_FORMS": "1", "email_settings-MIN_NUM_FORMS": "0", "email_settings-MAX_NUM_FORMS": "1", "is_active": True, }
def _fixture_setup(self): super(TestGetTestCases, self)._fixture_setup() self.tester = UserFactory(username='******') self.reviewer = UserFactory(username='******') self.product = ProductFactory() self.plan = TestPlanFactory(author=self.tester, owner=self.tester, product=self.product) self.cases = [ TestCaseFactory(author=self.tester, default_tester=None, reviewer=self.reviewer, plan=[self.plan]), TestCaseFactory(author=self.tester, default_tester=None, reviewer=self.reviewer, plan=[self.plan]), TestCaseFactory(author=self.tester, default_tester=None, reviewer=self.reviewer, plan=[self.plan]), ] self.another_plan = TestPlanFactory(author=self.tester, owner=self.tester, product=self.product)
def _fixture_setup(self): super(TestRemoveTag, self)._fixture_setup() self.product = ProductFactory() self.version = VersionFactory() self.build = self.product.build.all()[0] self.plan = TestPlanFactory(author=self.api_user, owner=self.api_user, product=self.product) self.test_runs = [ TestRunFactory(product_version=self.version, build=self.build, default_tester=None, plan=self.plan), TestRunFactory(product_version=self.version, build=self.build, default_tester=None, plan=self.plan), ] self.tag0 = TagFactory(name='xmlrpc_test_tag_0') self.tag1 = TagFactory(name='xmlrpc_test_tag_1') self.test_runs[0].add_tag(self.tag0) self.test_runs[1].add_tag(self.tag1)
def setUpTestData(cls): cls.user = UserFactory(username='******', email='*****@*****.**') cls.user.set_password('admin') cls.user.is_superuser = True cls.user.save() cls.c = Client() cls.c.login(username='******', password='******') cls.classification = ClassificationFactory(name='Auto') cls.product = ProductFactory(name='Kiwi', classification=cls.classification) cls.product_version = VersionFactory(value='0.1', product=cls.product) cls.plan_type = PlanTypeFactory() cls.test_plan = TestPlanFactory(name='another test plan for testing', product_version=cls.product_version, owner=cls.user, author=cls.user, product=cls.product, type=cls.plan_type) TestPlanTextFactory(plan=cls.test_plan) cls.plan_id = cls.test_plan.pk cls.child_plan = TestPlanFactory(parent=cls.test_plan)
def setUpTestData(cls): cls.post_data = {"description": "test"} super().setUpTestData() cls.plan_name = "TestNewTestPlanViewPermissions" cls.product = ProductFactory() cls.product_version = VersionFactory(product=cls.product) cls.plan_type = PlanTypeFactory() cls.test_plan = TestPlanFactory() user_should_have_perm(cls.tester, perm="testplans.view_testplan") cls.post_data.update( # pylint: disable=objects-update-used { "author": cls.tester.pk, "product": cls.product.pk, "product_version": cls.product_version.pk, "type": cls.plan_type.pk, "name": cls.plan_name, "email_settings-0-auto_to_plan_author": "on", "email_settings-0-auto_to_case_owner": "on", "email_settings-0-auto_to_case_default_tester": "on", "email_settings-0-notify_on_case_update": "on", "email_settings-0-notify_on_plan_update": "on", "email_settings-0-id": cls.test_plan.emailing.pk, "email_settings-TOTAL_FORMS": "1", "email_settings-INITIAL_FORMS": "1", "email_settings-MIN_NUM_FORMS": "0", "email_settings-MAX_NUM_FORMS": "1", "is_active": True, } )
def setUpTestData(cls): cls.product = ProductFactory() cls.request = HttpRequest() cls.info_objects = _InfoObjects(cls.request, cls.product.pk) cls.build_one = BuildFactory(product=cls.product) cls.build_two = BuildFactory(product=cls.product) cls.build_two.is_active = False cls.build_two.save() cls.category_one = CategoryFactory(product=cls.product) cls.category_two = CategoryFactory(product=cls.product) cls.category_three = CategoryFactory() cls.component_one = ComponentFactory(product=cls.product) cls.component_two = ComponentFactory(product=cls.product) cls.component_three = ComponentFactory() cls.env_group_one = EnvGroupFactory() cls.env_group_two = EnvGroupFactory() cls.env_property_one = EnvPropertyFactory() cls.env_property_two = EnvPropertyFactory() EnvGroupPropertyMapFactory(group=cls.env_group_one, property=cls.env_property_one) cls.env_value_one = EnvValueFactory(property=cls.env_property_one) cls.env_value_two = EnvValueFactory() cls.user_one = UserFactory() cls.user_two = UserFactory() cls.version_one = VersionFactory(product=cls.product) cls.version_two = VersionFactory()
def setUpTestData(cls): cls.user = UserFactory() cls.http_req = make_http_request( user=cls.user, user_perm='testplans.add_testplancomponent') cls.product = ProductFactory() cls.plans = [ TestPlanFactory(author=cls.user, owner=cls.user, product=cls.product), TestPlanFactory(author=cls.user, owner=cls.user, product=cls.product), ] cls.component1 = ComponentFactory( name='xmlrpc test component 1', description='xmlrpc test description', product=cls.product, initial_owner=None, initial_qa_contact=None) cls.component2 = ComponentFactory( name='xmlrpc test component 2', description='xmlrpc test description', product=cls.product, initial_owner=None, initial_qa_contact=None)
def setUpTestData(cls): cls.http_req = make_http_request() cls.tester = UserFactory(username='******') cls.reviewer = UserFactory(username='******') cls.product = ProductFactory() cls.plan = TestPlanFactory(author=cls.tester, owner=cls.tester, product=cls.product) cls.cases = [ TestCaseFactory(author=cls.tester, default_tester=None, reviewer=cls.reviewer, plan=[cls.plan]), TestCaseFactory(author=cls.tester, default_tester=None, reviewer=cls.reviewer, plan=[cls.plan]), TestCaseFactory(author=cls.tester, default_tester=None, reviewer=cls.reviewer, plan=[cls.plan]), ] cls.another_plan = TestPlanFactory(author=cls.tester, owner=cls.tester, product=cls.product)
def setUpTestData(cls): cls.http_req = make_http_request() cls.user = UserFactory() cls.product = ProductFactory() cls.plan = TestPlanFactory(author=cls.user, owner=cls.user, product=cls.product)
def setUpTestData(cls): super().setUpTestData() user_should_have_perm(cls.tester, "bugs.view_bug") ProductFactory() VersionFactory() BuildFactory()
def test_product_delete_with_test_plan_wo_email_settings(self): """ A test to demonstrate Issue #181. Steps to reproduce: 1) Create a new Product 2) Create a new Test Plan for Product 3) DON'T edit the Test Plan 4) Delete the Product Expected results: 0) No errors 1) Product is deleted 2) Test Plan is deleted """ # setup product = ProductFactory(name="Something to delete") product_version = VersionFactory(value="0.1", product=product) plan_type = PlanTypeFactory() previous_plans_count = TestPlan.objects.count() TestPlan.objects.create( name="Test plan for the new product", author=self.user, product=product, product_version=product_version, type=plan_type, ) # verify TP was created self.assertEqual(previous_plans_count + 1, TestPlan.objects.count()) # make sure there are no email settings TestPlanEmailSettings.objects.all().delete() # now delete the product admin_delete_url = "admin:%s_%s_delete" % ( product._meta.app_label, # pylint: disable=no-member product._meta.model_name, # pylint: disable=no-member ) location = reverse(admin_delete_url, args=[product.pk]) response = self.c.get(location) self.assertContains(response, product.name) self.assertContains(response, _("Yes, I'm sure")) # confirm that we're sure we want to delete it response = self.c.post(location, {"post": "yes"}) self.assertEqual(302, response.status_code) self.assertTrue( "/admin/%s/%s/" % ( product._meta.app_label, product._meta.model_name, ) # pylint: disable=no-member in response["Location"] ) # verify everything has been deleted self.assertFalse(Product.objects.filter(pk=product.pk).exists()) self.assertFalse(Version.objects.filter(pk=product_version.pk).exists()) self.assertEqual(previous_plans_count, TestPlan.objects.count())
def test_product_delete_with_test_plan_wo_email_settings(self): """ A test to demonstrate Issue #181. Steps to reproduce: 1) Create a new Product 2) Create a new Test Plan for Product 3) DON'T edit the Test Plan 4) Delete the Product Expected results: 0) No errors 1) Product is deleted 2) Test Plan is deleted """ # setup product = ProductFactory(name='Something to delete') product_version = VersionFactory(value='0.1', product=product) plan_type = PlanTypeFactory() # create Test Plan via the UI by sending a POST request to the view previous_plans_count = TestPlan.objects.count() test_plan_name = 'Test plan for the new product' response = self.c.post(reverse('plans-new'), { 'name': test_plan_name, 'product': product.pk, 'product_version': product_version.pk, 'type': plan_type.pk, }, follow=True) self.assertEqual(HTTPStatus.OK, response.status_code) # verify test plan was created self.assertTrue(test_plan_name in str( response.content, encoding=settings.DEFAULT_CHARSET)) self.assertEqual(previous_plans_count + 1, TestPlan.objects.count()) # now delete the product admin_delete_url = "admin:%s_%s_delete" % (product._meta.app_label, product._meta.model_name) location = reverse(admin_delete_url, args=[product.pk]) response = self.c.get(location) self.assertEqual(HTTPStatus.OK, response.status_code) self.assertTrue('Are you sure you want to delete the product "%s"' % product.name in str(response.content, encoding=settings.DEFAULT_CHARSET)) self.assertTrue("Yes, I'm sure" in str( response.content, encoding=settings.DEFAULT_CHARSET)) # confirm that we're sure we want to delete it response = self.c.post(location, {'post': 'yes'}) self.assertEqual(302, response.status_code) self.assertTrue('/admin/%s/%s/' % (product._meta.app_label, product._meta.model_name) in response['Location']) # verify everything has been deleted self.assertFalse(Product.objects.filter(pk=product.pk).exists()) self.assertFalse( Version.objects.filter(pk=product_version.pk).exists()) self.assertEqual(previous_plans_count, TestPlan.objects.count())
def setUpTestData(cls): super().setUpTestData() user_should_have_perm(cls.tester, perm='testplans.change_testplan') user_should_have_perm(cls.tester, perm='testplans.view_testplan') cls.product = ProductFactory() cls.product_version = VersionFactory(product=cls.product) cls.test_plan_type = PlanTypeFactory() cls.test_plan_1 = TestPlanFactory() cls.testplan_edit_url = reverse('plan-edit', args=[cls.test_plan_1.pk]) cls.testplan_edit_data = { 'author': cls.tester.pk, 'product': cls.product.pk, 'product_version': cls.product_version.pk, 'type': cls.test_plan_type.pk, 'name': cls.test_plan_1.name, 'email_settings-0-auto_to_plan_author': 'on', 'email_settings-0-auto_to_case_owner': 'on', 'email_settings-0-auto_to_case_default_tester': 'on', 'email_settings-0-notify_on_case_update': 'on', 'email_settings-0-notify_on_plan_update': 'on', 'email_settings-0-id': cls.test_plan_1.emailing.pk, 'email_settings-TOTAL_FORMS': '1', 'email_settings-INITIAL_FORMS': '1', 'email_settings-MIN_NUM_FORMS': '0', 'email_settings-MAX_NUM_FORMS': '1', 'is_active': True, }
def _fixture_setup(self): super(TestGetProduct, self)._fixture_setup() self.product = ProductFactory() self.plan = TestPlanFactory(author=self.api_user, owner=self.api_user, product=self.product)
def test_create_plan_with_different_user(self): product = ProductFactory() version = VersionFactory(product=product) plan_type = PlanTypeFactory() user = UserFactory() params = { 'product': product.pk, 'product_version': version.pk, 'name': 'test plan', 'type': plan_type.pk, 'text': 'Testing TCMS', 'parent': None, 'author': user.pk } result = self.rpc_client.TestPlan.create(params) self.assertEqual(params['product'], result['product_id']) self.assertEqual(params['product_version'], result['product_version_id']) self.assertEqual(params['name'], result['name']) self.assertEqual(params['type'], result['type_id']) self.assertEqual(params['text'], result['text']) self.assertEqual(params['parent'], result['parent']) self.assertEqual(user.username, result['author']) self.assertEqual(user.pk, result['author_id'])
def setUpTestData(cls): cls.user = UserFactory(username='******', email='*****@*****.**') cls.user.set_password('admin') cls.user.is_superuser = True cls.user.is_staff = True cls.user.save() cls.classification = ClassificationFactory(name='Auto') cls.product = ProductFactory(name='Kiwi', classification=cls.classification) cls.product_version = VersionFactory(value='0.1', product=cls.product) cls.plan_type = PlanTypeFactory() cls.test_plan = TestPlanFactory(name='another test plan for testing', product_version=cls.product_version, owner=cls.user, author=cls.user, product=cls.product, type=cls.plan_type) # add TestCases to plan with status CONFIRMED for _i in range(5): case = TestCaseFactory( plan=[cls.test_plan], case_status=TestCaseStatus.objects.get(name='CONFIRMED')) TestCaseTextFactory(case=case)
def test_update_with_product(self): test_run = TestRunFactory() product = ProductFactory() updated_test_plan = TestPlanFactory(product=product) updated_build = BuildFactory(version=product.version.first()) updated_summary = "Updated summary." updated_stop_date = "2020-05-05 00:00:00" updated_test_run = self.rpc_client.TestRun.update( test_run.pk, { "plan": updated_test_plan.pk, "product": product.id, "build": updated_build.pk, "summary": updated_summary, "stop_date": updated_stop_date, }, ) test_run.refresh_from_db() self.assertEqual(updated_test_run["plan"], updated_test_plan.pk) self.assertEqual(updated_test_run["build"], updated_build.pk) self.assertEqual(updated_test_run["summary"], updated_summary) self.assertEqual(updated_test_run["stop_date"], test_run.stop_date)