Exemple #1
0
    def __init__(self, db, authority):
        """
        :param db: DB session object
        :param authority: Restrict all request to this authority
        """
        self.db = db
        self.authority = authority

        self.handlers = {
            (CommandType.UPSERT, DataType.USER): UserUpsertAction(self.db),
            (CommandType.UPSERT, DataType.GROUP): GroupUpsertAction(self.db),
            (
                CommandType.CREATE,
                DataType.GROUP_MEMBERSHIP,
            ): GroupMembershipCreateAction(self.db),
        }

        self.effective_user_id = None
Exemple #2
0
 def test_it_raises_conflict_with_bad_group_foreign_key(self, db_session, user):
     with pytest.raises(ConflictingDataError):
         GroupMembershipCreateAction(db_session).execute(
             [group_membership_create(user.id, 999999)]
         )
Exemple #3
0
 def test_it_fails_without_continue(self, db_session, commands):
     with pytest.raises(UnsupportedOperationError):
         GroupMembershipCreateAction(db_session).execute(
             commands, on_duplicate="fail"
         )
Exemple #4
0
    def test_it_can_insert_new_records(self, db_session, commands):
        reports = GroupMembershipCreateAction(db_session).execute(commands)

        assert reports == Any.iterable.comprised_of(Any.instance_of(Report)).of_size(3)

        self.assert_membership_matches_commands(db_session, commands)