From 052e024c0e39fa2e260b5d9f33067682de6c675e Mon Sep 17 00:00:00 2001 From: DiegoRuizGil Date: Fri, 9 Dec 2022 10:52:25 +0100 Subject: [PATCH 1/2] =?UTF-8?q?[test]=20Test=20export=20census=20Comprobac?= =?UTF-8?q?i=C3=B3n=20c=C3=B3digo=20404=20con=20votaci=C3=B3n=20no=20v?= =?UTF-8?q?=C3=A1lida.=20Correcci=C3=B3n=20test=20utils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- decide/census/tests.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/decide/census/tests.py b/decide/census/tests.py index f3700343fb..152645f64a 100644 --- a/decide/census/tests.py +++ b/decide/census/tests.py @@ -113,7 +113,7 @@ def test_census_utils(self): selected_atributes = ['id'] voters_data = [] - census = Census.objects.filter(voting_id=1).values() + census = Census.objects.filter(voting_id=self.v.id).values() user_atributes = censusUtils.get_user_atributes() data = censusUtils.get_csvtext_and_data(form_values, census) @@ -138,6 +138,12 @@ def test_access_accepted(self): self.client.force_login(self.user_admin) response = self.client.get('/census/export/{}/'.format(1), format='json') self.assertEqual(response.status_code, 200) + + def test_voting_not_found(self): + self.client.force_login(self.user_admin) + voting_id = int(self.v.id) + 1 + response = self.client.get('/census/export/{}/'.format(voting_id), format='json') + self.assertEqual(response.status_code, 404) class ExportCensusTransTestCase(StaticLiveServerTestCase): @@ -191,3 +197,4 @@ def testCheckExportName(self): title = self.driver.find_element(By.TAG_NAME, 'h1').text title = title.split(": ")[0] return self.assertEqual(str(title),'Nombre de la votación') + From 984ce44f5da68e7b5b0168236ea0045809edc84f Mon Sep 17 00:00:00 2001 From: Dr-Vell Date: Sat, 10 Dec 2022 20:58:17 +0100 Subject: [PATCH 2/2] =?UTF-8?q?[Test]=20Tests=20de=20traducci=C3=B3n=20esp?= =?UTF-8?q?a=C3=B1ol=20visualizer=20Se=20han=20a=C3=B1adido=209=20tests=20?= =?UTF-8?q?a=20tests.py=20del=20paquete=20visualizer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Francisco J Migueles Student <99977786+Framigdom@users.noreply.github.com> --- decide/visualizer/tests.py | 86 ++++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 8 deletions(-) diff --git a/decide/visualizer/tests.py b/decide/visualizer/tests.py index 0c9bd12b7b..6e75e2a0e2 100644 --- a/decide/visualizer/tests.py +++ b/decide/visualizer/tests.py @@ -55,8 +55,8 @@ def test_graphs_title_exist(self): v.save() self.driver.get(f'{self.live_server_url}/visualizer/{v.pk}') - title_text = self.driver.find_element(By.ID,'graphs_title').text - self.assertEqual(title_text,'Gráficas de la votación:') + title_text = self.driver.find_element(By.ID,'graphs_title').is_displayed() + self.assertTrue(title_text) def test_graph_title_1_exist(self): @@ -67,8 +67,8 @@ def test_graph_title_1_exist(self): v.save() self.driver.get(f'{self.live_server_url}/visualizer/{v.pk}') - title_text = self.driver.find_element(By.ID,'graph_title_1').text - self.assertEqual(title_text,'Gráfica de votos') + title_text = self.driver.find_element(By.ID,'graph_title_1').is_displayed() + self.assertTrue(title_text) def test_graph_title_2_exist(self): @@ -79,8 +79,8 @@ def test_graph_title_2_exist(self): v.save() self.driver.get(f'{self.live_server_url}/visualizer/{v.pk}') - title_text = self.driver.find_element(By.ID,'graph_title_2').text - self.assertEqual(title_text,'Gráfica de escaños') + title_text = self.driver.find_element(By.ID,'graph_title_2').is_displayed() + self.assertTrue(title_text) def test_graph_title_3_exist(self): @@ -91,8 +91,8 @@ def test_graph_title_3_exist(self): v.save() self.driver.get(f'{self.live_server_url}/visualizer/{v.pk}') - title_text = self.driver.find_element(By.ID,'graph_title_3').text - self.assertEqual(title_text,'Gráfica de porcentaje de representación') + title_text = self.driver.find_element(By.ID,'graph_title_3').is_displayed() + self.assertTrue(title_text) def test_graph_canvas_1_exist(self): @@ -280,9 +280,12 @@ def crear_votacion(self): v.auths.add(a) v.create_pubkey() v.start_date = timezone.now() + v.seats = 3 + v.min_percentage_representation=5 v.save() self.v_id = v.id + self.voting = v return v.id def detener_votacion(self): @@ -310,4 +313,71 @@ def testCheckResultadosTransES(self): self.driver.get(f'{self.live_server_url}/visualizer/'+str(self.v_id)) Resultados_text= self.driver.find_elements(By.TAG_NAME, 'h2')[0].text return self.assertEqual(str(Resultados_text),'Resultados:') + + def testCheckFechaInicioTransES(self): + self.crear_votacion() + self.detener_votacion() + self.driver.get(f'{self.live_server_url}/visualizer/'+str(self.v_id)) + Resultados_text= self.driver.find_elements(By.TAG_NAME, 'h4')[0].text + Resultados_text=Resultados_text.split(':')[0] + return self.assertEqual(str(Resultados_text),'Fecha de inicio de la votación') + + def testCheckFechaFinTransES(self): + self.crear_votacion() + self.detener_votacion() + self.driver.get(f'{self.live_server_url}/visualizer/'+str(self.v_id)) + Resultados_text= self.driver.find_elements(By.TAG_NAME, 'h4')[1].text + Resultados_text=Resultados_text.split(':')[0] + return self.assertEqual(str(Resultados_text),'Fecha de fin de la votación') + + def testCheckEscañosTransES(self): + self.crear_votacion() + self.detener_votacion() + self.driver.get(f'{self.live_server_url}/visualizer/'+str(self.v_id)) + Resultados_text= self.driver.find_elements(By.TAG_NAME, 'h3')[1].text + Resultados_text=Resultados_text.split(':')[0] + return self.assertEqual(str(Resultados_text),'Número de escaños a repartir') + + def testCheckMinPercentageTransES(self): + self.crear_votacion() + self.detener_votacion() + self.driver.get(f'{self.live_server_url}/visualizer/'+str(self.v_id)) + Resultados_text= self.driver.find_elements(By.TAG_NAME, 'h3')[2].text + Resultados_text=Resultados_text.split(':')[0] + return self.assertEqual(str(Resultados_text),'Porcentaje mínimo para tener representación') + + def testCheckHontDesTransES(self): + self.crear_votacion() + self.detener_votacion() + self.driver.get(f'{self.live_server_url}/visualizer/'+str(self.v_id)) + Resultados_text= self.driver.find_elements(By.TAG_NAME, 'p')[0].text + Resultados_text=Resultados_text.split(':')[0] + return self.assertEqual(str(Resultados_text),"El cálculo en el reparto de escaños esta basado en la Ley D'Hont, en la cual se ignoran las candidaturas con menos del mínimo porcentaje necesario de votos totales, además en caso de empate en el reparto de un escaño, este será dado al candidato con más votos totales obtenidos") + + def testCheckTituloGraficasTransES(self): + self.crear_votacion() + self.detener_votacion() + self.driver.get(f'{self.live_server_url}/visualizer/'+str(self.v_id)) + title_text = self.driver.find_element(By.ID,'graphs_title').text + self.assertEqual(title_text,'Gráficas de la votación:') + def testCheckTituloGraficas1TransES(self): + self.crear_votacion() + self.detener_votacion() + self.driver.get(f'{self.live_server_url}/visualizer/'+str(self.v_id)) + title_text = self.driver.find_element(By.ID,'graph_title_1').text + self.assertEqual(title_text,'Gráfica de votos') + + def testCheckTituloGraficas2TransES(self): + self.crear_votacion() + self.detener_votacion() + self.driver.get(f'{self.live_server_url}/visualizer/'+str(self.v_id)) + title_text = self.driver.find_element(By.ID,'graph_title_2').text + self.assertEqual(title_text,'Gráfica de escaños') + + def testCheckTituloGraficas3TransES(self): + self.crear_votacion() + self.detener_votacion() + self.driver.get(f'{self.live_server_url}/visualizer/'+str(self.v_id)) + title_text = self.driver.find_element(By.ID,'graph_title_3').text + self.assertEqual(title_text,'Gráfica de porcentaje de representación') \ No newline at end of file