Exemple #1
0
    def test_notify_org_issues(self):
        recipient = UserFactory()
        member = Member(user=recipient, role='editor')
        org = OrganizationFactory(members=[member])
        dataset = DatasetFactory(organization=org)

        open_issues = {}
        for i in range(3):
            user = UserFactory()
            message = Message(content=faker.sentence(), posted_by=user)
            issue = DatasetIssue.objects.create(subject=dataset,
                                                user=user,
                                                title=faker.sentence(),
                                                discussion=[message])
            open_issues[issue.id] = issue
        # Creating a closed issue that shouldn't show up in response.
        user = UserFactory()
        message = Message(content=faker.sentence(), posted_by=user)
        DatasetIssue.objects.create(subject=dataset,
                                    user=user,
                                    title=faker.sentence(),
                                    discussion=[message],
                                    closed=datetime.now(),
                                    closed_by=user)

        notifications = issues_notifications(recipient)

        self.assertEqual(len(notifications), len(open_issues))

        for dt, details in notifications:
            issue = open_issues[details['id']]
            self.assertEqual(details['title'], issue.title)
            self.assertEqual(details['subject']['id'], issue.subject.id)
            self.assertEqual(details['subject']['type'], 'dataset')
Exemple #2
0
    def test_notify_user_issues(self):
        owner = UserFactory()
        dataset = DatasetFactory(owner=owner)

        open_issues = {}
        for i in range(3):
            user = UserFactory()
            message = Message(content=faker.sentence(), posted_by=user)
            issue = Issue.objects.create(subject=dataset,
                                         user=user,
                                         title=faker.sentence(),
                                         discussion=[message])
            open_issues[issue.id] = issue

        # Creating a closed issue that shouldn't show up in response.
        user = UserFactory()
        message = Message(content=faker.sentence(), posted_by=user)
        Issue.objects.create(subject=dataset,
                             user=user,
                             title=faker.sentence(),
                             discussion=[message],
                             closed=datetime.now(),
                             closed_by=user)

        notifications = issues_notifications(owner)

        self.assertEqual(len(notifications), len(open_issues))

        for dt, details in notifications:
            issue = open_issues[details['id']]
            self.assertEqual(details['title'], issue.title)
            self.assertEqual(details['subject']['id'], issue.subject.id)
            self.assertEqual(details['subject']['type'], 'dataset')
Exemple #3
0
    def test_notify_org_issues(self):
        recipient = UserFactory()
        member = Member(user=recipient, role='editor')
        org = OrganizationFactory(members=[member])
        dataset = DatasetFactory(organization=org)

        open_issues = {}
        for i in range(3):
            user = UserFactory()
            message = Message(content=faker.sentence(), posted_by=user)
            issue = Issue.objects.create(
                subject=dataset,
                user=user,
                title=faker.sentence(),
                discussion=[message]
            )
            open_issues[issue.id] = issue
        # Creating a closed issue that shouldn't show up in response.
        user = UserFactory()
        message = Message(content=faker.sentence(), posted_by=user)
        Issue.objects.create(
            subject=dataset,
            user=user,
            title=faker.sentence(),
            discussion=[message],
            closed=datetime.now(),
            closed_by=user
        )

        notifications = issues_notifications(recipient)

        self.assertEqual(len(notifications), len(open_issues))

        for dt, details in notifications:
            issue = open_issues[details['id']]
            self.assertEqual(details['title'], issue.title)
            self.assertEqual(details['subject']['id'], issue.subject.id)
            self.assertEqual(details['subject']['type'], 'dataset')
Exemple #4
0
    def test_notify_user_issues(self):
        owner = UserFactory()
        dataset = DatasetFactory(owner=owner)

        open_issues = {}
        for i in range(3):
            user = UserFactory()
            message = Message(content=faker.sentence(), posted_by=user)
            issue = DatasetIssue.objects.create(
                subject=dataset,
                user=user,
                title=faker.sentence(),
                discussion=[message]
            )
            open_issues[issue.id] = issue

        # Creating a closed issue that shouldn't show up in response.
        user = UserFactory()
        message = Message(content=faker.sentence(), posted_by=user)
        DatasetIssue.objects.create(
            subject=dataset,
            user=user,
            title=faker.sentence(),
            discussion=[message],
            closed=datetime.now(),
            closed_by=user
        )

        notifications = issues_notifications(owner)

        self.assertEqual(len(notifications), len(open_issues))

        for dt, details in notifications:
            issue = open_issues[details['id']]
            self.assertEqual(details['title'], issue.title)
            self.assertEqual(details['subject']['id'], issue.subject.id)
            self.assertEqual(details['subject']['type'], 'dataset')