Exemplo n.º 1
0
    def loadCurrentPelicula(self):
        if self.currentPelicula is None:
            return
        locked = False
        try:
            gtk.gdk.threads_enter()
            locked = True
            self.txtTitulo.set_text(self.currentPelicula.titulo)
            self.spbDuracion.set_value(int(self.currentPelicula.duracion))
            self.btnFechaEstreno.set_label(self.currentPelicula.fechaEstreno)
            self.txtUrlPelicula.set_text(self.currentPelicula.urlPelicula)
            self.txtImagenPelicula.set_text(self.currentPelicula.urlImagen)

            self.lstCompanias.get_model().clear()
            for compania in self.currentPelicula.companias:
                self.lstCompanias.get_model().append([compania.nombre])

            self.lstGeneros.get_model().clear()
            for genero in self.currentPelicula.generos:
                self.lstGeneros.get_model().append([genero.nombre])

            self.lstReparto.get_model().clear()
            gtk.gdk.threads_leave()
            locked = False
            client = MovieClient()
            for reparto in self.currentPelicula.reparto:
                try:
                    actor = client.obtenActor(reparto.idActor)
                    gtk.gdk.threads_enter()
                    locked = True
                    self.lstReparto.get_model().append(
                        [reparto.papel, actor.nombre])
                except:
                    pass
                finally:
                    if locked:
                        gtk.gdk.threads_leave()
                        locked = False
        finally:
            if locked:
                gtk.gdk.threads_leave()
Exemplo n.º 2
0
    def loadCurrentPelicula(self):
        if self.currentPelicula is None:
            return
        locked = False
        try:
            gtk.gdk.threads_enter()
            locked = True
            self.txtTitulo.set_text(self.currentPelicula.titulo)
            self.spbDuracion.set_value(int(self.currentPelicula.duracion))
            self.btnFechaEstreno.set_label(self.currentPelicula.fechaEstreno)
            self.txtUrlPelicula.set_text(self.currentPelicula.urlPelicula)
            self.txtImagenPelicula.set_text(self.currentPelicula.urlImagen)

            self.lstCompanias.get_model().clear()
            for compania in self.currentPelicula.companias:
                self.lstCompanias.get_model().append([compania.nombre])

            self.lstGeneros.get_model().clear()
            for genero in self.currentPelicula.generos:
                self.lstGeneros.get_model().append([genero.nombre])

            self.lstReparto.get_model().clear()
            gtk.gdk.threads_leave()
            locked = False
            client = MovieClient()
            for reparto in self.currentPelicula.reparto:
                try:
                    actor = client.obtenActor(reparto.idActor)
                    gtk.gdk.threads_enter()
                    locked = True
                    self.lstReparto.get_model().append(
                        [reparto.papel, actor.nombre])
                except:
                    pass
                finally:
                    if locked:
                        gtk.gdk.threads_leave()
                        locked = False
        finally:
            if locked:
                gtk.gdk.threads_leave()
Exemplo n.º 3
0
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")
Exemplo n.º 4
0
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")
Exemplo n.º 5
0
    def run(self):
        locked = False
        try:
            client = MovieClient()
            gtk.gdk.threads_enter()
            locked = True
            idMessage = self.gui.pushMessage(
                "Obteniendo informacion del actor")
            gtk.gdk.threads_leave()
            locked = False
            self.gui.currentActor = client.obtenActor(self.actor.id)
            gtk.gdk.threads_enter()
            locked = True
            self.gui.popMessage(idMessage)
            self.gui.loadCurrentActor()
            gtk.gdk.threads_leave()
            locked = False
            self.gui.loadUrlImage(
                self.gui.imgActor,
                self.gui.currentActor.urlImagen,
                300)
            gtk.gdk.threads_enter()
            locked = True
            self.gui.frmDetallesActor.set_sensitive(True)
            gtk.gdk.threads_leave()
            locked = False

        except Exception as error:
            print "CargadorActor::run" + str(error)
        finally:
            if locked:
                gtk.gdk.threads_leave()
            gtk.gdk.threads_enter()
            self.gui.btnSeleccionarActor.set_sensitive(True)
            self.gui.btnBuscarActor.set_sensitive(True)
            gtk.gdk.threads_leave()
            locked = False
Exemplo n.º 6
0
 def test_obtenActor_1231(self, mock_read):
     cliente = MovieClient()
     mock_read.return_value = '{"id": "1", "place_of_birth" : "Veracruz","name" : "Juan Hebert", "homepage" : "", "birthday" : "1992-11-12", "deathday":"", "profile_path": ""}'
     actor = cliente.obtenActor(1231)
     self.assertEqual("Juan Hebert", actor.nombre)
     self.assertEqual("1992-11-12", actor.fechaNacimiento)
Exemplo n.º 7
0
def when_se_obtiene_actor(step):
    client = MovieClient()
    world.resultado = client.obtenActor(world.Id)
Exemplo n.º 8
0
def when_se_obtiene_actor(step):
    client = MovieClient()
    world.resultado = client.obtenActor(world.Id)