def test_invalid_lines(self): importer = SimpleValidationsImporter( self.files['csv_invalid_cpf_sheet']) self.assertTrue(not importer.is_valid(), u"Should return False to is_valid()") for i in self.invalid_lines: self.assertEquals(False, importer._validation_results[i])
def test_invalid_errors_in_logging(self): importer = SimpleValidationsImporter( self.files['csv_invalid_cpf_sheet']) self.assertTrue(not importer.is_valid(), u"Should return False to is_valid()") self.assertTrue(importer.logger, u"Logger isn't set") self.assertEquals(self.logger_error_messages, importer.logger.handlers[0].messages['error'])
def test_invalid_errors(self): importer = SimpleValidationsImporter(self.files['csv_invalid_cpf_sheet']) self.assertTrue(not importer.is_valid(),u"Should return False to is_valid()") self.assertNotEquals(SortedDict(),importer.errors) # importer.errors shouldn't be empty for i in importer.errors: self.assertEquals(True,i in self.invalid_lines) for k,v in importer.errors[i].items(): self.assertEquals(True,k in self.invalid_lines[i]) self.assertEquals(self.invalid_lines[i][k],v)
def test_invalid_errors(self): importer = SimpleValidationsImporter( self.files['csv_invalid_cpf_sheet']) self.assertTrue(not importer.is_valid(), u"Should return False to is_valid()") self.assertNotEquals( SortedDict(), importer.errors) # importer.errors shouldn't be empty for i in importer.errors: self.assertEquals(True, i in self.invalid_lines) for k, v in importer.errors[i].items(): self.assertEquals(True, k in self.invalid_lines[i]) self.assertEquals(self.invalid_lines[i][k], v)
def test_mock_log_instance_handlers(self): """ Each time we call set_logger only one instance of handlers should exist. We should assert that only one instance of each handlers is live """ importer = SimpleValidationsImporter(self.files['csv_sheet']) instances = [] for i in importer.logger.handlers: self.assertTrue( i.__class__.__name__ not in instances, u"More than one logger with same class found in importer.logger.handlers" ) instances.append(i.__class__.__name__)
def test_simple_false_validation(self): importer = SimpleValidationsImporter( self.files['csv_invalid_cpf_sheet']) self.assertTrue(not importer.is_valid(), u"Should return False to is_valid()")
def test_mock_log_instance_handler(self): importer = SimpleValidationsImporter(self.files['csv_sheet']) self.assertTrue( isinstance(importer.logger.handlers[0], MockLoggingHandler))
def test_before_clean_errors(self): """ attr errors should be empty SortedDict """ importer = SimpleValidationsImporter(self.files['csv_sheet']) self.assertEquals(SortedDict(), importer.errors)
def test_before_clean__validation_results(self): """ attr __validation_results should be empty SortedDict """ importer = SimpleValidationsImporter(self.files['csv_sheet']) self.assertEquals(SortedDict(), importer._validation_results)
def test_invalid_errors_in_logging(self): importer = SimpleValidationsImporter(self.files['csv_invalid_cpf_sheet']) self.assertTrue(not importer.is_valid(),u"Should return False to is_valid()") self.assertTrue(importer.logger,u"Logger isn't set") self.assertEquals(self.logger_error_messages,importer.logger.handlers[0].messages['error'])
def test_invalid_lines(self): importer = SimpleValidationsImporter(self.files['csv_invalid_cpf_sheet']) self.assertTrue(not importer.is_valid(),u"Should return False to is_valid()") for i in self.invalid_lines: self.assertEquals(False,importer._validation_results[i])
def test_simple_false_validation(self): importer = SimpleValidationsImporter(self.files['csv_invalid_cpf_sheet']) self.assertTrue(not importer.is_valid(),u"Should return False to is_valid()")