def test_isPresent(lstcasting, casting): cast = { 'id': '31212432412431412132', 'budget': '0', 'genres': 'Drama|Crime', 'imdb_id': 'tt0094675', 'original_language': 'fi', 'original_title': 'Ariel', 'overview': "Taisto Kasurinen is a Finnish coal miner whose father has just committed suicide and who is framed for a crime he did not commit. In jail, he starts to dream about leaving the country and starting a new life. He escapes from prison but things don't go as planned...", 'popularity': '0.823904', 'production_companies': 'Villealfa Filmproduction Oy', 'production_countries': 'Finland', 'release_date': '21/10/1988', 'revenue': '0', 'runtime': '69', 'spoken_languages': 'suomi', 'status': 'Released', 'tagline': '', 'title': 'Ariel', 'vote_average': '7.1', 'vote_count': '40', 'production_companies_number': '2', 'spoken_languages_number': '2' } print(slt.isPresent(lstcasting, casting[2])) assert slt.isPresent(lstcasting, casting[2]) > 0 assert slt.isPresent(lstcasting, cast) == 0
def test_isPresent(lstpeliculas, peliculas): pelicula = { '\ufeffid': '12391238712897', 'budget': '2', 'genres': 'Bachata|Salsa|Romance|Trap Fiction', 'imdb_id': 'tt012938123', 'original_language': 'es', 'original_title': 'El loco', 'overview': "LOCURA.", 'popularity': '10', 'production_companies': 'Bachata INC', 'production_countries': 'Colombia', 'release_date': '26/06/2020', 'revenue': '1239813', 'runtime': '195', 'spoken_languages': 'Locura', 'status': 'Released', 'tagline': 'AAAAAAAAAAAY.', 'title': 'XD', 'vote_average': '10', 'vote_count': '1', 'production_companies_number': '2', 'spoken_languages_number\n': '7' } print(slt.isPresent(lstpeliculas, peliculas[2])) assert slt.isPresent(lstpeliculas, peliculas[2]) > 0 assert slt.isPresent(lstpeliculas, pelicula) == 0
def test_deleteElement(lstbooks, books): pos = slt.isPresent(lstbooks, books[2]) assert pos > 0 book = slt.getElement(lstbooks, pos) assert book == books[2] slt.deleteElement(lstbooks, pos) assert slt.size(lstbooks) == 4 book = slt.getElement(lstbooks, pos) assert book == books[3]
def test_deleteElement(lstcasting, casting): pos = slt.isPresent(lstcasting, casting[2]) assert pos > 0 cast = slt.getElement(lstcasting, pos) assert cast == casting[2] slt.deleteElement(lstcasting, pos) assert slt.size(lstcasting) == len(casting) - 1 cast = slt.getElement(lstcasting, pos) assert cast == casting[3]
def isPresent (lst, element, comparefunction): """ Informa si el elemento element esta presente en la lista. Si esta presente retorna la posición en la que se encuentra o cero (0) si no esta presente """ if ( lst['type'] =='ARRAY_LIST'): return alt.isPresent (lst, element, comparefunction) else: return slt.isPresent (lst, element, comparefunction)
def test_deleteElement(lstpeliculas, peliculas): pos = slt.isPresent(lstpeliculas, peliculas[2]) assert pos > 0 pelicula = slt.getElement(lstpeliculas, pos) assert pelicula == peliculas[2] slt.deleteElement(lstpeliculas, pos) assert slt.size(lstpeliculas) == len(peliculas) - 1 pelicula = slt.getElement(lstpeliculas, pos) assert pelicula == peliculas[3]
def isPresent(lst, element, comparefunction): """ Informa si el elemento element esta presente en la lista. Args: lst Lista a evaluar element Elemento que se desea insertar en la lista comparefuntion Función que permitirá identificar si el elemento está o no presente Return :: int La primera posición en la que se encuentra o cero (0) si no esta presente """ if (lst['type'] == 'ARRAY_LIST'): return alt.isPresent(lst, element, comparefunction) else: return slt.isPresent(lst, element, comparefunction)
def isPresent(lst, element): """ Informa si el elemento element esta presente en la lista. Informa si un elemento está en la lista. Si esta presente, retorna la posición en la que se encuentra o cero (0) si no esta presente. Se utiliza la función de comparación utilizada durante la creación de la lista para comparar los elementos. Args: lst: La lista a examinar element: El elemento a buscar Raises: Exception """ try: if (lst['type'] == 'ARRAY_LIST'): return alt.isPresent(lst, element) else: return slt.isPresent(lst, element) except Exception as exp: error.reraise(exp, 'List->isPresent: ')
def test_isPresent(lstbooks, books): book = {'book_id': '10', 'book_title': 'Title 10', 'author': 'author 10'} print(slt.isPresent(lstbooks, books[2])) assert slt.isPresent(lstbooks, books[2]) > 0 assert slt.isPresent(lstbooks, book) == 0
def test_isPresent(lstbooks, lista): book = {'id': '10', 'original_title': 'Title 10', 'director': 'author 10'} print(slt.isPresent(lstbooks, lista[2])) assert slt.isPresent(lstbooks, lista[2]) > 0 assert slt.isPresent(lstbooks, book) == 0