Пример #1
0
    def test_defaults_for(self, command_type, data_type, expected_defaults):
        config = Configuration.create("acct:[email protected]", 2)

        config.raw["defaults"] = [
            ["*", "*", {
                "a": 1,
                "last": "wild"
            }],
            ["create", "*", {
                "b": 2,
                "last": "command"
            }],
            ["*", "user", {
                "c": 3,
                "last": "data"
            }],
            ["create", "user", {
                "d": 4,
                "last": "both"
            }],
        ]

        defaults = config.defaults_for(command_type, data_type)

        assert defaults == expected_defaults
Пример #2
0
    def test_accessors(self):
        config = Configuration.create(effective_user="******",
                                      total_instructions=100)

        assert config.view is ViewType.NONE
        assert config.effective_user == "acct:[email protected]"
        assert config.total_instructions == 100
Пример #3
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)
Пример #4
0
 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
             )
         )
Пример #5
0
    def body(self):
        """
        Get the body of this command.

        :return: A Configuration object
        """
        return Configuration(self.raw[1])
Пример #6
0
    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
Пример #7
0
    def configure(cls, effective_user, total_instructions, view=ViewType.NONE):
        """
        Create a configuration command.

        :param effective_user: The user to execute actions as
        :param total_instructions: The total number of instructions
        :rtype: ConfigCommand
        """
        return ConfigCommand.create(
            Configuration.create(effective_user, total_instructions, view=view),
        )
Пример #8
0
    def test_create(self):
        config = Configuration.create(effective_user="******",
                                      total_instructions="100")

        assert isinstance(config, Configuration)

        assert config.raw == {
            "view":
            None,
            "user": {
                "effective": "acct:[email protected]"
            },
            "instructions": {
                "total": 100
            },
            "defaults": [
                ["create", "*", {
                    "on_duplicate": "continue"
                }],
                ["upsert", "*", {
                    "merge_query": True
                }],
            ],
        }
Пример #9
0
    def test_from_raw(self, configuration_body):
        config = Configuration(configuration_body)

        assert isinstance(config, Configuration)
        assert config.raw == configuration_body
Пример #10
0
 def test_we_apply_the_schema(self):
     with pytest.raises(SchemaValidationError):
         Configuration.create("wrong_user_format", 100)
Пример #11
0
    def test_create(self, configuration_body):
        command = ConfigCommand.create(Configuration(configuration_body))

        self._check_command(command, configuration_body)