Ejemplo n.º 1
0
    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  # pylint: disable=protected-access

        # 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()
Ejemplo n.º 2
0
    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)

        url = reverse('execution-detail-pane', args=[self.execution_1.case_id])
        response = self.client.get(
            url, {
                'case_run_id':
                self.execution_1.pk,
                'case_text_version':
                self.execution_1.case.history.latest().history_id,
            })

        self.assertEqual(HTTPStatus.OK, response.status_code)

        self.assertContains(
            response,
            '<textarea name="comment" cols="40" id="id_comment" maxlength="10000" '
            'rows="10">\n</textarea>',
            html=True)

        with override('en'):
            for status in TestExecutionStatus.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)
Ejemplo n.º 3
0
 def setUpTestData(cls):
     super().setUpTestData()
     initiate_user_with_default_setups(cls.tester)
     cls.url = reverse('ajax.update.cases-actor')
     cls.case_pks = []
     for case in TestCase.objects.filter(plan=cls.plan):
         cls.case_pks.append(case.pk)
Ejemplo n.º 4
0
    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)

        url = reverse('execution-detail-pane', args=[self.execution_1.case_id])
        response = self.client.get(
            url, {
                'execution_id':
                self.execution_1.pk,
                'case_text_version':
                self.execution_1.case.history.latest().history_id,
            })

        self.assertEqual(HTTPStatus.OK, response.status_code)

        self.assertContains(
            response,
            '<textarea name="comment" cols="40" id="id_comment" maxlength="3000" '
            'rows="10">\n</textarea>',
            html=True)

        for status in TestExecutionStatus.objects.all():
            self.assertContains(
                response,
                '<i class="submit_button %s fa-2x" style="color: %s" \
                    statusId="%s" title="%s"></i>' %
                (status.icon, status.color, status.pk, status.name),
                html=True)
Ejemplo n.º 5
0
    def setUpTestData(cls):
        super().setUpTestData()
        initiate_user_with_default_setups(cls.tester)
        cls.test_run = TestRunFactory()

        cls.superuser = UserFactory()
        cls.superuser.is_superuser = True
        cls.superuser.set_password("password")
        cls.superuser.save()
Ejemplo n.º 6
0
    def setUpTestData(cls):
        super().setUpTestData()

        initiate_user_with_default_setups(cls.tester)
        cls.comment_bug_url = reverse("bugs-comment")
        user_should_have_perm(cls.tester, "bugs.change_bug")

        cls.assignee = UserFactory()
        cls.url = reverse("bugs-comment")
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
    def save(self, commit=True):
        user = super().save(commit=False)
        user.email = self.cleaned_data["email"]
        user.is_active = False
        user.set_password(self.cleaned_data["password1"])

        if User.objects.filter(is_superuser=True).count() == 0:
            user.is_superuser = True

        if commit:
            user.save()
            initiate_user_with_default_setups(user)
        return user
Ejemplo n.º 10
0
    def setUpTestData(cls):
        super().setUpTestData()
        initiate_user_with_default_setups(cls.tester)

        for _i in range(3):
            cls.test_run.add_tag(TagFactory())

        cls.unauthorized = UserFactory()
        cls.unauthorized.set_password('password')
        cls.unauthorized.save()

        cls.unauthorized.user_permissions.add(*Permission.objects.all())
        remove_perm_from_user(cls.unauthorized, 'testruns.add_testruntag')
        remove_perm_from_user(cls.unauthorized, 'testruns.delete_testruntag')
Ejemplo n.º 11
0
    def _fixture_setup(self):
        # restore the serialized data from initial migrations
        # this includes default groups and permissions
        super()._fixture_setup()
        self.api_user = UserFactory()
        self.api_user.set_password('api-testing')
        initiate_user_with_default_setups(self.api_user)

        # this is the XML-RPC ServerProxy with cookies support
        self.rpc_client = tcms_api.xmlrpc.TCMSXmlrpc(
            self.api_user.username,
            'api-testing',
            '%s/xml-rpc/' % self.live_server_url,
        ).server
Ejemplo n.º 12
0
def initiate_defaults(strategy, details, backend, user=None, *args, **kwargs):
    if user:
        initiate_user_with_default_setups(user)
Ejemplo n.º 13
0
 def setUpTestData(cls):
     super().setUpTestData()
     initiate_user_with_default_setups(cls.tester)
     cls.test_plan = TestPlanFactory()
Ejemplo n.º 14
0
 def setUpTestData(cls):
     super().setUpTestData()
     initiate_user_with_default_setups(cls.tester)
Ejemplo n.º 15
0
 def setUpTestData(cls):
     super().setUpTestData()
     initiate_user_with_default_setups(cls.tester)
     cls.test_case = TestCaseFactory()
Ejemplo n.º 16
0
    def setUpTestData(cls):
        super().setUpTestData()
        initiate_user_with_default_setups(cls.tester)

        cls.test_run = TestRunFactory()
        cls.execution = TestExecutionFactory(run=cls.test_run)
Ejemplo n.º 17
0
    def setUpTestData(cls):
        super().setUpTestData()

        initiate_user_with_default_setups(cls.tester)
        cls.comment_bug_url = reverse('bugs-comment')
        user_should_have_perm(cls.tester, 'bugs.change_bug')
Ejemplo n.º 18
0
 def setUpTestData(cls):
     super().setUpTestData()
     initiate_user_with_default_setups(cls.tester)
     cls.url = reverse('ajax.update.cases-actor')
Ejemplo n.º 19
0
 def setUpTestData(cls):
     super().setUpTestData()
     initiate_user_with_default_setups(cls.tester)
     cls.test_bug = BugFactory()
Ejemplo n.º 20
0
from django.contrib.auth.models import User

from tcms.management.models import Classification
from tcms.utils.permissions import initiate_user_with_default_setups

# this will be used for API calls
bot = User.objects.create(
    username='******',
    email='*****@*****.**',
    is_active=True,
)
bot.set_password('changeme')
bot.save()
initiate_user_with_default_setups(bot)

# this is used inside integration test
Classification.objects.create(name='test-products')
Ejemplo n.º 21
0
def initiate_defaults(strategy, details, backend, user=None, *args, **kwargs):
    if user and kwargs.get('is_new', False):
        initiate_user_with_default_setups(user)