@@ -2130,6 +2130,50 @@ def test_450_property_reset(self):
21302130 self .assertIsNone (value )
21312131 self .app .save .assert_called_once_with ()
21322132
2133+ def test_notes_get (self ):
2134+ notes = "For Your Eyes Only"
2135+ self .app .domains ["test-vm1" ].get_notes = unittest .mock .Mock ()
2136+ self .app .domains ["test-vm1" ].get_notes .configure_mock (
2137+ ** {"return_value" : notes }
2138+ )
2139+ value = self .call_mgmt_func (b"admin.vm.notes.Get" , b"test-vm1" )
2140+ self .assertEqual (value , notes )
2141+ self .app .domains ["test-vm1" ].get_notes .configure_mock (
2142+ ** {"side_effect" : Exception ()}
2143+ )
2144+ with self .assertRaises (qubes .exc .QubesException ):
2145+ self .call_mgmt_func (b"admin.vm.notes.Get" , b"test-vm1" )
2146+ self .assertEqual (
2147+ self .app .domains ["test-vm1" ].get_notes .mock_calls ,
2148+ [unittest .mock .call (), unittest .mock .call ()],
2149+ )
2150+ self .assertFalse (self .app .save .called )
2151+
2152+ def test_notes_set (self ):
2153+ self .app .domains ["test-vm1" ].set_notes = unittest .mock .Mock ()
2154+ with self .assertRaises (qubes .exc .ProtocolError ):
2155+ payload = ("x" * 256001 ).encode ()
2156+ self .call_mgmt_func (
2157+ b"admin.vm.notes.Set" ,
2158+ b"test-vm1" ,
2159+ payload = payload ,
2160+ )
2161+ with self .assertRaises (qubes .exc .QubesException ):
2162+ payload = "For Your Eyes Only" .encode ()
2163+ self .call_mgmt_func (
2164+ b"admin.vm.notes.Set" ,
2165+ b"test-vm1" ,
2166+ payload = payload ,
2167+ )
2168+ self .app .domains ["test-vm1" ].set_notes .configure_mock (
2169+ ** {"side_effect" : Exception ()}
2170+ )
2171+ self .call_mgmt_func (
2172+ b"admin.vm.notes.Set" ,
2173+ b"test-vm1" ,
2174+ payload = payload ,
2175+ )
2176+
21332177 def device_list_testclass (self , vm , event ):
21342178 if vm is not self .vm :
21352179 return
0 commit comments