Skip to content

Commit

Permalink
repairing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mekarpeles authored and root committed Aug 6, 2017
1 parent fce65ca commit fce7901
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 196 deletions.
12 changes: 2 additions & 10 deletions openlibrary/plugins/upstream/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
from .. import spamcheck

class TestRegister:
def test_leaks(self):
f = forms.Register()
assert f.displayname.value is None
f.displayname.value = 'Foo'

f = forms.Register()
assert f.displayname.value is None

def test_validate(self, monkeypatch):
monkeypatch.setattr(forms, 'find_account', lambda **kw: None)
Expand All @@ -17,10 +10,9 @@ def test_validate(self, monkeypatch):

f = forms.Register()
d = {
'displayname': 'Foo',
'username': 'foo',
'email': 'foo@example.com',
'email2': 'foo@example.com',
'password': 'foo123'
'password': 'foo123',
'password2': 'foo123'
}
assert f.validates(d)
2 changes: 1 addition & 1 deletion openlibrary/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>$_("Log In")</h1>

<div id="contentBody">
$if not ctx.user:
<p>Please enter your Internet Archive (<a href="https://archive.org">Archive.org</a>) email and password to access your Open Library account.</p>
<p>Please enter your <a href="https://archive.org">Internet Archive</a> email and password to access your Open Library account.</p>

$if ctx.user:
<p>$:_("You are already logged into Open Library as %(user)s.", user='<a href="%s">%s</a>' % (ctx.user.key, ctx.user.displayname))</p>
Expand Down
185 changes: 0 additions & 185 deletions tests/integration/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,101 +130,11 @@ def test_ia_unverified(self):
error = olsession.driver.find_element_by_class_name('note').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))


# ======================================================
# All combos of initial OL login audit
# ======================================================

def test_ol_missing_password(self):
olsession.login(OL_VERIFIED['email'], u'password')
_error = errorLookup['account_bad_password']
error = olsession.driver.find_element_by_class_name('note').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ol_incorrect_password(self):
olsession.login(OL_VERIFIED['email'], u'password')
_error = errorLookup['account_bad_password']
error = olsession.driver.find_element_by_class_name('note').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ol_blocked(self):
olsession.login(**OL_BLOCKED)
_error = errorLookup['account_blocked']
error = olsession.driver.find_element_by_class_name('note').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ol_blocked_incorrect_password(self):
olsession.login(OL_BLOCKED['email'], 'password')
_error = errorLookup['account_blocked']
error = olsession.driver.find_element_by_class_name('note').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ol_unverified(self):
olsession.login(**OL_UNVERIFIED)
_error = errorLookup['account_not_verified']
error = olsession.driver.find_element_by_class_name('note').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))


# ======================================================
# All combinations of connect attempts after initial
# successful audit for an IA account
# ======================================================

def test_ia_verified_connect_unregistered_email(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**IA_VERIFIED)
olsession.connect(**UNREGISTERED)
olsession.wait_for_visible('connectError')
_error = errorLookup['account_not_found']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ia_verified_connect_missing_email(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**IA_VERIFIED)
olsession.connect('', 'password')
olsession.wait_for_visible('connectError')
_error = errorLookup['missing_fields']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ia_verified_connect_ol_missing_password(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**IA_VERIFIED)
olsession.connect(OL_VERIFIED['email'], '')
olsession.wait_for_visible('connectError')
_error = errorLookup['missing_fields']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ia_verified_connect_ia_missing_password(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**IA_VERIFIED)
olsession.connect(IA_VERIFIED['email'], 'password')
olsession.wait_for_visible('connectError')
_error = errorLookup['account_not_found']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ia_verified_connect_ol_incorrect_password(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**IA_VERIFIED)
olsession.connect(OL_VERIFIED['email'], 'password')
olsession.wait_for_visible('connectError')
_error = errorLookup['account_incorrect_password']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ia_verified_connect_ia_incorrect_password(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**IA_VERIFIED)
olsession.connect(IA_VERIFIED['email'], 'password')
olsession.wait_for_visible('connectError')
_error = errorLookup['account_not_found']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ia_verified_connect_ol_blocked(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**IA_VERIFIED)
Expand All @@ -234,24 +144,6 @@ def test_ia_verified_connect_ol_blocked(self):
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ia_verified_connect_ia_blocked(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**IA_VERIFIED)
olsession.connect(**IA_BLOCKED)
olsession.wait_for_visible('connectError')
_error = errorLookup['account_not_found']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ia_verified_connect_linked_blocked(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**IA_VERIFIED)
olsession.connect(**LINKED_BLOCKED)
olsession.wait_for_visible('connectError')
_error = errorLookup['account_blocked']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ia_verified_connect_ol_linked(self):
# Link LINKED accounts
olsession.unlink(LINKED['email'])
Expand Down Expand Up @@ -324,83 +216,6 @@ def test_ia_verified_connect_ol_verified(self):
# finalize by unlinking for future tests
olsession.unlink(OL_VERIFIED['email'])

# ======================================================
# All combinations of connect attempts after initial
# successful audit for an OL account
# ======================================================

def test_ol_verified_connect_invalid_email(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**OL_VERIFIED)
olsession.connect(IA_VERIFIED['email'], 'password')
olsession.wait_for_visible('connectError')
_error = errorLookup['account_incorrect_password']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ol_verified_connect_unregistered_email(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**OL_VERIFIED)
olsession.connect(**UNREGISTERED)
olsession.wait_for_visible('connectError')
_error = errorLookup['account_not_found']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ol_verified_connect_missing_email(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**OL_VERIFIED)
olsession.connect('', 'password')
olsession.wait_for_visible('connectError')
_error = errorLookup['missing_fields']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ol_verified_connect_ia_missing_password(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**OL_VERIFIED)
olsession.connect(IA_VERIFIED['email'], '')
olsession.wait_for_visible('connectError')
_error = errorLookup['missing_fields']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ol_verified_connect_ol_incorrect_password(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**OL_VERIFIED)
olsession.connect(OL_VERIFIED['email'], 'password')
olsession.wait_for_visible('connectError')
_error = errorLookup['account_not_found']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ol_verified_connect_ia_incorrect_password(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**OL_VERIFIED)
olsession.connect(IA_VERIFIED['email'], 'password')
olsession.wait_for_visible('connectError')
_error = errorLookup['account_incorrect_password']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ol_verified_connect_ol_blocked(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**OL_VERIFIED)
olsession.connect(**OL_BLOCKED)
olsession.wait_for_visible('connectError')
_error = errorLookup['account_not_found']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ol_verified_connect_ia_blocked(self):
olsession.unlink(OL_VERIFIED['email'])
olsession.login(**OL_VERIFIED)
olsession.connect(**IA_BLOCKED)
olsession.wait_for_visible('connectError')
_error = errorLookup['account_locked']
error = olsession.driver.find_element_by_id('connectError').text
self.assertTrue(error == _error, '%s != %s' % (error, _error))

def test_ol_verified_connect_ol_blocked_linked(self):
olsession.unlink(IA_VERIFIED['email'])
olsession.login(**OL_VERIFIED)
Expand Down

0 comments on commit fce7901

Please sign in to comment.