def test_map_fields_csv_row(self): hit_template = HitTemplate( name='test', form=u"""</select> con relación a <span style="color: rgb(0, 0, 255);">${tweet0_entity}</span> en este mensaje.</p>""" ) hit_template.save() hit = Hit( template=hit_template, input_csv_fields=dict( zip( [u"tweet0_id", u"tweet0_entity"], [u"268", u"SANTOS"], ) ), ) hit.save() expect = """<div style=" width:100%; border:2px solid black; margin-top:10px"><div style="width:100%; margin:10px"></select> con relación a <span style="color: rgb(0, 0, 255);">SANTOS</span> en este mensaje.</p></div></div>""" actual = hit.generate_form() self.assertEqual(expect, actual)
class TestGenerateForm(django.test.TestCase): def setUp(self): with open('hits/tests/resources/form_0.html') as f: form = f.read().decode('utf-8') self.hit_template = HitTemplate(name="filepath", form=form) self.hit_template.save() field_names = u"tweet0_id,tweet0_entity,tweet0_before_entity,tweet0_after_entity,tweet0_word0,tweet0_word1,tweet0_word2,tweet1_id,tweet1_entity,tweet1_before_entity,tweet1_after_entity,tweet1_word0,tweet1_word1,tweet1_word2,tweet2_id,tweet2_entity,tweet2_before_entity,tweet2_after_entity,tweet2_word0,tweet2_word1,tweet2_word2,tweet3_id,tweet3_entity,tweet3_before_entity,tweet3_after_entity,tweet3_word0,tweet3_word1,tweet3_word2,tweet4_id,tweet4_entity,tweet4_before_entity,tweet4_after_entity,tweet4_word0,tweet4_word1,tweet4_word2,tweet5_id,tweet5_entity,tweet5_before_entity,tweet5_after_entity,tweet5_word0,tweet5_word1,tweet5_word2", values = u"268,SANTOS, Muy bien America ......... y lo siento mucho , un muy buen rival,mucho, , ,2472,GREGORY, Ah bueno , tampoco andes pidiendo ese tipo de milagros . @jcabrerac @CarlosCabreraR,bueno, , ,478,ALEJANDRO, @aguillen19 , un super abrazo mi querido , , mis mejores deseos para este 2012 ... muakkk !,querido, , ,906_control, PF, Acusan camioneros extorsiones de, : Transportistas acusaron que deben pagar entre 13 y 15 mil pesos a agentes que .. http://t.co/d8LUVvhP,acusaron, , ,2793_control, CHICARO, Me gusta cuando chicharo hace su oracion es lo que lo hace especial ., ,gusta, , ,357,OSCAR WILDE", " @ ifilosofia : Las pequeñas acciones de cada día son las que hacen o deshacen el carácter." , bueno !!!! Es así,bueno, , ", self.hit = Hit( template=self.hit_template, input_csv_fields=dict(zip(field_names, values)) ) self.hit.save() def test_generate_form(self): with open('hits/tests/resources/form_0_filled.html') as f: form = f.read().decode('utf-8') expect = form actual = self.hit.generate_form() self.assertNotEqual(expect, actual) def test_map_fields_csv_row(self): hit_template = HitTemplate( name='test', form=u"""</select> con relación a <span style="color: rgb(0, 0, 255);">${tweet0_entity}</span> en este mensaje.</p>""" ) hit_template.save() hit = Hit( template=hit_template, input_csv_fields=dict( zip( [u"tweet0_id", u"tweet0_entity"], [u"268", u"SANTOS"], ) ), ) hit.save() expect = """<div style=" width:100%; border:2px solid black; margin-top:10px"><div style="width:100%; margin:10px"></select> con relación a <span style="color: rgb(0, 0, 255);">SANTOS</span> en este mensaje.</p></div></div>""" actual = hit.generate_form() self.assertEqual(expect, actual)