Example #1
0
	def testMain(self):
		def has_text(text):
			# create the actual check function
			def my_has_text(dialog):
				self.assertIsInstance(dialog, QuickNoteDialog)
				buffer = dialog.textview.get_buffer()
				result = buffer.get_text(*buffer.get_bounds())
				#~ print result
				self.assertTrue(text in result)

			return my_has_text

		# Text on commandline
		text = 'foo bar baz\ndus 123'
		with tests.DialogContext(has_text(text)):
			main('text=' + text)

		# Clipboard input
		text = 'foo bar baz\ndus 123'
		SelectionClipboard.clipboard.clear() # just to be sure
		Clipboard.set_text(text)
		with tests.DialogContext(has_text(text)):
			main('input=clipboard')

		text = 'foo bar baz\ndus 456'
		SelectionClipboard.set_text(text)
		with tests.DialogContext(has_text(text)):
			main('input=clipboard')
Example #2
0
	def testMain(self):
		# Text on commandline
		text = 'foo bar baz\ndus 123'
		self.assertRun(('text=' + text,), text)
		self.assertRun(('--text', text), text)

		encoded = 'Zm9vIGJhciBiYXoKZHVzIDEyMwo='
		self.assertRun(('--text', encoded, '--encoding', 'base64'), text)

		encoded = 'foo%20bar%20baz%0Adus%20123'
		self.assertRun(('--text', encoded, '--encoding', 'url'), text)

		# Clipboard input
		text = 'foo bar baz\ndus 123'
		SelectionClipboard.clipboard.clear() # just to be sure
		Clipboard.set_text(text)
		self.assertRun(('input=clipboard',), text)
		self.assertRun(('--input', 'clipboard',), text)

		text = 'foo bar baz\ndus 456'
		SelectionClipboard.set_text(text)
		self.assertRun(('input=clipboard',), text)
		self.assertRun(('--input', 'clipboard',), text)

		# Template options
		cmd = QuickNotePluginCommand('quicknote')
		cmd.parse_options('option:url=foo')
		self.assertEqual(cmd.template_options, {'url': 'foo'})

		cmd = QuickNotePluginCommand('quicknote')
		cmd.parse_options('--option', 'url=foo')
		self.assertEqual(cmd.template_options, {'url': 'foo'})
Example #3
0
	def testMain(self):
		def main(*args):
			cmd = QuickNotePluginCommand('quicknote')
			cmd.parse_options(*args)
			cmd.run()

		def has_text(text):
			# create the actual check function
			def my_has_text(dialog):
				self.assertIsInstance(dialog, QuickNoteDialog)
				buffer = dialog.textview.get_buffer()
				result = buffer.get_text(*buffer.get_bounds())
				self.assertTrue(text in result)

			return my_has_text

		# Text on commandline
		text = 'foo bar baz\ndus 123'
		with tests.DialogContext(has_text(text)):
			main('text=' + text)

		with tests.DialogContext(has_text(text)):
			main('--text', text)

		encoded = 'Zm9vIGJhciBiYXoKZHVzIDEyMwo='
		with tests.DialogContext(has_text(text)):
			main('--text', encoded, '--encoding', 'base64')

		encoded = 'foo%20bar%20baz%0Adus%20123'
		with tests.DialogContext(has_text(text)):
			main('--text', encoded, '--encoding', 'url')

		# Clipboard input
		text = 'foo bar baz\ndus 123'
		SelectionClipboard.clipboard.clear() # just to be sure
		Clipboard.set_text(text)
		with tests.DialogContext(has_text(text)):
			main('input=clipboard')

		with tests.DialogContext(has_text(text)):
			main('--input', 'clipboard')

		text = 'foo bar baz\ndus 456'
		SelectionClipboard.set_text(text)
		with tests.DialogContext(has_text(text)):
			main('input=clipboard')

		with tests.DialogContext(has_text(text)):
			main('--input', 'clipboard')

		# Template options
		cmd = QuickNotePluginCommand('quicknote')
		cmd.parse_options('option:url=foo')
		self.assertEqual(cmd.template_options, {'url': 'foo'})

		cmd = QuickNotePluginCommand('quicknote')
		cmd.parse_options('--option', 'url=foo')
		self.assertEqual(cmd.template_options, {'url': 'foo'})
Example #4
0
    def testMain(self):
        def main(*args):
            cmd = QuickNotePluginCommand('quicknote')
            cmd.parse_options(*args)
            cmd.run()

        def has_text(text):
            # create the actual check function
            def my_has_text(dialog):
                self.assertIsInstance(dialog, QuickNoteDialog)
                buffer = dialog.textview.get_buffer()
                result = buffer.get_text(*buffer.get_bounds())
                self.assertTrue(text in result)

            return my_has_text

        # Text on commandline
        text = 'foo bar baz\ndus 123'
        with tests.DialogContext(has_text(text)):
            main('text=' + text)

        with tests.DialogContext(has_text(text)):
            main('--text', text)

        encoded = 'Zm9vIGJhciBiYXoKZHVzIDEyMwo='
        with tests.DialogContext(has_text(text)):
            main('--text', encoded, '--encoding', 'base64')

        encoded = 'foo%20bar%20baz%0Adus%20123'
        with tests.DialogContext(has_text(text)):
            main('--text', encoded, '--encoding', 'url')

        # Clipboard input
        text = 'foo bar baz\ndus 123'
        SelectionClipboard.clipboard.clear()  # just to be sure
        Clipboard.set_text(text)
        with tests.DialogContext(has_text(text)):
            main('input=clipboard')

        with tests.DialogContext(has_text(text)):
            main('--input', 'clipboard')

        text = 'foo bar baz\ndus 456'
        SelectionClipboard.set_text(text)
        with tests.DialogContext(has_text(text)):
            main('input=clipboard')

        with tests.DialogContext(has_text(text)):
            main('--input', 'clipboard')

        # Template options
        cmd = QuickNotePluginCommand('quicknote')
        cmd.parse_options('option:url=foo')
        self.assertEqual(cmd.template_options, {'url': 'foo'})

        cmd = QuickNotePluginCommand('quicknote')
        cmd.parse_options('--option', 'url=foo')
        self.assertEqual(cmd.template_options, {'url': 'foo'})