Exemplo n.º 1
0
 def test_updateActor_1(self, mock_update):
     cliente = MovieClient()
     mock_update.return_value = True
     actor = Actor()
     actor.nombre = "Juan"
     actor.id = 1
     self.assertTrue(cliente.updateActor(actor))
Exemplo n.º 2
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()
Exemplo n.º 3
0
 def test_udpatePelicula_22(self, mock_update):
     cliente = MovieClient()
     mock_update.return_value = True
     pelicula = Pelicula()
     pelicula.id = 22
     pelicula.titulo = "Back to the future"
     self.assertTrue(cliente.updatePelicula(pelicula))
Exemplo n.º 4
0
def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)

                results = client.perform_search()
                print('Found {} results.'.format(len(results)))

                for r in results:
                    print('{} -- {}'.format(r.Year, r.Title))

        # always except errors from most specific to least specific order
        # this is to avoid catching yourself excepting any error, with a generic message, before you except
        # a specific error
        except requests.exceptions.ConnectionError as ce:
            print(
                'There was a problem communicating with the server. Connection failed.'
            )
        except ValueError as ve:
            print('Please enter a valid search string.')
        except KeyError as ke:
            print('Your search term returned zero results.')
        except Exception as x:
            print("That didn't work: {}".format(type(x)))

    print('Exiting...')
Exemplo n.º 5
0
    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()
Exemplo n.º 6
0
    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.actoresReducidos = client.buscarActor(self.who, 1)
            gtk.gdk.threads_enter()
            locked = True
            for actor in self.gui.actoresReducidos:
                self.gui.cmbResultadosActor.append_text(actor.nombre)

            self.gui.popMessage(idMessage)
            self.gui.btnBuscarActor.set_sensitive(True)
            gtk.gdk.threads_leave()
            locked = False
        except Exception as error:

            print "BuscadorActores::" + str(error)
        finally:
            if locked:
                gtk.gdk.threads_leave()
Exemplo n.º 7
0
def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)
                results = client.perform_search()
                print("Found {} results.".format(len(results)))
                for r in results:
                    print('{} -- {}'.format(r.Year, r.Title))
        except requests.exceptions.ConnectionError:
            print('ERROR: Cannot search, connection error.')
        except ValueError as ve:
            print('ERROR: Your search string is invalid: {}'.format(ve))
        except Exception as x:
            print('ERROR: {}'.format(x))
    print('exiting...')
Exemplo n.º 8
0
def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)

                results = client.perform_search()
                print('Found {} results.'.format(len(results)))
                for r in results:
                    print("{} -- {}".format(r.Year, r.Title))
        except requests.exceptions.ConnectionError as ce:
            print('ERROR: Cannot search your network is down.')
        except ValueError as ve:
            print('ERROR: Your search string is invalid: {}'.format(ve))
        except Exception as x:
            print('ERROR : {}'.format(x))
    print('exiting...')
Exemplo n.º 9
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.º 10
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.º 11
0
def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)
                results = client.perform_search()
                print("Found {} results.".format(len(results)))
                for r in results:
                    print('{} -- {}'.format(
                        r.Year, r.Title
                    ))
        except requests.exceptions.ConnectionError:
            print('Error: Your network connection appears down.')
        except ValueError as ve:
            print('Error: Invalid search string. {}'.format(ve))
        except Exception as x:
            print("This went wrong: {}".format(x))
    print('exiting')
Exemplo n.º 12
0
def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)

                results = client.perform_search()
                print(f'Found {len(results)} results.')
                for r in results:
                    print(f'{r.year} — {r.title}')
        except requests.exceptions.ConnectionError:
            print('ERROR: Cannot search, you network is down')
        except ValueError as ve:
            print(f'ERROR: Your search string is invalid: {ve}')
        except Exception as x:
            print(f'ERROR: {type(x)}')

    print('exiting...')
Exemplo n.º 13
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.º 14
0
def search_event_loop():
    search = 'ONCE_THROUGH_LOOP'

    while search != 'x':
        try:
            search = input('Title search text (x to exit): ')
            if search != 'x':
                client = MovieClient(search)

                results = client.perform_search()
                # print(client.perform_search())
                for r in results:
                    print('{} -- {}'.format(
                        r.Year, r.Title
                    ))

        except requests.exceptions.ConnectionError:
            print('ERROR: Unable to connect to network.')
        except ValueError as ve:
            print('ERROR: Your search is invalid: {}'.format(ve))
        except Exception as x:
            print('ERROR: {}'.format(x))

    print('exiting...')
Exemplo n.º 15
0
def search_event_loop():
    search = None

    while search != 'x':
        try:
            search = input('What are you seeking (x for exit): ')

            if search != 'x':
                client = MovieClient(search)
                results = client.perform_search()

                print('Found {} results'.format(len(results)))

                for r in results:
                    print('{} --- {}'.format(r.Year, r.Title))

        except requests.exceptions.ConnectionError as ce:
            print('ERROR: Network is down.')
        except KeyError as ve:
            print('ERROR: Search string is invalid {}'.format(ve))
        except Exception as x:
            print('Ah, something goes wrong. ERROR: {}'.format(x))

    print('exiting…')
Exemplo n.º 16
0
def search_event_loop():
    search_text = "ONCE_THROUGH_LOOP"

    while search_text != 'x':
        try:
            search_text = input('Title search text (x to exit): ')

            if search_text != 'x':
                client = MovieClient(search_text)

                results = client.perform_search()
                print("Found {} results.".format(len(results)))
                for r in results:
                    print('{} -- {}'.format(
                        r.Year, r.Title
                    ))
        except requests.exceptions.ConnectionError:
            print('ERROR: Cannot search, your network is down.')
        except ValueError as ve:
            print('ERROR: Your search text is invalid: {}'.format(ve))
        except Exception as x:
            print('That did not work: {}'.format(x));

    print('exiting...')
Exemplo n.º 17
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.º 18
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.º 19
0
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)
Exemplo n.º 20
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.client = MovieClient()
Exemplo n.º 21
0
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)
Exemplo n.º 22
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.client = MovieClient()
Exemplo n.º 23
0
def when_se_obtiene_actor(step):
    client = MovieClient()
    world.resultado = client.obtenPelicula(world.Id)
Exemplo n.º 24
0
from movie_client import MovieClient

movie_client = MovieClient()


def main():
    val = 'RUN'

    while val:
        command = str(
            input("Search movies by [1]keyword, [2]director, [3]IMDB: "))
        if command == '1':
            search_by_keyword()
        elif command == '2':
            search_by_director()
        elif command == '3':
            search_by_imdb()
        else:
            print('exiting...')
            break


def search_by_keyword():
    keyword = input('What keyword you want to search: ')
    r = movie_client.entry_by_keyword(keyword)
    r_json = r.json()
    movies = r_json.get('hits')
    for i, movie in enumerate(movies, 1):
        print("{}. {}.".format(i, movie.get('title')))

Exemplo n.º 25
0
def when_se_obtiene_actor(step):
    client = MovieClient()
    world.resultado = client.obtenPelicula(world.Id)
Exemplo n.º 26
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.º 27
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"])