コード例 #1
0
    def _create_project(self):
        # Bare bones project
        project = models.Project()
        project.name = 'TEST_PROJECT'
        project.description = 'TEST_DESCRIPTION'

        project.save()

        # Bare bones stage
        stage = models.Stage()
        stage.project = project
        stage.name = 'Production'
        stage.save()

        self.stage = stage

        # Bare bones configuration
        configuration = models.Configuration()
        configuration.project = project
        configuration.stage = stage
        configuration.key = 'KEY'
        configuration.value = 'VALUE'
        configuration.prompt_me_for_input = True
        configuration.save()

        self.configuration = configuration

        # Bare bones task
        task = models.Task()
        task.name = 'TASK_NAME'
        task.save()

        self.task = task

        # Bare bones deployment
        deployment = models.Deployment()
        deployment.user = self.user
        deployment.stage = stage
        deployment.comments = 'COMMENTS'
        deployment.output = 'OUTPUT'
        deployment.task = task
        deployment.save()

        # Setup Hook
        hook = hook_models.Hook()
        hook.url = 'http://example.com'
        hook.save()

        project_hook = hook_models.Hook()
        project_hook.url = 'http://example.com/project/hook/'
        project_hook.project = project
        project_hook.save()

        self.deployment = deployment

        self.hook = hook
        self.project_hook = project_hook

        self.project = project
コード例 #2
0
    def test_custom_serializer(self):

        test_class = hook_models.Hook()
        test_class.dict = dict

        ret = utils.serialize_hook(test_class)

        self.assertEqual(ret, 'CUSTOM_SERIALIZER_CALLED')
コード例 #3
0
ファイル: test_urls.py プロジェクト: caputomarcos/trinity
    def test_hook_reverse_with_project(self):
        h = hook_models.Hook()
        h.url = 'http://www.example.com'
        h.project = self.project

        self.assertEqual(
            reverse('projects_project_view', args=(self.project.pk, )),
            h.get_absolute_url())
コード例 #4
0
    def test_serialize_hook_no_serialize_hook_method(self):
        def dict():
            return 'DICT_TEST'

        test_class = hook_models.Hook()
        test_class.dict = dict
        # self.fail(utils.serialize_hook(test_class))
        self.assertEqual(utils.serialize_hook(test_class)['hook'], 'DICT_TEST')
コード例 #5
0
    def test_deliver_hook(self):
        def dict():
            return 'DICT_TEST'

        h = hook_models.Hook()
        h.dict = dict

        h.url = 'http://www.example.com'
        receivers.deliver_hook(h, 'http://www.example.com')
コード例 #6
0
ファイル: test_views.py プロジェクト: caputomarcos/trinity
    def test_delete_hook_view(self):

        hook_to_delete = hook_models.Hook()
        hook_to_delete.url = 'http://www.deleteme.com/'
        hook_to_delete.save()

        self.assertTrue(hook_to_delete.pk)

        view = reverse('hooks_hook_delete', args=(hook_to_delete.pk, ))

        self.client.post(view)

        hooks = hook_models.Hook.objects.filter(url='http://www.deleteme.com/')

        self.assertFalse(hooks.exists())
コード例 #7
0
ファイル: test_urls.py プロジェクト: caputomarcos/trinity
    def _create_project(self):
        # Bare bones project
        project = models.Project()
        project.name = 'TEST_PROJECT'
        project.description = 'TEST_DESCRIPTION'

        project.save()

        project_hook = hook_models.Hook()
        project_hook.url = 'http://example.com/project/hook/'
        project_hook.project = project
        project_hook.save()

        self.project_hook = project_hook

        self.project = project
コード例 #8
0
    def test_task_delete_hook(self, mock_requests):

        # post_data deletes hooks when the status code is 410
        mock_requests.post.return_value.status_code = 410

        h = hook_models.Hook()
        h.url = 'http://example.com/project/delete/me/'
        h.project = self.project
        h.save()

        d = DeliverHook()

        # We're testing we don't have hook deleted, since we're not passing in the hook id
        ret = d.post_data('http://example.com/api/123', {'junk': 'payload'})

        hook_models.Hook.objects.get(pk=h.pk)
コード例 #9
0
    def test_task_delete_hook_410(self, mock_requests):

        # post_data deletes hooks when the status code is 410
        mock_requests.post.return_value.status_code = 410

        h = hook_models.Hook()
        h.url = 'http://example.com/project/delete/me/'
        h.project = self.project
        h.save()

        hook_id = h.pk

        d = DeliverHook()
        ret = d.post_data('http://example.com/api/123', {'junk': 'payload'},
                          hook_id)

        def look_up_error(hook_id):
            hook_models.Hook.objects.get(pk=hook_id)

        self.assertRaises(hook_models.Hook.DoesNotExist, look_up_error,
                          hook_id)
コード例 #10
0
ファイル: test_urls.py プロジェクト: caputomarcos/trinity
    def test_hook_reverse(self):
        h = hook_models.Hook()
        h.url = 'http://www.example.com'

        self.assertEqual(reverse('index'), h.get_absolute_url())