Esempio n. 1
0
    def test_reuse_metrics(self):
        dataset = VisibleDatasetFactory()
        reuse = VisibleReuseFactory()
        issue = IssueFactory(subject=reuse)
        DiscussionFactory(subject=reuse)

        reuse.count_datasets()
        reuse.count_issues()
        reuse.count_discussions()

        assert reuse.get_metrics()['datasets'] == 1
        assert reuse.get_metrics()['issues'] == 1
        assert reuse.get_metrics()['discussions'] == 1

        with assert_emit(Reuse.on_update):
            reuse.datasets.append(dataset)
            reuse.save()

        reuse.count_datasets()
        assert reuse.get_metrics()['datasets'] == 2

        dataset.count_reuses()
        assert dataset.get_metrics()['reuses'] == 1

        with assert_emit(Reuse.on_update):
            reuse.datasets.remove(dataset)
            reuse.save()

        dataset_tasks.update_datasets_reuses_metrics()
        dataset.reload()
        assert dataset.get_metrics()['reuses'] == 0
Esempio n. 2
0
    def test_reuse_metrics(self):
        reuse = VisibleReuseFactory()
        issue = IssueFactory(subject=reuse)
        DiscussionFactory(subject=reuse)

        reuse.count_datasets()
        reuse.count_issues()
        reuse.count_discussions()

        assert reuse.get_metrics()['datasets'] == 1
        assert reuse.get_metrics()['issues'] == 1
        assert reuse.get_metrics()['discussions'] == 1