Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into auth-social/pabalvcar
Browse files Browse the repository at this point in the history
  • Loading branch information
Pabalvcar committed Dec 12, 2022
2 parents a974081 + cf5efc0 commit f900fd7
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 9 deletions.
9 changes: 8 additions & 1 deletion decide/census/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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):

Expand Down Expand Up @@ -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')

86 changes: 78 additions & 8 deletions decide/visualizer/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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):

Expand All @@ -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):

Expand All @@ -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):

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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')

0 comments on commit f900fd7

Please sign in to comment.