Exemple #1
0
	def export(self):
		dir = Dir(create_tmp_dir('export_SourceFiles'))
		notebook = Notebook(dir=dir)
		for name, text in get_test_data('wiki'):
			page = notebook.get_page(Path(name))
			page.parse('wiki', text)
			notebook.store_page(page)
		file = dir.file('Test/foo.txt')
		self.assertTrue(file.exists())

		check_call(['python', './zim.py', '--export', '--template=Default', dir.path, '--output', self.dir.path])
Exemple #2
0
	def export(self):
		dir = Dir(self.create_tmp_dir('source_files'))
		init_notebook(dir)
		notebook = Notebook(dir=dir)
		for name, text in tests.WikiTestData:
			page = notebook.get_page(Path(name))
			page.parse('wiki', text)
			notebook.store_page(page)
		file = dir.file('Test/foo.txt')
		self.assertTrue(file.exists())

		zim = Application(('./zim.py', '--export', '--template=Default', dir.path, '--output', self.dir.path, '--index-page', 'index'))
		zim.run()
Exemple #3
0
    def export(self):
        dir = Dir(self.create_tmp_dir('source_files'))
        init_notebook(dir)
        notebook = Notebook(dir=dir)
        for name, text in tests.WikiTestData:
            page = notebook.get_page(Path(name))
            page.parse('wiki', text)
            notebook.store_page(page)
        file = dir.file('Test/foo.txt')
        self.assertTrue(file.exists())

        argv = ('./zim.py', '--export', '--template=Default', dir.path,
                '--output', self.dir.path, '--index-page', 'index')
        #~ zim = Application(argv)
        #~ zim.run()

        cmd = zim.main.build_command(argv[1:])
        cmd.run()
Exemple #4
0
    def runTest(self):
        '''Test synchronization'''
        # Test if zim detects pages, that where created with another
        # zim instance and transfered to this instance with
        # dropbox or another file synchronization tool.
        #
        # The scenario is as follow:
        # 1) Page.txt is created in this instance
        # 2) Page/Subpage.txt is created in another instance
        #    and copied into the notebook by the synchronization tool
        # 3) Zim runs a standard index update
        # Outcome should be that Page:Subpage shows up in the index

        # create notebook
        dir = Dir(self.create_tmp_dir())

        init_notebook(dir, name='foo')
        notebook = Notebook(dir=dir)
        index = notebook.index
        index.update()

        # add page in this instance
        path = Path('Page')
        page = notebook.get_page(path)
        page.parse('wiki', 'nothing important')
        notebook.store_page(page)

        # check file exists
        self.assertTrue(dir.file('Page.txt').exists())

        # check file is indexed
        self.assertTrue(page in list(index.list_all_pages()))

        # check attachment dir does not exist
        subdir = dir.subdir('Page')
        self.assertEqual(notebook.get_attachments_dir(page), subdir)
        self.assertFalse(subdir.exists())

        for newfile, newpath in (
            (subdir.file('NewSubpage.txt').path, Path('Page:NewSubpage')),
            (dir.file('Newtoplevel.txt').path, Path('Newtoplevel')),
            (dir.file('SomeDir/Dir/Newpage.txt').path,
             Path('SomeDir:Dir:Newpage')),
        ):
            # make sure ctime changed since last index
            import time
            time.sleep(2)

            # create new page without using zim classes
            self.assertFalse(os.path.isfile(newfile))

            mydir = os.path.dirname(newfile)
            if not os.path.isdir(mydir):
                os.makedirs(mydir)

            fh = open(newfile, 'w')
            fh.write('Test 123\n')
            fh.close()

            self.assertTrue(os.path.isfile(newfile))

            # simple index reload
            index.update()

            # check if the new page is found in the index
            self.assertTrue(newpath in list(index.list_all_pages()))
Exemple #5
0
	def runTest(self):
		'''Test synchronization'''
		# Test if zim detects pages, that where created with another
		# zim instance and transfered to this instance with
		# dropbox or another file synchronization tool.
		#
		# The scenario is as follow:
		# 1) Page.txt is created in this instance
		# 2) Page/Subpage.txt is created in another instance
		#    and copied into the notebook by the synchronization tool
		# 3) Zim runs a standard index update
		# Outcome should be that Page:Subpage shows up in the index

		# create notebook
		dir = Dir(self.create_tmp_dir())

		init_notebook(dir, name='foo')
		notebook = Notebook(dir=dir)
		index = notebook.index
		index.update()

		# add page in this instance
		path = Path('Page')
		page =  notebook.get_page(path)
		page.parse('wiki', 'nothing important')
		notebook.store_page(page)

		# check file exists
		self.assertTrue(dir.file('Page.txt').exists())

		# check file is indexed
		self.assertTrue(page in list(index.list_all_pages()))

		# check attachment dir does not exist
		subdir = dir.subdir('Page')
		self.assertEqual(notebook.get_attachments_dir(page), subdir)
		self.assertFalse(subdir.exists())

		for newfile, newpath in (
			(subdir.file('NewSubpage.txt').path, Path('Page:NewSubpage')),
			(dir.file('Newtoplevel.txt').path, Path('Newtoplevel')),
			(dir.file('SomeDir/Dir/Newpage.txt').path, Path('SomeDir:Dir:Newpage')),
		):
			# make sure ctime changed since last index
			import time
			time.sleep(2)

			# create new page without using zim classes
			self.assertFalse(os.path.isfile(newfile))

			mydir = os.path.dirname(newfile)
			if not os.path.isdir(mydir):
				os.makedirs(mydir)

			fh = open(newfile, 'w')
			fh.write('Test 123\n')
			fh.close()

			self.assertTrue(os.path.isfile(newfile))

			# simple index reload
			index.update()

			# check if the new page is found in the index
			self.assertTrue(newpath in list(index.list_all_pages()))