DatGuy1 / Windows-Toasts

Python library used to send toast notifications on Windows machines
Apache License 2.0
90 stars 6 forks source link

Make test for custom ToastActivatedEventArgs dataclass #8

Open DatGuy1 opened 2 years ago

DatGuy1 commented 2 years ago

Something like this:

def test_activation_args():
    from winsdk.windows.foundation import PropertyValue
    from winsdk.windows.foundation.collections import ValueSet
    from winsdk.windows.ui.notifications import ToastActivatedEventArgs as WinRtToastActivatedEventArgs

    userInput = ValueSet()
    userInput.insert("textBox", PropertyValue.create_string("World, Hello!"))

    rawEventArgs = ValueSet()
    rawEventArgs.insert("arguments", PropertyValue.create_string("test=yes"))
    rawEventArgs.insert("user_input", userInput)

    eventArgs = WinRtToastActivatedEventArgs._from(rawEventArgs)
    parsedArgs = ToastActivatedEventArgs.fromWinRt(eventArgs)

    assert parsedArgs.arguments == "test=yes"
    assert parsedArgs.input == "World, Hello!"

Issue is I don't know what type rawEventArgs should be. The _from(rawEventArgs) statement leads to OSError: [WinError -2147467262] No such interface supported.

DatGuy1 commented 5 months ago

Could be solved by https://github.com/pywinrt/pywinrt/commit/d3b55413a2d102bc2cb864aae340fe4487b3a157. Pending wheel release to check.