diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index fecdbb13..00000000 --- a/.coveragerc +++ /dev/null @@ -1,28 +0,0 @@ -# .coveragerc to control coverage.py -[run] -branch = True -source = src -# omit = bad_file.py - -[paths] -source = - src/ - */site-packages/ - -[report] -# Regexes for lines to exclude from consideration -exclude_lines = - # Have to re-enable the standard pragma - pragma: no cover - - # Don't complain about missing debug-only code: - def __repr__ - if self\.debug - - # Don't complain if tests don't hit defensive assertion code: - raise AssertionError - raise NotImplementedError - - # Don't complain if non-runnable code isn't run: - if 0: - if __name__ == .__main__.: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..9164f3ff --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: Build +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.7' + - name: Verificar version de Python + run: | + python --version + - name: Instalación de librerías y dependencias + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: pruebas+coverage + id: pruebas + run: | + pwd + ls + python -m coverage run -m unittest discover -s tests -v + echo 'Miramos el reporte' + coverage report + echo 'Guardamos archivo' + python -m coverage xml -i + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index bf66c587..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: CI - -# Controls when the action will run. -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - job1: - name: Pruebas - runs-on: ubuntu-latest - steps: - - name: Checkout de repositorio - uses: actions/checkout@v2 - - name: Configuración de entorno de python - uses: actions/setup-python@v2 - with: - python-version: '3.7' - - name: Instalación de librerías y dependencias - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - name: Correr pruebas - id: correr-pruebas - run: python -m unittest discover -s tests diff --git a/__pycache__/setup.cpython-310.pyc b/__pycache__/setup.cpython-310.pyc new file mode 100644 index 00000000..c6d69b82 Binary files /dev/null and b/__pycache__/setup.cpython-310.pyc differ diff --git a/aplicacion.sqlite b/aplicacion.sqlite new file mode 100644 index 00000000..30913307 Binary files /dev/null and b/aplicacion.sqlite differ diff --git a/reports/index.html b/reports/index.html index ae321397..8cc57c65 100644 --- a/reports/index.html +++ b/reports/index.html @@ -1222,8 +1222,6 @@ // middle point has same y points[k + 1] = points[k - ps + 1]; - // we've added a point, better reflect that - k += ps; } } } @@ -4417,9 +4415,9 @@

Statistical information for the repository 'MISW-4101-Practicas-TutorialCancionesTags' was gathered on 2021/02/16.
The output has been generated by gitinspector 0.5.0dev. The statistical analysis tool for git repositories.

-

The following historical commit information, by author, was found.

Author Commits Insertions Deletions % of changes
avargas20332514124100.00
 
+

The following historical commit information, by author, was found.

Author Commits Insertions Deletions % of changes
avargas20332514124100.00
 

The following history timeline has been gathered from the repository. (Green = Additions , Red = Deletions)

-
Author08/02 - 14/02
avargas20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Modified Rows:2638
+
Author08/02 - 14/02
figura color naranja como un solavargas20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Modified Rows:2638

The following file participation percentage table, by author, was calculated.

