def test_put_with_local_site_and_set_local_site(self):
        """Testing the PUT <URL> API and attempting to set a LocalSite for a
        another LocalSite's WebHook is ignored
        """
        local_site_1 = LocalSite.objects.create(name='local-site-1')
        local_site_1.users.add(self.user)

        local_site_2 = LocalSite.objects.create(name='local-site-2')

        self.user.is_superuser = True
        self.user.save()

        webhook = self.create_webhook(local_site=local_site_1)

        rsp = self.api_put(get_webhook_item_url(webhook.pk, local_site_1.name),
                           {
                               'local_site': local_site_2.pk,
                           },
                           expected_mimetype=webhook_item_mimetype)

        self.assertEqual(rsp['stat'], 'ok')

        webhook = WebHookTarget.objects.get(pk=rsp['webhook']['id'])
        self.assertEqual(webhook.local_site_id, local_site_1.pk)
        self.compare_item(rsp['webhook'], webhook)
Exemple #2
0
    def setup_basic_put_test(self, user, with_local_site, local_site_name,
                             put_valid_data):

        webhook = self.create_webhook(with_local_site=with_local_site)

        return (get_webhook_item_url(webhook.pk, local_site_name),
                webhook_item_mimetype, {}, webhook, [])
Exemple #3
0
    def test_put_with_local_site_and_set_local_site(self):
        """Testing the PUT <URL> API and attempting to set a LocalSite for a
        another LocalSite's WebHook is ignored
        """
        local_site_1 = LocalSite.objects.create(name='local-site-1')
        local_site_1.users.add(self.user)

        local_site_2 = LocalSite.objects.create(name='local-site-2')

        self.user.is_superuser = True
        self.user.save()

        webhook = self.create_webhook(local_site=local_site_1)

        rsp = self.api_put(
            get_webhook_item_url(webhook.pk, local_site_1.name),
            {
                'local_site': local_site_2.pk,
            },
            expected_mimetype=webhook_item_mimetype)

        self.assertEqual(rsp['stat'], 'ok')

        webhook = WebHookTarget.objects.get(pk=rsp['webhook']['id'])
        self.assertEqual(webhook.local_site_id, local_site_1.pk)
        self.compare_item(rsp['webhook'], webhook)
Exemple #4
0
    def setup_basic_put_test(self, user, with_local_site, local_site_name,
                             put_valid_data):
        webhook = self.create_webhook(with_local_site=with_local_site)

        return (get_webhook_item_url(webhook.pk, local_site_name),
                webhook_item_mimetype,
                {},
                webhook,
                [local_site_name])
    def test_put_with_global_site_and_set_local_site(self):
        """Testing the PUT <URL> API and attempting to set a LocalSite for a
        non-LocalSite WebHook is ignored
        """
        local_site = LocalSite.objects.create(name='local-site-1')

        self.user.is_superuser = True
        self.user.save()

        webhook = self.create_webhook()

        rsp = self.api_put(get_webhook_item_url(webhook.pk), {
            'local_site': local_site.pk,
        },
                           expected_mimetype=webhook_item_mimetype)

        self.assertEqual(rsp['stat'], 'ok')

        webhook = WebHookTarget.objects.get(pk=rsp['webhook']['id'])
        self.assertIsNone(webhook.local_site)
        self.compare_item(rsp['webhook'], webhook)
Exemple #6
0
    def test_put_with_global_site_and_set_local_site(self):
        """Testing the PUT <URL> API and attempting to set a LocalSite for a
        non-LocalSite WebHook is ignored
        """
        local_site = LocalSite.objects.create(name='local-site-1')

        self.user.is_superuser = True
        self.user.save()

        webhook = self.create_webhook()

        rsp = self.api_put(
            get_webhook_item_url(webhook.pk),
            {
                'local_site': local_site.pk,
            },
            expected_mimetype=webhook_item_mimetype)

        self.assertEqual(rsp['stat'], 'ok')

        webhook = WebHookTarget.objects.get(pk=rsp['webhook']['id'])
        self.assertIsNone(webhook.local_site)
        self.compare_item(rsp['webhook'], webhook)
    def setup_basic_delete_test(self, user, with_local_site, local_site_name):
        webhook = self.create_webhook(with_local_site=with_local_site)

        return (get_webhook_item_url(webhook.pk, local_site_name), [webhook])
    def setup_basic_get_test(self, user, with_local_site, local_site_name):
        webhook = self.create_webhook(with_local_site=with_local_site)

        return (get_webhook_item_url(webhook.pk, local_site_name),
                webhook_item_mimetype, webhook)
Exemple #9
0
    def setup_basic_delete_test(self, user, with_local_site, local_site_name):
        webhook = self.create_webhook(with_local_site=with_local_site)

        return (get_webhook_item_url(webhook.pk, local_site_name),
                [webhook])
Exemple #10
0
    def setup_basic_get_test(self, user, with_local_site, local_site_name):
        webhook = self.create_webhook(with_local_site=with_local_site)

        return (get_webhook_item_url(webhook.pk, local_site_name),
                webhook_item_mimetype,
                webhook)