Beispiel #1
0
	def test_process_line_with_id_in_API(self):
		test_processor = CSV_Processor("data-test-formatted.csv", "output.csv", False)
		test_processor._dest = cStringIO.StringIO()
		line = "lexcorp,Lex,2011-01-12,12345"
		columns = {'Account ID': 3, 'Created On': 2}
		test_processor._process_line(line, columns)
		self.assertEqual(test_processor._dest.getvalue(), "12345,2011-01-12,good,2011-01-12\n")
Beispiel #2
0
	def test_process_line_with_id_not_in_API(self):
		test_processor = CSV_Processor("data-test-formatted.csv", "output.csv", False)
		test_processor._dest = cStringIO.StringIO()
		line = "vanhalen,Eddie,1984-01-12,OU812"
		columns = {'Account ID': 3, 'Created On': 2}
		sys.stderr = cStringIO.StringIO()
		test_processor._process_line(line, columns)
		self.assertEqual(sys.stderr.getvalue(), "ID OU812 not found in API; skipped...\n")
Beispiel #3
0
	def test_process_file_without_account_id_column(self):
		"""
		No idea why this fails.
		"""
		test_processor = CSV_Processor("data-test-no-account-id.csv", "output.csv", False)
		test_processor._dest = cStringIO.StringIO()
		test_processor.process_file()
		self.assertRaises(ValueError)
Beispiel #4
0
	def test_process_file_without_created_on_column(self):
		"""
		This also barfs on the SystemExit call.
		"""
		test_processor = CSV_Processor("data-test-no-created-on.csv", "output.csv", False)
		test_processor._dest = cStringIO.StringIO()
		test_processor.process_file()
		self.assertRaises(ValueError)
Beispiel #5
0
	def test_process_correctly_formatted_file(self):
		test_processor = CSV_Processor("data-test-formatted.csv", "output.csv", False)
		test_processor._dest = cStringIO.StringIO()
		test_processor.process_file()
		self.assertEqual(test_processor._dest.getvalue(), "Account ID,Created On,Status,Status Set On\n12345,2011-01-12,good,2011-01-12\n")