コード例 #1
0
    def test_it_raises_UnsupportedOperationError_for_invalid_actions(
        self, db_session, command_type, data_type, commands
    ):
        executor = BulkExecutor(db_session)

        with pytest.raises(UnsupportedOperationError):
            executor.execute_batch(command_type, data_type, commands, {})
コード例 #2
0
ファイル: _executor_test.py プロジェクト: zhujinlong/h
    def test_configure_looks_up_the_effective_user(self, db_session, user):
        executor = BulkExecutor(db_session)

        assert executor.effective_user_id is None

        executor.configure(
            Configuration.create(effective_user=user.userid,
                                 total_instructions=2))

        assert executor.effective_user_id == user.id
コード例 #3
0
ファイル: _executor_test.py プロジェクト: zhujinlong/h
 def test_configure_raises_if_the_effective_user_does_not_exist(
         self, db_session):
     with pytest.raises(InvalidDeclarationError):
         BulkExecutor(db_session).configure(
             Configuration.create(
                 effective_user="******",
                 total_instructions=2))
コード例 #4
0
    def test_it_calls_correct_db_handler(self, db_session, command_type,
                                         data_type, handler, commands):
        executor = BulkExecutor(db_session, authority=AUTHORITY)
        handler.assert_called_once_with(db_session)

        executor.effective_user_id = 1

        # These commands aren't actually the right type, but it doesn't
        # matter for this test
        executor.execute_batch(command_type, data_type, {"config_option": 2},
                               commands)

        bulk_upsert = handler.return_value
        bulk_upsert.execute.assert_called_once_with(commands,
                                                    effective_user_id=1,
                                                    config_option=2)
コード例 #5
0
 def test_it_raises_InvalidDeclarationError_with_called_with_non_lms_authority(
     self, command
 ):
     with pytest.raises(InvalidDeclarationError):
         BulkExecutor(sentinel.db).execute_batch(
             command.type, command.body.type, {}, [command]
         )
コード例 #6
0
    def test_it_raises_InvalidDeclarationError_with_non_lms_authority(self):
        config = Configuration.create(
            effective_user="******", total_instructions=2
        )

        with pytest.raises(InvalidDeclarationError):
            BulkExecutor(sentinel.db).configure(config)
コード例 #7
0
 def executor(self, db_session):
     return BulkExecutor(db_session, authority=AUTHORITY)