示例#1
0
    def test_response_forbidden(self, mock_requests, mock_logger):
        mock_requests.post.return_value = Mock(status_code=403)

        org = factories.Organization()

        response = create_instance(org)
        self.assertEqual(response.status_code, 403)
        mock_logger.warning.assert_called_once_with(
            '{} (id={}, model={}) could not be created/fetched successfully '
            'on/from Track.'.format(org.name, org.id, 'Organization'))
示例#2
0
    def test_response_org_create(self, mock_requests, mock_logger):
        mock_requests.post.return_value = Mock(status_code=201)

        org = factories.Organization()

        response = create_instance(org)
        self.assertEqual(response.status_code, 201)
        mock_logger.info.assert_called_once_with(
            'The request for {} (id={}, model={}) was successfully executed '
            'on Track.'.format(org.name, org.id, 'Organization'))
示例#3
0
    def test_response_wfl1_create(self, mock_requests, mock_logger):
        content = [{'id': self.tola_user.organization.id}]
        mock_requests.post.return_value = Mock(status_code=201)
        mock_requests.get.return_value = Mock(status_code=200,
                                              content=json.dumps(content))

        wfl1 = factories.WorkflowLevel1(
            organization=self.tola_user.organization)

        response = create_instance(wfl1)
        self.assertEqual(response.status_code, 201)
        mock_logger.info.assert_called_once_with(
            'The request for {} (id={}, model={}) was successfully executed '
            'on Track.'.format(wfl1.name, wfl1.id, 'WorkflowLevel1'))
示例#4
0
def sync_save_track_workflowlevel1(sender, instance, **kwargs):
    if settings.TOLA_TRACK_SYNC_ENABLED:
        if kwargs.get('created'):
            tsync.create_instance(instance)
        else:
            tsync.update_instance(instance)
示例#5
0
def sync_save_track_organization(sender, instance, **kwargs):
    if settings.TOLA_TRACK_SYNC_ENABLED:
        if kwargs.get('created'):
            tsync.create_instance(instance)
        else:
            tsync.update_instance(instance)
示例#6
0
    def test_response_wrong_model_create(self):
        tola_user = factories.TolaUser()

        with self.assertRaises(ValueError):
            create_instance(tola_user)