Example #1
0
def test_set_encoder_sets_the_global_encoder(pickle_encoder):
    # Given that I've set a Pickle encoder as the global encoder
    # When I get the global encoder
    encoder = remoulade.get_encoder()

    # Then it should be the same as the encoder that was set
    assert encoder == pickle_encoder
Example #2
0
 def decode(cls, data: bytes) -> 'ScheduledJob':
     data = get_encoder().decode(data)
     return ScheduledJob(
         actor_name=data["actor_name"],
         interval=data["interval"],
         daily_time=None if data["daily_time"] is None else
         datetime.datetime.strptime(data["daily_time"], '%H:%M:%S').time(),
         iso_weekday=data["iso_weekday"],
         enabled=data["enabled"],
         last_queued=None
         if data["last_queued"] is None else datetime.datetime.strptime(
             data["last_queued"], '%Y-%m-%dT%H:%M:%S'),
         tz=data["tz"],
         args=data["args"],
         kwargs=data["kwargs"])
Example #3
0
 def encode(self) -> bytes:
     return get_encoder().encode(self.as_dict())
Example #4
0
def pickle_encoder():
    old_encoder = remoulade.get_encoder()
    new_encoder = remoulade.PickleEncoder()
    remoulade.set_encoder(new_encoder)
    yield new_encoder
    remoulade.set_encoder(old_encoder)