Fix another tests.
(forgot to commit earlier)
This commit is contained in:
parent
a7e1d8829f
commit
cda3055bd6
@ -207,6 +207,7 @@ def pdf_info(original):
|
||||
_log.debug('pdfinfo could not read the pdf file.')
|
||||
raise BadMediaFail()
|
||||
|
||||
lines = [l.decode() for l in lines]
|
||||
info_dict = dict([[part.strip() for part in l.strip().split(':', 1)]
|
||||
for l in lines if ':' in l])
|
||||
|
||||
|
@ -59,7 +59,7 @@ def get_upload_file_limits(user):
|
||||
"""
|
||||
Get the upload_limit and max_file_size for this user
|
||||
"""
|
||||
if user.upload_limit >= 0:
|
||||
if user.upload_limit is not None and user.upload_limit >= 0: # TODO: debug this
|
||||
upload_limit = user.upload_limit
|
||||
else:
|
||||
upload_limit = mg_globals.app_config.get('upload_limit', None)
|
||||
|
@ -48,10 +48,10 @@ class TestAPI(object):
|
||||
return template.TEMPLATE_TEST_CONTEXT[template_name]
|
||||
|
||||
def http_auth_headers(self):
|
||||
return {'Authorization': 'Basic {0}'.format(
|
||||
base64.b64encode(':'.join([
|
||||
return {'Authorization': ('Basic {0}'.format(
|
||||
base64.b64encode((':'.join([
|
||||
self.user.username,
|
||||
self.user_password])))}
|
||||
self.user_password])).encode('ascii')).decode()))}
|
||||
|
||||
def do_post(self, data, test_app, **kwargs):
|
||||
url = kwargs.pop('url', '/api/submit')
|
||||
|
@ -119,7 +119,7 @@ def test_register_views(test_app):
|
||||
assert message['To'] == 'angrygrrl@example.org'
|
||||
email_context = template.TEMPLATE_TEST_CONTEXT[
|
||||
'mediagoblin/auth/verification_email.txt']
|
||||
assert email_context['verification_url'] in message.get_payload(decode=True)
|
||||
assert email_context['verification_url'].encode('ascii') in message.get_payload(decode=True)
|
||||
|
||||
path = urlparse.urlsplit(email_context['verification_url'])[2]
|
||||
get_params = urlparse.urlsplit(email_context['verification_url'])[3]
|
||||
@ -190,7 +190,7 @@ def test_register_views(test_app):
|
||||
email_context = template.TEMPLATE_TEST_CONTEXT[
|
||||
'mediagoblin/plugins/basic_auth/fp_verification_email.txt']
|
||||
#TODO - change the name of verification_url to something forgot-password-ish
|
||||
assert email_context['verification_url'] in message.get_payload(decode=True)
|
||||
assert email_context['verification_url'].encode('ascii') in message.get_payload(decode=True)
|
||||
|
||||
path = urlparse.urlsplit(email_context['verification_url'])[2]
|
||||
get_params = urlparse.urlsplit(email_context['verification_url'])[3]
|
||||
|
@ -142,8 +142,7 @@ class TestUserEdit(object):
|
||||
assert message['To'] == 'new@example.com'
|
||||
email_context = template.TEMPLATE_TEST_CONTEXT[
|
||||
'mediagoblin/edit/verification.txt']
|
||||
assert email_context['verification_url'] in \
|
||||
message.get_payload(decode=True)
|
||||
assert email_context['verification_url'].encode('ascii') in message.get_payload(decode=True)
|
||||
|
||||
path = urlparse.urlsplit(email_context['verification_url'])[2]
|
||||
assert path == u'/edit/verify_email/'
|
||||
|
@ -54,19 +54,19 @@ def test_exif_extraction():
|
||||
expected = OrderedDict({'EXIF CVAPattern': {'field_length': 8,
|
||||
'field_offset': 26224,
|
||||
'field_type': 7,
|
||||
'printable': u'[0, 2, 0, 2, 1, 2, 0, 1]',
|
||||
'printable': '[0, 2, 0, 2, 1, 2, 0, 1]',
|
||||
'tag': 41730,
|
||||
'values': [0, 2, 0, 2, 1, 2, 0, 1]},
|
||||
'EXIF ColorSpace': {'field_length': 2,
|
||||
'field_offset': 476,
|
||||
'field_type': 3,
|
||||
'printable': u'sRGB',
|
||||
'printable': 'sRGB',
|
||||
'tag': 40961,
|
||||
'values': [1]},
|
||||
'EXIF ComponentsConfiguration': {'field_length': 4,
|
||||
'field_offset': 308,
|
||||
'field_type': 7,
|
||||
'printable': u'YCbCr',
|
||||
'printable': 'YCbCr',
|
||||
'tag': 37121,
|
||||
'values': [1, 2, 3, 0]},
|
||||
'EXIF CompressedBitsPerPixel': {'field_length': 8,
|
||||
|
@ -51,7 +51,7 @@ class TestHTTPCallback(object):
|
||||
'client_id': client_id,
|
||||
'client_secret': client_secret})
|
||||
|
||||
response_data = json.loads(response.body)
|
||||
response_data = json.loads(response.body.decode())
|
||||
|
||||
return response_data['access_token']
|
||||
|
||||
|
@ -135,13 +135,13 @@ otherperson@example.com\n\nSGkgb3RoZXJwZXJzb24sCmNocmlzIGNvbW1lbnRlZCBvbiB5b3VyI
|
||||
self.logout()
|
||||
self.login('otherperson', 'nosreprehto')
|
||||
|
||||
self.test_app.get(media_uri_slug + '/c/{0}/'.format(comment_id))
|
||||
self.test_app.get(media_uri_slug + 'c/{0}/'.format(comment_id))
|
||||
|
||||
notification = Notification.query.filter_by(id=notification_id).first()
|
||||
|
||||
assert notification.seen == True
|
||||
|
||||
self.test_app.get(media_uri_slug + '/notifications/silence/')
|
||||
self.test_app.get(media_uri_slug + 'notifications/silence/')
|
||||
|
||||
subscription = CommentSubscription.query.filter_by(id=subscription_id)\
|
||||
.first()
|
||||
|
@ -163,7 +163,7 @@ code={1}&client_secret={2}'.format(client_id, code, client.secret))
|
||||
|
||||
assert token_res.status_int == 200
|
||||
|
||||
token_data = json.loads(token_res.body)
|
||||
token_data = json.loads(token_res.body.decode())
|
||||
|
||||
assert not 'error' in token_data
|
||||
assert 'access_token' in token_data
|
||||
@ -191,7 +191,7 @@ code={0}&client_secret={1}'.format(code, client.secret))
|
||||
|
||||
assert token_res.status_int == 200
|
||||
|
||||
token_data = json.loads(token_res.body)
|
||||
token_data = json.loads(token_res.body.decode())
|
||||
|
||||
assert 'error' in token_data
|
||||
assert not 'access_token' in token_data
|
||||
@ -215,7 +215,7 @@ code={0}&client_secret={1}'.format(code, client.secret))
|
||||
|
||||
assert token_res.status_int == 200
|
||||
|
||||
new_token_data = json.loads(token_res.body)
|
||||
new_token_data = json.loads(token_res.body.decode())
|
||||
|
||||
assert not 'error' in new_token_data
|
||||
assert 'access_token' in new_token_data
|
||||
|
@ -14,6 +14,7 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import collections
|
||||
import tempfile
|
||||
import shutil
|
||||
import os
|
||||
@ -26,13 +27,13 @@ from .resources import GOOD_PDF as GOOD
|
||||
|
||||
@pytest.mark.skipif("not check_prerequisites()")
|
||||
def test_pdf():
|
||||
good_dict = {'pdf_version_major': 1, 'pdf_title': '',
|
||||
good_dict = collections.OrderedDict({'pdf_version_major': 1, 'pdf_title': '',
|
||||
'pdf_page_size_width': 612, 'pdf_author': '',
|
||||
'pdf_keywords': '', 'pdf_pages': 10,
|
||||
'pdf_producer': 'dvips + GNU Ghostscript 7.05',
|
||||
'pdf_version_minor': 3,
|
||||
'pdf_creator': 'LaTeX with hyperref package',
|
||||
'pdf_page_size_height': 792}
|
||||
'pdf_page_size_height': 792})
|
||||
assert pdf_info(GOOD) == good_dict
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
create_pdf_thumb(GOOD, os.path.join(temp_dir, 'good_256_256.png'), 256, 256)
|
||||
|
@ -44,28 +44,23 @@ class Test_PWG(object):
|
||||
def test_session(self):
|
||||
resp = self.do_post("pwg.session.login",
|
||||
{"username": u"nouser", "password": "wrong"})
|
||||
assert resp.body == XML_PREFIX \
|
||||
+ '<rsp stat="fail"><err code="999" msg="Invalid username/password"/></rsp>'
|
||||
assert resp.body == (XML_PREFIX + '<rsp stat="fail"><err code="999" msg="Invalid username/password"/></rsp>').encode('ascii')
|
||||
|
||||
resp = self.do_post("pwg.session.login",
|
||||
{"username": self.username, "password": "wrong"})
|
||||
assert resp.body == XML_PREFIX \
|
||||
+ '<rsp stat="fail"><err code="999" msg="Invalid username/password"/></rsp>'
|
||||
assert resp.body == (XML_PREFIX + '<rsp stat="fail"><err code="999" msg="Invalid username/password"/></rsp>').encode('ascii')
|
||||
|
||||
resp = self.do_get("pwg.session.getStatus")
|
||||
assert resp.body == XML_PREFIX \
|
||||
+ '<rsp stat="ok"><username>guest</username></rsp>'
|
||||
assert resp.body == (XML_PREFIX + '<rsp stat="ok"><username>guest</username></rsp>').encode('ascii')
|
||||
|
||||
resp = self.do_post("pwg.session.login",
|
||||
{"username": self.username, "password": self.password})
|
||||
assert resp.body == XML_PREFIX + '<rsp stat="ok">1</rsp>'
|
||||
assert resp.body == (XML_PREFIX + '<rsp stat="ok">1</rsp>').encode('ascii')
|
||||
|
||||
resp = self.do_get("pwg.session.getStatus")
|
||||
assert resp.body == XML_PREFIX \
|
||||
+ '<rsp stat="ok"><username>chris</username></rsp>'
|
||||
assert resp.body == (XML_PREFIX + '<rsp stat="ok"><username>chris</username></rsp>').encode('ascii')
|
||||
|
||||
self.do_get("pwg.session.logout")
|
||||
|
||||
resp = self.do_get("pwg.session.getStatus")
|
||||
assert resp.body == XML_PREFIX \
|
||||
+ '<rsp stat="ok"><username>guest</username></rsp>'
|
||||
assert resp.body == (XML_PREFIX + '<rsp stat="ok"><username>guest</username></rsp>').encode('ascii')
|
||||
|
@ -456,11 +456,10 @@ def test_plugin_staticdirect(static_plugin_app):
|
||||
Test that the staticdirect utilities pull up the right things
|
||||
"""
|
||||
result = json.loads(
|
||||
static_plugin_app.get('/staticstuff/').body)
|
||||
static_plugin_app.get('/staticstuff/').body.decode())
|
||||
|
||||
assert len(result) == 2
|
||||
|
||||
assert result['mgoblin_bunny_pic'] == '/test_static/images/bunny_pic.png'
|
||||
assert result['plugin_bunny_css'] == \
|
||||
'/plugin_static/staticstuff/css/bunnify.css'
|
||||
|
||||
|
@ -61,7 +61,7 @@ def create_key(key_dir, key_filepath):
|
||||
key = str(getrandbits(192))
|
||||
key_file = tempfile.NamedTemporaryFile(dir=key_dir, suffix='.bin',
|
||||
delete=False)
|
||||
key_file.write(key)
|
||||
key_file.write(key.encode('ascii'))
|
||||
key_file.flush()
|
||||
os.rename(key_file.name, key_filepath)
|
||||
key_file.close()
|
||||
|
Loading…
x
Reference in New Issue
Block a user