Skip to content

Commit

Permalink
Merge pull request #89 from ppaez/pruebas-connect
Browse files Browse the repository at this point in the history
Pruebas connect
  • Loading branch information
Mauricio Baeza committed Feb 6, 2016
2 parents e77015f + 045f383 commit 9d706a4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
16 changes: 15 additions & 1 deletion admincfdi/tests/test_pyutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def setUp(self):
pyutil.webdriver.FirefoxProfile = webdriver.FirefoxProfile

self.WebDriverWait = pyutil.WebDriverWait
pyutil.WebDriverWait = Mock()
self.wait = Mock()
pyutil.WebDriverWait = Mock(return_value=self.wait)

self.sleep = time.sleep
time.sleep = Mock()
Expand Down Expand Up @@ -98,6 +99,19 @@ def test_connect(self):
profile = descarga.connect(profile, rfc='x', ciec='y')
self.assertEqual(3, self.status.call_count)

def test_connect_fail(self):
from unittest.mock import Mock
from admincfdi.pyutil import DescargaSAT
from admincfdi.pyutil import WebDriverWait
from selenium import webdriver
from selenium.common.exceptions import TimeoutException

self.wait.until.side_effect = TimeoutException
profile = webdriver.FirefoxProfile()
descarga = DescargaSAT(status_callback=self.status)
profile = descarga.connect(profile, rfc='x', ciec='y')
self.assertRaises(TimeoutException)

def test_disconnect_not_connected(self):
from admincfdi.pyutil import DescargaSAT
from selenium import webdriver
Expand Down
11 changes: 5 additions & 6 deletions docs/devel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ Los detalles de cada paso:
- Llenar el usuario y la contraseña (RFC y CIEC)
- Enviar los datos al servidor
- Esperar la respuesta
- El título de la página cambia a *NetIQ Access Manager*
- Hay un elemento iframe con id ``content``, el cual contiene:
- En caso de éxito, el elemento con clase ``messagetext``
con el texto *session has been authenticated*.
- En caso de falla, un pop up con el elemento con id ``xacerror``
que contiene el texto *Login failed*
- En caso de éxito, se carga una página con el título
*NetIQ Access Manager*
- En caso de falla, un elemento ``div`` con id ``xacerror``
deja de estar oculto y muestra su texto que empieza
con *El RFC o contraseña son incorrectos.*

#. Buscar

Expand Down
17 changes: 16 additions & 1 deletion functional_DescargaSAT.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,24 @@ def no_op(*args):
pass

descarga = DescargaSAT(status_callback=no_op)
descarga.connect(profile, rfc=self.rfc, ciec=self.ciec)
status = descarga.connect(profile, rfc=self.rfc, ciec=self.ciec)
self.assertTrue(status)
descarga.disconnect()

def test_connect_fail(self):
from admincfdi.pyutil import DescargaSAT
from selenium import webdriver

profile = webdriver.FirefoxProfile()

def no_op(*args):
pass

descarga = DescargaSAT(status_callback=no_op)
status = descarga.connect(profile, rfc='x', ciec='y')
self.assertFalse(status)
descarga.browser.close()

def test_search_uuid(self):
import os
import tempfile
Expand Down

0 comments on commit 9d706a4

Please sign in to comment.