Exemple #1
0
	def test_update_image_paths(self):
		os.mkdir('tmp')
		open('tmp/1.tmp', 'w').close()

		m = MonitorDirectory('tmp', image_extension='.tmp')
		open('tmp/2.tmp', 'w').close()
		open('tmp/3.tmp', 'w').close()
		new_image_paths = m.get_new_image_paths()
		m.update(new_image_paths)

		self.assertEquals(m.image_paths, set(['1.tmp', '2.tmp', '3.tmp']))

		new_image_paths = m.get_new_image_paths()

		self.assertTrue(len(new_image_paths)==0)

		[os.remove(i) for i in iglob('tmp/*.tmp')]
		os.rmdir('tmp')
Exemple #2
0
	def test_add_image_to_shared_folder(self):
		'''
		monitor file contents of a directory add a file and assert that in a call to new_image_paths = m.get_new_image_paths() new_image_paths contains the new file
		'''
		os.mkdir('tmp')
		m = MonitorDirectory('tmp', image_extension='.tmp')

		# create dummy file
		open('tmp/tmp.tmp', 'w').close()

		new_image_paths = m.get_new_image_paths()

		logger.info(new_image_paths)

		self.assertTrue('tmp.tmp' in new_image_paths)

		os.remove('tmp/tmp.tmp')
		os.rmdir('tmp')