def testInvalidAtribbute(self): schemaWithInvalidAttribute = [('endereço', 'atributo invalido', 'one'), ('telefone', 'atributo invalido', 'many') ] with self.assertRaises(Exception): process(self.facts, schemaWithInvalidAttribute)
def testInvalidAtribbuteValue(self): schemaWithInvalidAttributeValue = [ ('endereço', 'cardinality', 'valor invalido'), ('telefone', 'cardinality', 'valor invalido') ] with self.assertRaises(Exception): process(self.facts, schemaWithInvalidAttributeValue)
def main(): # get raw input from file inputFile = codecs.open("input", 'r') inputData = inputFile.readlines() # process data dataProcessor.process(inputData) emails = dataProcessor.getEmails(inputData) excludes = dataProcessor.getExcludes(inputData) # create pairs pairs = santaManager.randomize(emails, excludes) # send appropiate emails for pair in pairs: emailSender.sendSantaMail(pair) # save log file on smpt server logger.saveResultOnServer(pairs, emails, excludes)
def testBasicScenario(self): expectedResult = [('gabriel', 'endereço', 'av rio branco, 109', True), ('joão', 'endereço', 'rua bob, 88', True), ('joão', 'telefone', '91234-5555', True), ('gabriel', 'telefone', '98888-1111', True), ('gabriel', 'telefone', '56789-1010', True)] result = process(self.facts, self.schema) self.assertEqual(result, expectedResult)
def testAllFactsFalse(self): facts = [('gabriel', 'endereço', 'av rio branco, 109', False), ('joão', 'endereço', 'rua alice, 10', False), ('joão', 'endereço', 'rua bob, 88', False), ('joão', 'telefone', '234-5678', False), ('joão', 'telefone', '91234-5555', False), ('joão', 'telefone', '234-5678', False), ('gabriel', 'telefone', '98888-1111', False), ('gabriel', 'telefone', '56789-1010', False)] schema = [('endereço', 'cardinality', 'one'), ('telefone', 'cardinality', 'many')] expectedResult = [] result = process(facts, schema) self.assertEqual(result, expectedResult)
def testInvalidParameter(self): invalidFacts = 'facts' invalidSchema = 'schema' with self.assertRaises(TypeError): process(invalidFacts, invalidSchema) with self.assertRaises(TypeError): process(self.facts, invalidSchema) with self.assertRaises(TypeError): process(invalidFacts, self.schema)
from dataProcessor import process facts = [('gabriel', 'endereço', 'av rio branco, 109', True), ('joão', 'endereço', 'rua alice, 10', True), ('joão', 'endereço', 'rua bob, 88', True), ('joão', 'telefone', '234-5678', True), ('joão', 'telefone', '91234-5555', True), ('joão', 'telefone', '234-5678', False), ('gabriel', 'telefone', '98888-1111', True), ('gabriel', 'telefone', '56789-1010', True)] schema = [('endereço', 'cardinality', 'one'), ('telefone', 'cardinality', 'many')] print(process(facts, schema))
def testInvalidAttributeName(self): schemaWithInvalidType = [('tipo invalido', 'cardinality', 'one'), ('tipo invalido2', 'cardinality', 'many')] with self.assertRaises(Exception): process(self.facts, schemaWithInvalidType)