Пример #1
0
    def test_new_issue(self):
        self.app.config['USE_METRICS'] = True
        user = self.login()
        dataset = Dataset.objects.create(title='Test dataset')

        url = url_for('api.issues', **{'for': dataset.id})
        with assert_emit(on_new_issue):
            response = self.post(url, {
                'title': 'test title',
                'comment': 'bla bla',
                'subject': {
                    'class': 'Dataset',
                    'id': dataset.id,
                }
            })
        self.assert201(response)

        dataset.reload()
        self.assertEqual(dataset.metrics['issues'], 1)

        issues = Issue.objects(subject=dataset)
        self.assertEqual(len(issues), 1)

        issue = issues[0]
        self.assertEqual(issue.user, user)
        self.assertEqual(len(issue.discussion), 1)
        self.assertIsNotNone(issue.created)
        self.assertIsNone(issue.closed)
        self.assertIsNone(issue.closed_by)
        self.assertEqual(issue.title, 'test title')

        message = issue.discussion[0]
        self.assertEqual(message.content, 'bla bla')
        self.assertEqual(message.posted_by, user)
        self.assertIsNotNone(message.posted_on)
Пример #2
0
    def test_new_issue(self):
        user = self.login()
        dataset = Dataset.objects.create(title='Test dataset')

        url = url_for('api.issues', **{'for': dataset.id})
        with self.assert_emit(on_new_issue):
            response = self.post(url, {
                'title': 'test title',
                'comment': 'bla bla',
                'subject': dataset.id
            })
        self.assertStatus(response, 201)

        dataset.reload()
        self.assertEqual(dataset.metrics['issues'], 1)

        issues = Issue.objects(subject=dataset)
        self.assertEqual(len(issues), 1)

        issue = issues[0]
        self.assertEqual(issue.user, user)
        self.assertEqual(len(issue.discussion), 1)
        self.assertIsNotNone(issue.created)
        self.assertIsNone(issue.closed)
        self.assertIsNone(issue.closed_by)
        self.assertEqual(issue.title, 'test title')

        message = issue.discussion[0]
        self.assertEqual(message.content, 'bla bla')
        self.assertEqual(message.posted_by, user)
        self.assertIsNotNone(message.posted_on)
Пример #3
0
 def get(self, org):
     '''List organization issues'''
     reuses = Reuse.objects(organization=org).only('id')
     datasets = Dataset.objects(organization=org).only('id')
     subjects = list(reuses) + list(datasets)
     qs = Issue.objects(subject__in=subjects).order_by('-created')
     return list(qs)
Пример #4
0
    def test_new_issue(self):
        user = self.login()
        dataset = Dataset.objects.create(title='Test dataset')

        response = self.post(url_for('api.issues', **{'for': dataset.id}), {
            'title': 'test title',
            'comment': 'bla bla',
            'subject': dataset.id
        })
        self.assertStatus(response, 201)

        dataset.reload()
        self.assertEqual(dataset.metrics['issues'], 1)

        issues = Issue.objects(subject=dataset)
        self.assertEqual(len(issues), 1)

        issue = issues[0]
        self.assertEqual(issue.user, user)
        self.assertEqual(len(issue.discussion), 1)
        self.assertIsNotNone(issue.created)
        self.assertIsNone(issue.closed)
        self.assertIsNone(issue.closed_by)
        self.assertEqual(issue.title, 'test title')

        message = issue.discussion[0]
        self.assertEqual(message.content, 'bla bla')
        self.assertEqual(message.posted_by, user)
        self.assertIsNotNone(message.posted_on)
Пример #5
0
 def get(self, org):
     '''List organization issues'''
     reuses = Reuse.objects(organization=org).only('id')
     datasets = Dataset.objects(organization=org).only('id')
     subjects = list(reuses) + list(datasets)
     qs = Issue.objects(subject__in=subjects).order_by('-created')
     return list(qs)
Пример #6
0
    def test_new_issue(self):
        user = self.login()
        fake = Fake.objects.create(name='Fake')

        response = self.post(url_for('api.fake_issues', id=fake.id), {
            'type': 'other',
            'comment': 'bla bla'
        })
        self.assertStatus(response, 201)

        fake.reload()
        self.assertEqual(fake.metrics['issues'], 1)

        issues = Issue.objects(subject=fake)
        self.assertEqual(len(issues), 1)

        issue = issues[0]
        self.assertEqual(issue.type, 'other')
        self.assertEqual(issue.user, user)
        self.assertEqual(len(issue.discussion), 1)
        self.assertIsNotNone(issue.created)
        self.assertIsNone(issue.closed)
        self.assertIsNone(issue.closed_by)

        message = issue.discussion[0]
        self.assertEqual(message.content, 'bla bla')
        self.assertEqual(message.posted_by, user)
        self.assertIsNotNone(message.posted_on)
Пример #7
0
 def get(self, org):
     """List organization issues"""
     reuses_ids = [r.id for r in Reuse.objects(organization=org).only("id")]
     datasets_ids = [d.id for d in Dataset.objects(organization=org).only("id")]
     ids = reuses_ids + datasets_ids
     qs = Issue.objects(subject__in=ids).order_by("-created")
     return list(qs)
Пример #8
0
    def test_new_issue(self):
        user = self.login()
        fake = Fake.objects.create(name='Fake')

        response = self.post(url_for('api.fake_issues', id=fake.id), {
            'type': 'other',
            'comment': 'bla bla'
        })
        self.assertStatus(response, 201)

        fake.reload()
        self.assertEqual(fake.metrics['issues'], 1)

        issues = Issue.objects(subject=fake)
        self.assertEqual(len(issues), 1)

        issue = issues[0]
        self.assertEqual(issue.type, 'other')
        self.assertEqual(issue.user, user)
        self.assertEqual(len(issue.discussion), 1)
        self.assertIsNotNone(issue.created)
        self.assertIsNone(issue.closed)
        self.assertIsNone(issue.closed_by)

        message = issue.discussion[0]
        self.assertEqual(message.content, 'bla bla')
        self.assertEqual(message.posted_by, user)
        self.assertIsNotNone(message.posted_on)
Пример #9
0
 def get(self, org):
     '''List organization issues'''
     reuses_ids = [r.id for r in Reuse.objects(organization=org).only('id')]
     datasets_ids = [d.id
                     for d in Dataset.objects(organization=org).only('id')]
     ids = reuses_ids + datasets_ids
     qs = Issue.objects(subject__in=ids).order_by('-created')
     return list(qs)