Windows-Toasts
Windows-Toasts copied to clipboard
Make test for custom ToastActivatedEventArgs dataclass
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.
Could be solved by https://github.com/pywinrt/pywinrt/commit/d3b55413a2d102bc2cb864aae340fe4487b3a157. Pending wheel release to check.