Beispiel #1
0
 def save_entries(self, entries):
     self.rdb.delete(self.SCHEDULE_KEY)
     if entries:
         self.rdb.hmset(self.SCHEDULE_KEY, {
             name: json.dumps(
                 serializer.serialize_entry(entry)
             ) for name, entry in entries.items()
         })
def test_serialize_deserialize_entry(dt):
    entry = ScheduleEntry(
        name='entry-1',
        task='entry-1-task',
        schedule=dt,
        args=('arg1', 'arg2'),
        kwargs={
            'key1': 'val1',
            'key2': 'val2'
        },
        last_run_at=datetime.now(),
        total_run_count=1,
        options={},
    )

    decoded_entry = deserialize_entry(serialize_entry(entry))

    assert decoded_entry.__reduce__() == entry.__reduce__()
def test_serialize_entry_json_serializable(dt):
    entry = ScheduleEntry(
        name='entry-1',
        task='entry-1-task',
        schedule=dt,
        args=('arg1', 'arg2'),
        kwargs={
            'key1': 'val1',
            'key2': 'val2'
        },
        last_run_at=datetime.now(),
        total_run_count=1,
        options={},
    )

    obj = serialize_entry(entry)

    try:
        json.dumps(obj)
    except Exception as e:
        pytest.fail(e)
Beispiel #4
0
 def save_entries(self, entries):
     self.client.set(self.SCHEDULE_KEY, {
         name: serializer.serialize_entry(entry)
         for name, entry in entries.items()
     })