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)
def test_create(self, upsert_user_body): command = Command.create(CommandType.CREATE, UpsertUser(upsert_user_body)) self._check_command(command, upsert_user_body)
def test_we_apply_validation(self, raw): with pytest.raises(SchemaValidationError): Command(raw)
def test_from_raw(self, upsert_user_body): command = Command([CommandType.CREATE.value, upsert_user_body]) self._check_command(command, upsert_user_body)