Beispiel #1
0
 def setUp(self):
     super(PagesAsLibrarianTests, self).setUp()
     # change user group to belong to Librarian group
     self.user.groups.clear()
     self.group = modelfactories.GroupFactory(name="Librarian")
     self.user.groups.add(self.group)
     self.user.save()
Beispiel #2
0
    def setUp(self):
        # create librarian group and those members
        self.librarian_group = modelfactories.GroupFactory(name="Librarian")
        self.librarian1 = auth.UserF(is_active=True)
        self.librarian2 = auth.UserF(is_active=True)

        self.librarian1.groups.add(self.librarian_group)
        self.librarian1.save()

        self.librarian2.groups.add(self.librarian_group)
        self.librarian2.save()

        self.collection = modelfactories.CollectionFactory.create()
        self.editor = auth.UserF(is_active=True)
        self.journal = modelfactories.JournalFactory.create(editor=self.editor)
        self.issue = modelfactories.IssueFactory(journal=self.journal)
        self.board = editorial_modelfactories.EditorialBoardFactory.create(issue=self.issue)
        self.member = editorial_modelfactories.EditorialMemberFactory.create(board=self.board)

        # link journal to collection
        jmodels.Membership.objects.create(journal=self.journal, collection=self.collection, created_by=auth.UserF(is_active=True))

        # link librarians and collection
        self.collection.add_user(self.librarian1)
        self.collection.add_user(self.librarian2)

        self.expected_recipients = []
        self.expected_bcc_recipients = [self.librarian1.email, self.librarian2.email, ]
        self.expected_subject_sufix_by_action = {
            'board_add_member': "Member of the journal board, was added",
            'board_edit_member': "Member of the journal board, was edited",
            'board_delete_member': "Member of the journal board, was deleted",
        }
Beispiel #3
0
    def test_get_users_by_group_by_collections_only_one_user_match(self):
        # with:
        # create librarian group and those members
        group_name = "Librarian"
        librarian_group = modelfactories.GroupFactory(name=group_name)
        librarian1 = auth.UserF(is_active=True)
        librarian2 = auth.UserF(is_active=True)

        librarian1.groups.add(librarian_group)
        librarian1.save()

        librarian2.groups.add(librarian_group)
        librarian2.save()

        # create col1. user: librarian1 belongs to it
        col1 = modelfactories.CollectionFactory.create()
        col1.add_user(librarian1)
        # create col2. without users.
        col2 = modelfactories.CollectionFactory.create()

        # when:
        users = get_users_by_group_by_collections(group_name, [
            col1,
            col2,
        ])
        # then:
        self.assertEqual(1, len(users))
        self.assertIn(librarian1, users)
        self.assertNotIn(librarian2, users)
Beispiel #4
0
    def setUp(self):
        # create a group 'Librarian'
        self.group = modelfactories.GroupFactory(name="Librarian")
        # create a user and set group 'Librarian'
        self.user = modelfactories.UserFactory(is_active=True)
        self.user.groups.add(self.group)
        self.user.save()

        self.collection = modelfactories.CollectionFactory.create()
        self.collection.add_user(self.user, is_manager=False)
        self.collection.make_default_to_user(self.user)

        self.journal = modelfactories.JournalFactory.create()
        self.journal.join(self.collection, self.user)

        # create an issue
        self.issue = modelfactories.IssueFactory.create()
        self.issue.journal = self.journal
        self.journal.save()
        self.issue.save()
Beispiel #5
0
    def setUp(self):
        # create a group 'Editors'
        group = modelfactories.GroupFactory(name="Editors")
        # create a user and set group 'Editors'
        self.user = modelfactories.UserFactory(is_active=True)
        self.user.groups.add(group)

        self.collection = modelfactories.CollectionFactory.create()
        self.collection.add_user(self.user, is_manager=False)
        self.collection.make_default_to_user(self.user)

        self.journal = modelfactories.JournalFactory.create()
        self.journal.join(self.collection, self.user)

        # set the user as editor of the journal
        self.journal.editor = self.user

        # create an issue
        self.issue = modelfactories.IssueFactory.create()
        self.issue.journal = self.journal
        self.journal.save()
        self.issue.save()
Beispiel #6
0
    def test_get_users_by_group_by_collections_NO_collections(self):
        # with:
        # create librarian group and those members
        group_name = "Librarian"
        librarian_group = modelfactories.GroupFactory(name=group_name)
        librarian1 = auth.UserF(is_active=True)
        librarian2 = auth.UserF(is_active=True)

        librarian1.groups.add(librarian_group)
        librarian1.save()

        librarian2.groups.add(librarian_group)
        librarian2.save()

        # collection list is an empty list

        # when:
        users = get_users_by_group_by_collections(group_name, [])
        # then:
        self.assertEqual(0, len(users))
        self.assertNotIn(librarian1, users)
        self.assertNotIn(librarian2, users)