示例#1
0
 def run(self):
     locked = False
     try:
         gtk.gdk.threads_enter()
         locked = True
         client = MovieClient()
         idMessage = self.gui.pushMessage(
             "Obteniendo informacion de la pelicula")
         gtk.gdk.threads_leave()
         locked = False
         self.gui.currentPelicula = client.obtenPelicula(self.pelicula.id)
         gtk.gdk.threads_enter()
         locked = True
         self.gui.popMessage(idMessage)
         gtk.gdk.threads_leave()
         locked = False
         self.gui.loadCurrentPelicula()
         self.gui.loadUrlImage(
             self.gui.imgPelicula,
             self.gui.currentPelicula.urlImagen,
             300)
         gtk.gdk.threads_enter()
         locked = True
         self.gui.frmDetallesPelicula.set_sensitive(True)
         self.gui.btnSeleccionarPelicula.set_sensitive(True)
         self.gui.btnBuscarPelicula.set_sensitive(True)
         gtk.gdk.threads_leave()
         locked = False
     except Exception as error:
         print "CargadorPelicula::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")
示例#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")
示例#4
0
 def test_obtenPelicula_22(self):
     cliente = MovieClient()
     cliente.obtenRepartoPelicula = mock.Mock(return_value = [{"idActor" : 31, "papel" : "tom hanks"}])
     
     pelicula = cliente.obtenPelicula(22)
     self.assertEqual(31, pelicula.reparto[0]["idActor"])
示例#5
0
def when_se_obtiene_actor(step):
    client = MovieClient()
    world.resultado = client.obtenPelicula(world.Id)
示例#6
0
def when_se_obtiene_actor(step):
    client = MovieClient()
    world.resultado = client.obtenPelicula(world.Id)