diff --git a/cat_win/tests/src/service/test_clipboard.py b/cat_win/tests/src/service/test_clipboard.py index 20a1ad2..5477e6f 100644 --- a/cat_win/tests/src/service/test_clipboard.py +++ b/cat_win/tests/src/service/test_clipboard.py @@ -14,6 +14,11 @@ class TestClipboard(TestCase): maxDiff = None + def test_clipabord_clear(self): + Clipboard.clipboard = '42' + Clipboard.clear() + self.assertEqual(Clipboard.clipboard, '') + def test_put_cached(self): # the patch makes the copy_function not None with patch.object(Clipboard, 'copy_function') as mocka, patch.object(Clipboard, '_copy') as mockb: @@ -39,3 +44,29 @@ def test__copy_importerror(self): self.assertNotIn('ClipBoardError', fake_out.getvalue()) self.assertIn('ImportError', fake_out.getvalue()) self.assertIn("'--clip'", fake_out.getvalue()) + + def test_get_cached(self): + # the patch makes the copy_function not None + with patch.object(Clipboard, 'paste_function') as mocka, patch.object(Clipboard, '_paste') as mockb: + Clipboard.get() + mocka.assert_called_once() + mockb.assert_not_called() + + def test_get_not_cached(self): + with patch.object(Clipboard, '_paste') as mockb: + self.assertEqual(Clipboard.get(), None) + mockb.assert_called_once() + + def test__paste_clipboarderror(self): + with patch('sys.stderr', new=StdOutMock()) as fake_out: + Clipboard._paste(0, True) + self.assertIn('ClipBoardError', fake_out.getvalue()) + self.assertNotIn('ImportError', fake_out.getvalue()) + self.assertIn("'--clip'", fake_out.getvalue()) + + def test__paste_importerror(self): + with patch('sys.stderr', new=StdOutMock()) as fake_out: + Clipboard._paste( 0, False) + self.assertNotIn('ClipBoardError', fake_out.getvalue()) + self.assertIn('ImportError', fake_out.getvalue()) + self.assertIn("'--clip'", fake_out.getvalue())