Exemple #1
0
    def from_data(cls, raw):
        """Create a command from a raw data structure.

        :param raw: The data to decode
        :returns: An appropriate child of `Command`
        """

        command = Command(raw)

        if command.type is CommandType.CONFIGURE:
            return ConfigCommand(raw)

        if command.type is CommandType.CREATE:
            return CreateCommand(raw)

        elif command.type is CommandType.UPSERT:
            return UpsertCommand(raw)
Exemple #2
0
    def test_create(self, upsert_user_body):
        command = Command.create(CommandType.CREATE, UpsertUser(upsert_user_body))

        self._check_command(command, upsert_user_body)
Exemple #3
0
 def test_we_apply_validation(self, raw):
     with pytest.raises(SchemaValidationError):
         Command(raw)
Exemple #4
0
    def test_from_raw(self, upsert_user_body):
        command = Command([CommandType.CREATE.value, upsert_user_body])

        self._check_command(command, upsert_user_body)