File Author Percentage
docs/conf.py avargas20100.0%
src/__main__.py avargas20100.0%
setup.py avargas20100.0%
src/modelo/album.py avargas20100.0%
src/modelo/cancion.py avargas20100.0%
src/logica/coleccion.py avargas20100.0%
src/modelo/interprete.py avargas20100.0%
src/modelo/declarative_base.py avargas20100.0%
src/vista/interfaz_coleccion.py avargas20100.0%
src/vista/vista_album.py avargas20100.0%
src/vista/vista_busqueda.py avargas20100.0%
src/vista/vista_cancion.py avargas20100.0%
tests/test_album.py avargas20100.0%
src/vista/vista_lista_cancion.py avargas20100.0%
src/vista/vista_lista_album.py avargas20100.0%
tests/test_cancion.py avargas20100.0%
tests/test_interprete.py avargas20100.0%
diff --git a/requirements.txt b/requirements.txt index 69d16165..0624a73c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ coverage==5.4 Faker==5.8.0 -PyQt5==5.15.2 +#PyQt5==5.15.2 SQLAlchemy==1.3.22 diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..b0f373f6 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,16 @@ +sonar.projectKey=nelsonortfan_TutorialCancionesTags +sonar.organization=nelsonortfan + +sonar.coverage.exclusions=**tests/**,**src/vista/**,**src/recursos/**,**docs/**,**setup.py** +sonar.python.coverage.reportPaths=coverage.xml +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=TutorialCancionesTags +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 +# This is a comment \ No newline at end of file diff --git a/src/logica/coleccion.py b/src/logica/coleccion.py index a7d9d634..f1075568 100644 --- a/src/logica/coleccion.py +++ b/src/logica/coleccion.py @@ -203,7 +203,7 @@ def eliminar_interprete(self, interprete_id): session.delete(interprete) session.commit() return True - except: + except Exception: return False def dar_interpretes(self): diff --git a/src/vista/interfaz_coleccion.py b/src/vista/interfaz_coleccion.py index 14c6265c..fd4d379d 100644 --- a/src/vista/interfaz_coleccion.py +++ b/src/vista/interfaz_coleccion.py @@ -11,6 +11,8 @@ class App(QApplication): Clase principal de la interfaz ''' + MENSAJE_ERROR = "Error al buscar álbum" + def __init__(self, sys_argv, logica): ''' Constructor de la interfaz @@ -190,7 +192,7 @@ def mostrar_resultados_albumes(self, nombre_album): if len(albumes) == 0: mensaje_error = QMessageBox() mensaje_error.setIcon(QMessageBox.Critical) - mensaje_error.setWindowTitle("Error al buscar álbum") + mensaje_error.setWindowTitle(self.MENSAJE_ERROR) mensaje_error.setText("No hay álbumes con el título " + nombre_album) mensaje_error.setStandardButtons(QMessageBox.Ok) mensaje_error.exec_() @@ -204,7 +206,7 @@ def mostrar_resultados_canciones(self, nombre_cancion): if len(canciones) == 0: mensaje_error = QMessageBox() mensaje_error.setIcon(QMessageBox.Critical) - mensaje_error.setWindowTitle("Error al buscar álbum") + mensaje_error.setWindowTitle(self.MENSAJE_ERROR) mensaje_error.setText("No hay canciones con el título " + nombre_cancion) mensaje_error.setStandardButtons(QMessageBox.Ok) mensaje_error.exec_() @@ -218,7 +220,7 @@ def mostrar_resultados_interpretes(self, nombre_interprete): if len(interpretes) == 0: mensaje_error = QMessageBox() mensaje_error.setIcon(QMessageBox.Critical) - mensaje_error.setWindowTitle("Error al buscar álbum") + mensaje_error.setWindowTitle(self.MENSAJE_ERROR) mensaje_error.setText("No hay canciones con el interprete " + nombre_interprete) mensaje_error.setStandardButtons(QMessageBox.Ok) mensaje_error.exec_() diff --git a/src/vista/vista_cancion.py b/src/vista/vista_cancion.py index e8a4cf60..49b2b60e 100644 --- a/src/vista/vista_cancion.py +++ b/src/vista/vista_cancion.py @@ -199,37 +199,53 @@ def guardar_cancion(self): self.interfaz.crear_cancion({"titulo":self.texto_cancion.text(),"minutos":self.texto_minutos.text(), "segundos":self.texto_segundos.text(), "compositor":self.texto_compositor.text()}, self.interpretes, id_album=self.id_album) else: #Si ya hay una canción actual, se debe actualizar - for id in self.interpretes_a_eliminar: + self.actualizar_cancion_actual() + + self.regresar_album_definido() + + def actualizar_interprete_eliminar(self): + for id in self.interpretes_a_eliminar: if id != "n": self.interfaz.eliminar_interprete(id) - self.interpretes_a_eliminar = [] - self.cancion_actual["titulo"]=self.texto_cancion.text() - self.cancion_actual["minutos"]=self.texto_minutos.text() - self.cancion_actual["segundos"]=self.texto_segundos.text() - self.cancion_actual["compositor"]=self.texto_compositor.text() - if self.cancion_actual["titulo"] == "" or self.cancion_actual["minutos"] == "" or self.cancion_actual["segundos"] == "": - mensaje_error = QMessageBox() - mensaje_error.setIcon(QMessageBox.Critical) - mensaje_error.setWindowTitle("Error al guardar canción") - mensaje_error.setText("Ningún campo debe estar vacio") - mensaje_error.setStandardButtons(QMessageBox.Ok) - mensaje_error.exec_() - elif int(self.cancion_actual["minutos"]) == 0 and int(self.cancion_actual["segundos"]) < 10: - mensaje_error = QMessageBox() - mensaje_error.setIcon(QMessageBox.Critical) - mensaje_error.setWindowTitle("Error al guardar canción") - mensaje_error.setText("La duración de la canción debe ser mínimo de 10 sg") - mensaje_error.setStandardButtons(QMessageBox.Ok) - mensaje_error.exec_() - else: - self.interfaz.guardar_cancion(self.cancion_actual, self.interpretes) - - if self.id_album != -1: + + def validar_tiempo_cancion(self): + return self.cancion_actual["titulo"] == "" or self.cancion_actual["minutos"] == "" or self.cancion_actual["segundos"] == "" + + def validar_tiempo_cancion_10_segundos(self): + return int(self.cancion_actual["minutos"]) == 0 and int(self.cancion_actual["segundos"]) < 10 + + def regresar_album_definido(self): + if self.id_album != -1: #Si hay un album definido, se regresa a la vista del album, de lo contrario, se creo la canción sola. self.hide() self.interfaz.mostrar_ventana_album(self.id_album) self.id_album = -1 + def actualizar_cancion_actual(self): + #Si ya hay una canción actual, se debe actualizar + self.actualizar_interprete_eliminar() + self.interpretes_a_eliminar = [] + self.cancion_actual["titulo"]=self.texto_cancion.text() + self.cancion_actual["minutos"]=self.texto_minutos.text() + self.cancion_actual["segundos"]=self.texto_segundos.text() + self.cancion_actual["compositor"]=self.texto_compositor.text() + if self.validar_tiempo_cancion(): + mensaje_error = QMessageBox() + mensaje_error.setIcon(QMessageBox.Critical) + mensaje_error.setWindowTitle("Error al guardar canción") + mensaje_error.setText("Ningún campo debe estar vacio") + mensaje_error.setStandardButtons(QMessageBox.Ok) + mensaje_error.exec_() + elif self.validar_tiempo_cancion_10_segundos(): + mensaje_error = QMessageBox() + mensaje_error.setIcon(QMessageBox.Critical) + mensaje_error.setWindowTitle("Error al guardar canción") + mensaje_error.setText("La duración de la canción debe ser mínimo de 10 sg") + mensaje_error.setStandardButtons(QMessageBox.Ok) + mensaje_error.exec_() + else: + self.interfaz.guardar_cancion(self.cancion_actual, self.interpretes) + def eliminar_interprete(self, n_interprete): ''' Método para eliminar intérpretes de la ventana diff --git a/tests/__pycache__/test_album.cpython-310.pyc b/tests/__pycache__/test_album.cpython-310.pyc new file mode 100644 index 00000000..3e759a5d Binary files /dev/null and b/tests/__pycache__/test_album.cpython-310.pyc differ diff --git a/tests/__pycache__/test_cancion.cpython-310.pyc b/tests/__pycache__/test_cancion.cpython-310.pyc new file mode 100644 index 00000000..8368e559 Binary files /dev/null and b/tests/__pycache__/test_cancion.cpython-310.pyc differ diff --git a/tests/__pycache__/test_interprete.cpython-310.pyc b/tests/__pycache__/test_interprete.cpython-310.pyc new file mode 100644 index 00000000..4f532e92 Binary files /dev/null and b/tests/__pycache__/test_interprete.cpython-310.pyc differ