예제 #1
0
	def test_exact_type(self):
		"""
		test an exact name search with filetype included
		"""
		actual_output = find_packaged.process_args(['/tmp/', '-e', 'gray', '-t', 'f'])
		expected_output = "/tmp/foodir/gray\n"
		self.assertEqual(actual_output.getvalue(), expected_output)
예제 #2
0
	def test_process_args_exact(self):
		"""
		tests that an exact name search works all the way through
		"""
		actual_output = find_packaged.process_args(['/tmp/', '-e', 'foo'])
		self.assertEqual(actual_output.getvalue(),"/tmp/foodir/nested_dir/foo\n")
		actual_output.close()
예제 #3
0
	def test_bad_path_given(self):
		"""
		tests that a bad path reverts to the current working directory
		"""
		actual_output = find_packaged.process_args(['/some/path/doesnt/exist/', '-e', 'stirfry'])
		self.assertEqual(actual_output.getvalue(), "")
		actual_output.close()
예제 #4
0
	def test_regex_filetype(self):
		"""
		tests that regex works with filetype matching
		"""
		actual_output = find_packaged.process_args(['/tmp/', '-r', 'notok', '-t', 'd'])
		expected_output = "/tmp/notok\n"
		self.assertEqual(actual_output.getvalue(), expected_output)
		actual_output.close()
예제 #5
0
	def test_process_args_regex(self):
		"""
		tests that a regexed name search works all the way through
		"""
		actual_output = find_packaged.process_args(['/tmp', '-r', 'notok'])
		expected_value = "/tmp/notok\n"
		self.assertEqual(actual_output.getvalue(), expected_value)
		actual_output.close()
예제 #6
0
	def test_glob_type(self):
		"""
		test that filetype matching works with fnmatching
		"""
		actual_output = find_packaged.process_args(['/tmp/', '-n', '*foo*', '-t', 'd'])
		expected_value = "/tmp/foodir\n/tmp/foodir/nested_dir/nested_foodir\n"
		self.assertEqual(actual_output.getvalue(), expected_value)
		actual_output.close()
예제 #7
0
	def test_process_args_glob(self):
		"""
		tests that a fnmatched name search works all the way through
		"""
		actual_output = find_packaged.process_args(['/tmp','-n','n?t_valid'])
		expected_value = "/tmp/foodir/not_valid\n"
		self.assertEqual(actual_output.getvalue(), expected_value)
		actual_output.close()
예제 #8
0
	def test_only_path_given(self):
		"""
		tests that one search type must be provided
		"""
		try:
			out = find_packaged.process_args(['/tmp'])
			assert False
		except:
			assert True
예제 #9
0
	def test_multiple_exclusive_options(self):
		"""
		tests that user can't provide multiple search types
		"""
		try:
			out = find_packaged.process_args(['/tmp/', '-e', 'foo', '-n', 'f?o'])
			assert False
		except:
			assert True
예제 #10
0
	def test_no_args_given(self):
		"""
		tests that an error is raised when no args are provided
		"""
		try:
			out = find_packaged.process_args([])
			assert False
		except:
			assert True
예제 #11
0
	def test_bad_arg(self):
		"""
		tests that a bad arg throws some sort of exception
		it's an inelegant solution, but it works.
		"""
		try:
			actual_output = find_packaged.process_args(['/tmp/', '-e', 'foodir', '-stirfry'])
			assert False
		except:
			assert True