def run(self): locked = False try: gtk.gdk.threads_enter() locked = True idMessage = self.gui.pushMessage("Buscando coincidiencias...") gtk.gdk.threads_leave() locked = False client = MovieClient() self.gui.peliculasReducidas = client.buscarPelicula(self.title, 1) gtk.gdk.threads_enter() locked = True for pelicula in self.gui.peliculasReducidas: self.gui.cmbResultadosPelicula.append_text(pelicula.titulo) self.gui.popMessage(idMessage) self.gui.btnBuscarPelicula.set_sensitive(True) gtk.gdk.threads_leave() locked = False except Exception as error: print "BuscadorPelicula::run::" + str(error) finally: if locked: gtk.gdk.threads_leave()
class TestMovieClient(unittest.TestCase): def setUp(self): unittest.TestCase.setUp(self) self.client = MovieClient() def test_obtenPelicula_22(self): pelicula = self.client.obtenPelicula(22) self.assertEqual("Pirates of the Caribbean: The Curse of the Black Pearl", pelicula.titulo) self.assertEqual(143, pelicula.duracion) def test_obtenActor_1231(self): actor = self.client.obtenActor(1231) self.assertEqual("Julianne Moore", actor.nombre) self.assertEqual("1960-12-03", actor.fechaNacimiento) def test_buscarActor_willsmith_1(self): resultados = self.client.buscarActor("will smith", 1) self.assertTrue(len(resultados) > 10) def test_buscarPelicula_jurassicpark_1(self): resultados = self.client.buscarPelicula("jurassic park", 1) self.assertTrue(len(resultados) == 6) def test_obtenReparto_22(self): resultados = self.client.obtenRepartoPelicula(22) self.assertTrue(len(resultados) > 0) johnny = resultados[0] self.assertEqual("Jack Sparrow", johnny.papel) def test_json(self): result = self.client.getJSON("api.themoviedb.org", "/3/?api_key=1") self.assertEqual('{"status_code":7,"status_message":"Invalid API key: You must be granted a valid key."}', result) def test_factory(self): result = factoryGenericObject({"hola" : "mundo"}) self.assertEqual(result.hola,"mundo")
class TestMovieClient(unittest.TestCase): def setUp(self): unittest.TestCase.setUp(self) self.client = MovieClient() def test_obtenPelicula_22(self): pelicula = self.client.obtenPelicula(22) self.assertEqual( "Pirates of the Caribbean: The Curse of the Black Pearl", pelicula.titulo) self.assertEqual(143, pelicula.duracion) def test_obtenActor_1231(self): actor = self.client.obtenActor(1231) self.assertEqual("Julianne Moore", actor.nombre) self.assertEqual("1960-12-03", actor.fechaNacimiento) def test_buscarActor_willsmith_1(self): resultados = self.client.buscarActor("will smith", 1) self.assertTrue(len(resultados) > 10) def test_buscarPelicula_jurassicpark_1(self): resultados = self.client.buscarPelicula("jurassic park", 1) self.assertTrue(len(resultados) == 6) def test_obtenReparto_22(self): resultados = self.client.obtenRepartoPelicula(22) self.assertTrue(len(resultados) > 0) johnny = resultados[0] self.assertEqual("Jack Sparrow", johnny.papel) def test_json(self): result = self.client.getJSON("api.themoviedb.org", "/3/?api_key=1") self.assertEqual( '{"status_code":7,"status_message":"Invalid API key: You must be granted a valid key."}', result) def test_factory(self): result = factoryGenericObject({"hola": "mundo"}) self.assertEqual(result.hola, "mundo")
def when_se_realiza_la_busqueda(step, method): client = MovieClient() if method == "actor": world.resultado = client.buscarActor(world.patron, 1) else: world.resultado = client.buscarPelicula(world.patron, 1)
def when_se_realiza_la_busqueda(step, method): client = MovieClient() if method == "actor": world.resultado = client.buscarActor(world.patron, 1) else: world.resultado = client.buscarPelicula(world.patron, 1)