Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pruebas connect #89

Merged
3 commits merged into from
Feb 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion admincfdi/tests/test_pyutil.py
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
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
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