Пример #1
0
 def __transform_output__(cls, data: RawDataType) -> RawDataType:
     enabled = data.pop("enabled")
     if enabled:
         return data
     else:
         # create a new instance (which uses the defaults) and return its data
         return convert_to_raw(cls())
def test_track_start_event_dump():
    # noinspection PyArgumentList
    data = TrackStartEvent("TrackStartEvent", 549905730099216384,
                           549904277108424715, "QAAAiwIAJ0x1aXMg")

    assert convert_to_raw(data) == {
        "type": "TrackStartEvent",
        "guildId": "549904277108424715",
        "userId": "549905730099216384",
        "track": "QAAAiwIAJ0x1aXMg"
    }
Пример #3
0
def test_convert_to_raw():
    inst = DataTest("test", NestedTest(5.5, 3))

    raw = convert_to_raw(inst)

    assert raw == {
        "helloWorld": "test",
        "nest": {
            "coolThing": 5500,
            "test": 3
        }
    }
Пример #4
0
def test_filter_map_from_raw():
    raw = {
        "karaoke": {
            "filterBand": 220.0,
            "filterWidth": 100.0,
            "level": 1.0,
            "monoLevel": 1.0
        }
    }
    f = build_from_raw(FilterMap, raw)

    assert f == FilterMap(dict(karaoke=Karaoke()))

    assert convert_to_raw(raw) == raw
def test_track_end_event_dump():
    # noinspection PyArgumentList
    data = TrackEndEvent("TrackEndEvent", 549905730099216384,
                         549904277108424715, "QAAAmAIANUFudWVsIEFBIC0gRW",
                         TrackEndReason.FINISHED, True)

    assert convert_to_raw(data) == {
        "type": "TrackEndEvent",
        "guildId": "549904277108424715",
        "userId": "549905730099216384",
        "track": "QAAAmAIANUFudWVsIEFBIC0gRW",
        "reason": "FINISHED",
        "mayStartNext": True
    }
Пример #6
0
def test_filter_map_to_raw():
    f = FilterMap({})
    f.set_filter(Karaoke())
    raw = convert_to_raw(f)

    assert raw == {
        "karaoke": {
            "filterBand": 220.0,
            "filterWidth": 100.0,
            "level": 1.0,
            "monoLevel": 1.0
        }
    }

    assert build_from_raw(FilterMap, raw) == f
def test_unknown_andesite_event():
    data = {
        "type": "SpecialEvent",
        "userId": "1231231231231",
        "guildId": "234234234234234",
        "a": 5,
        "b": 6,
    }
    data_copy = copy.deepcopy(data)
    data_copy_low = copy.deepcopy(data_copy)
    lettercase.mut_convert_keys(data_copy_low, None, "snake")

    evt = build_from_raw(UnknownAndesiteEvent, data)

    assert evt.body == data_copy_low

    new_data = convert_to_raw(evt)
    assert data_copy == new_data