Ejemplo n.º 1
0
    def test_06_status_is_countable(self):
        counter = reporting.StatusCounter("month")

        # We now disregard role and count all completion events per user https://github.com/DOAJ/doaj/issues/1385
        admin_accepted = models.Provenance(user="******", roles=["admin", "editor", "associate_editor"], action="status:accepted")
        assert counter._is_countable(admin_accepted, "admin")
        assert counter._is_countable(admin_accepted, "editor")
        assert counter._is_countable(admin_accepted, "associate_editor")
        assert counter._is_countable(admin_accepted, "api")

        admin_rejected = models.Provenance(user="******", roles=["admin", "editor", "associate_editor"], action="status:rejected")
        assert counter._is_countable(admin_rejected, "admin")
        assert counter._is_countable(admin_rejected, "editor")
        assert counter._is_countable(admin_rejected, "associate_editor")
        assert counter._is_countable(admin_rejected, "api")

        editor_ready = models.Provenance(user="******", roles=["editor", "associate_editor"], action="status:ready")
        assert counter._is_countable(editor_ready, "editor")
        assert counter._is_countable(editor_ready, "admin")
        assert counter._is_countable(editor_ready, "associate_editor")
        assert counter._is_countable(editor_ready, "api")

        assed_completed = models.Provenance(user="******", roles=["associate_editor"], action="status:completed")
        assert counter._is_countable(assed_completed, "associate_editor")
        assert counter._is_countable(assed_completed, "admin")
        assert counter._is_countable(assed_completed, "editor")
        assert counter._is_countable(assed_completed, "api")

        other = models.Provenance(user="******", roles=["admin", "editor", "associate_editor"], action="status:other")
        assert not counter._is_countable(other, "associate_editor")
        assert not counter._is_countable(other, "admin")
        assert not counter._is_countable(other, "editor")
        assert not counter._is_countable(other, "api")
Ejemplo n.º 2
0
    def test_26_provenance(self):
        """Read and write properties into the provenance model"""
        p = models.Provenance()

        # now construct from a fixture
        source = ProvenanceFixtureFactory.make_provenance_source()
        p = models.Provenance(**source)
        assert p is not None

        # run the remaining methods just to make sure there are no errors
        p.save()
Ejemplo n.º 3
0
    def test_27_save_valid_dataobj(self):
        j = models.Journal()
        bj = j.bibjson()
        bj.title = "A legitimate title"
        j.data["junk"] = "in here"
        with self.assertRaises(dataobj.DataStructureException):
            j.save()
        assert j.id is None

        s = models.Suggestion()
        sbj = s.bibjson()
        sbj.title = "A legitimate title"
        s.data["junk"] = "in here"
        with self.assertRaises(dataobj.DataStructureException):
            s.save()
        assert s.id is None

        p = models.Provenance()
        p.type = "suggestion"
        p.data["junk"] = "in here"
        with self.assertRaises(dataobj.DataStructureException):
            p.save()
        assert p.id is None