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

Upgrade to python 3. #35

Merged
merged 2 commits into from
Oct 18, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
language: python
sudo: false

python:
- "2.7"

env:
- TOXENV=django18
- TOXENV=django110
- TOXENV=django111
- TOXENV=quality
matrix:
include:
- python: '2.7'
env: 'TOXENV=django111'
- python: '3.5'
env: 'TOXENV=django111'
- python: '3.5'
env: 'TOXENV=quality'

before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3 # give xvfb some time to start
- wget https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-linux64.tar.gz
- wget https://github.com/mozilla/geckodriver/releases/download/v0.25.0/geckodriver-v0.25.0-linux64.tar.gz
- mkdir geckodriver
- tar -xzf geckodriver-v0.19.1-linux64.tar.gz -C geckodriver
- tar -xzf geckodriver-v0.25.0-linux64.tar.gz -C geckodriver
- export PATH=$PATH:$PWD/geckodriver
- export BOKCHOY_HEADLESS=true

addons:
firefox: '58.0.2'
waheedahmed marked this conversation as resolved.
Show resolved Hide resolved
firefox: latest

install:
- pip install -r requirements/travis.txt
Expand Down
3 changes: 2 additions & 1 deletion google_drive/google_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
#

# Imports ###########################################################
from __future__ import absolute_import
import logging

from django import utils
from xblock.core import XBlock
from xblock.fields import Scope, String, Integer
from xblock.fields import Integer, Scope, String
from xblock.fragment import Fragment
from xblockutils.publish_event import PublishEventMixin
from xblockutils.resources import ResourceLoader
Expand Down
9 changes: 5 additions & 4 deletions google_drive/google_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
#

# Imports ###########################################################
from __future__ import absolute_import
import logging
import textwrap
import requests

import requests
from xblock.core import XBlock
from xblock.fields import Scope, String
from xblock.fragment import Fragment

from xblockutils.publish_event import PublishEventMixin
from xblockutils.resources import ResourceLoader
import six

LOG = logging.getLogger(__name__)
RESOURCE_LOADER = ResourceLoader(__name__)
Expand Down Expand Up @@ -143,7 +144,7 @@ def check_url(self, data, suffix=''): # pylint: disable=unused-argument,no-self
try:
test_url = data['url']
except KeyError as ex:
LOG.debug("URL not provided - %s", unicode(ex))
LOG.debug("URL not provided - %s", six.text_type(ex))
return {
'status_code': 400,
}
Expand All @@ -152,7 +153,7 @@ def check_url(self, data, suffix=''): # pylint: disable=unused-argument,no-self
url_response = requests.head(test_url)
# Catch wide range of request exceptions
except requests.exceptions.RequestException as ex:
LOG.debug("Unable to connect to %s - %s", test_url, unicode(ex))
LOG.debug("Unable to connect to %s - %s", test_url, six.text_type(ex))
return {
'status_code': 400,
}
Expand Down
1 change: 1 addition & 0 deletions google_drive/tests/integration/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#

# Imports ###########################################################
from __future__ import absolute_import
from xblockutils.base_test import SeleniumBaseTest


Expand Down
3 changes: 2 additions & 1 deletion google_drive/tests/integration/test_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#

# Imports ###########################################################
from ddt import ddt, unpack, data
from __future__ import absolute_import
from ddt import data, ddt, unpack

from google_drive.google_calendar import DEFAULT_CALENDAR_URL
from google_drive.google_docs import DEFAULT_DOCUMENT_URL
Expand Down
2 changes: 1 addition & 1 deletion google_drive/tests/integration/xml/image.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<google-document embed_code="&lt;img src='https://docs.google.com/drawings/d/1lmmxboBM5c_0WCTjhAxBdkpqQb3T8VSwtuG0TRR1ODQ/pub?w=960&amp;h=720'&gt;"/>
<google-document embed_code="&lt;img src='https://docs.google.com/drawings/d/e/2PACX-1vR5IEdW9QtEDQG8Kr0ZyigIVJNE8PTpet3H1AcLH0LsCBIVlN-onsTnmP5cfD44cwzrAS3jacvPP6q6/pub?w=960&amp;h=720'&gt;"/>
waheedahmed marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 2 additions & 1 deletion google_drive/tests/test_const.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
STATUS_CODE_400 = {'status_code': 400}
STATUS_CODE_404 = {'status_code': 404}

TEST_IMAGE_URL = 'https://docs.google.com/drawings/d/1lmmxboBM5c_0WCTjhAxBdkpqQb3T8VSwtuG0TRR1ODQ/pub?w=960&h=720'
TEST_IMAGE_URL = 'https://docs.google.com/drawings/d/e/2PACX-1vR5IEdW9QtEDQG8Kr0ZyigIVJNE8PTpet3H1AcLH0LsCBIVlN' \
'-onsTnmP5cfD44cwzrAS3jacvPP6q6/pub?w=960&h=720'
30 changes: 19 additions & 11 deletions google_drive/tests/unit/test_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,31 @@
# -*- coding: utf-8 -*-
#

from __future__ import absolute_import
# Imports ###########################################################
import json
import unittest
import cgi
import ddt
from mock import Mock

import ddt
from django.utils.html import escape
from django.utils.translation import override as override_language
from mock import Mock
from nose.tools import assert_equals, assert_in
from workbench.runtime import WorkbenchRuntime
from xblock.runtime import KvsFieldData, DictKeyValueStore
from xblock.runtime import DictKeyValueStore, KvsFieldData

from google_drive import GoogleCalendarBlock
from google_drive.google_calendar import DEFAULT_CALENDAR_ID
from google_drive.tests.test_const import (
BUTTONS_WRAPPER,
RESULT_ERROR,
RESULT_MISSING_EVENT_TYPE,
RESULT_SUCCESS,
STUDIO_EDIT_WRAPPER,
USER_INPUTS_WRAPPER,
VALIDATION_WRAPPER
)
from google_drive.tests.unit.test_utils import generate_scope_ids, make_request
from google_drive.tests.test_const import STUDIO_EDIT_WRAPPER, VALIDATION_WRAPPER, USER_INPUTS_WRAPPER, BUTTONS_WRAPPER
from google_drive.tests.test_const import RESULT_SUCCESS, RESULT_ERROR, RESULT_MISSING_EVENT_TYPE

# Constants ###########################################################
TEST_SUBMIT_DATA = {
Expand Down Expand Up @@ -101,7 +109,7 @@ def test_calendar_template_content(self, override, activate_lang, expected_lang)
)

assert_in('<div class="google-calendar-xblock-wrapper">', student_fragment.content)
assert_in(cgi.escape(src_url), student_fragment.content)
assert_in(escape(src_url), student_fragment.content)
assert_in('Google Calendar', student_fragment.content)

assert_in(STUDIO_EDIT_WRAPPER, studio_fragment.content)
Expand All @@ -116,7 +124,7 @@ def test_calendar_document_submit(self): # pylint: disable=no-self-use
body = json.dumps(TEST_SUBMIT_DATA)
res = block.handle('studio_submit', make_request(body))
# pylint: disable=no-value-for-parameter
assert_equals(json.loads(res.body), RESULT_SUCCESS)
assert_equals(json.loads(res.body.decode('utf8')), RESULT_SUCCESS)

assert_equals(block.display_name, TEST_SUBMIT_DATA['display_name'])
assert_equals(block.calendar_id, TEST_SUBMIT_DATA['calendar_id'])
Expand All @@ -125,7 +133,7 @@ def test_calendar_document_submit(self): # pylint: disable=no-self-use
body = json.dumps('')
res = block.handle('studio_submit', make_request(body))
# pylint: disable=no-value-for-parameter
assert_equals(json.loads(res.body), RESULT_ERROR)
assert_equals(json.loads(res.body.decode('utf8')), RESULT_ERROR)

def test_calendar_publish_event(self): # pylint: disable=no-self-use
""" Test event publishing in GoogleCalendarBlock"""
Expand All @@ -134,9 +142,9 @@ def test_calendar_publish_event(self): # pylint: disable=no-self-use
body = json.dumps(TEST_COMPLETE_PUBLISH_DATA)
res = block.handle('publish_event', make_request(body))
# pylint: disable=no-value-for-parameter
assert_equals(json.loads(res.body), RESULT_SUCCESS)
assert_equals(json.loads(res.body.decode('utf8')), RESULT_SUCCESS)

body = json.dumps(TEST_INCOMPLETE_PUBLISH_DATA)
res = block.handle('publish_event', make_request(body))

assert_equals(json.loads(res.body), RESULT_MISSING_EVENT_TYPE)
assert_equals(json.loads(res.body.decode('utf8')), RESULT_MISSING_EVENT_TYPE)
42 changes: 26 additions & 16 deletions google_drive/tests/unit/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@
#

# Imports ###########################################################
from __future__ import absolute_import
import json
import unittest
from mock import Mock

from mock import Mock
from nose.tools import assert_equals, assert_in
from workbench.runtime import WorkbenchRuntime
from xblock.runtime import KvsFieldData, DictKeyValueStore
from xblock.runtime import DictKeyValueStore, KvsFieldData

from google_drive import GoogleDocumentBlock
from google_drive.google_docs import DEFAULT_EMBED_CODE, DEFAULT_DOCUMENT_URL
from google_drive.google_docs import DEFAULT_DOCUMENT_URL, DEFAULT_EMBED_CODE
from google_drive.tests.test_const import (
BUTTONS_WRAPPER,
RESULT_ERROR,
RESULT_MISSING_EVENT_TYPE,
RESULT_SUCCESS,
STATUS_CODE_200,
STATUS_CODE_400,
STATUS_CODE_404,
STUDIO_EDIT_WRAPPER,
TEST_IMAGE_URL,
USER_INPUTS_WRAPPER,
VALIDATION_WRAPPER
)
from google_drive.tests.unit.test_utils import generate_scope_ids, make_request
from google_drive.tests.test_const import STUDIO_EDIT_WRAPPER, VALIDATION_WRAPPER, USER_INPUTS_WRAPPER, BUTTONS_WRAPPER
from google_drive.tests.test_const import RESULT_SUCCESS, RESULT_ERROR, RESULT_MISSING_EVENT_TYPE
from google_drive.tests.test_const import STATUS_CODE_200, STATUS_CODE_400, STATUS_CODE_404
from google_drive.tests.test_const import TEST_IMAGE_URL

# Constants ###########################################################
TEST_SUBMIT_DATA = {
Expand Down Expand Up @@ -90,15 +100,15 @@ def test_studio_document_submit(self): # pylint: disable=no-self-use
body = json.dumps(TEST_SUBMIT_DATA)
res = block.handle('studio_submit', make_request(body))
# pylint: disable=no-value-for-parameter
assert_equals(json.loads(res.body), RESULT_SUCCESS)
assert_equals(json.loads(res.body.decode('utf8')), RESULT_SUCCESS)

assert_equals(block.display_name, TEST_SUBMIT_DATA['display_name'])
assert_equals(block.embed_code, TEST_SUBMIT_DATA['embed_code'])
assert_equals(block.alt_text, TEST_SUBMIT_DATA['alt_text'])

body = json.dumps('')
res = block.handle('studio_submit', make_request(body))
assert_equals(json.loads(res.body), RESULT_ERROR)
assert_equals(json.loads(res.body.decode('utf8')), RESULT_ERROR)

def test_check_document_url(self): # pylint: disable=no-self-use
""" Test verification of the provided Google Document URL"""
Expand All @@ -107,22 +117,22 @@ def test_check_document_url(self): # pylint: disable=no-self-use
data = json.dumps(TEST_VALIDATE_URL_DATA)
res = block.handle('check_url', make_request(data))
# pylint: disable=no-value-for-parameter
assert_equals(json.loads(res.body), STATUS_CODE_200)
assert_equals(json.loads(res.body.decode('utf8')), STATUS_CODE_200)

data = json.dumps(TEST_VALIDATE_UNDEFINED_DATA)
res = block.handle('check_url', make_request(data))

assert_equals(json.loads(res.body), STATUS_CODE_400)
assert_equals(json.loads(res.body.decode('utf8')), STATUS_CODE_400)

data = json.dumps(TEST_VALIDATE_NONEXISTENT_URL_DATA)
res = block.handle('check_url', make_request(data))

assert_equals(json.loads(res.body), STATUS_CODE_404)
assert_equals(json.loads(res.body.decode('utf8')), STATUS_CODE_404)

data = json.dumps({})
res = block.handle('check_url', make_request(data))

assert_equals(json.loads(res.body), STATUS_CODE_400)
assert_equals(json.loads(res.body.decode('utf8')), STATUS_CODE_400)

def test_document_publish_event(self): # pylint: disable=no-self-use
""" Test event publishing in GoogleDocumentBlock"""
Expand All @@ -131,14 +141,14 @@ def test_document_publish_event(self): # pylint: disable=no-self-use
body = json.dumps(TEST_COMPLETE_PUBLISH_DOCUMENT_DATA)
res = block.handle('publish_event', make_request(body))
# pylint: disable=no-value-for-parameter
assert_equals(json.loads(res.body), RESULT_SUCCESS)
assert_equals(json.loads(res.body.decode('utf8')), RESULT_SUCCESS)

body = json.dumps(TEST_COMPLETE_PUBLISH_IMAGE_DATA)
res = block.handle('publish_event', make_request(body))

assert_equals(json.loads(res.body), RESULT_SUCCESS)
assert_equals(json.loads(res.body.decode('utf8')), RESULT_SUCCESS)

body = json.dumps(TEST_INCOMPLETE_PUBLISH_DATA)
res = block.handle('publish_event', make_request(body))

assert_equals(json.loads(res.body), RESULT_MISSING_EVENT_TYPE)
assert_equals(json.loads(res.body.decode('utf8')), RESULT_MISSING_EVENT_TYPE)
2 changes: 1 addition & 1 deletion google_drive/tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#

# Imports ###########################################################
from __future__ import absolute_import
from webob import Request

from xblock.fields import ScopeIds


Expand Down
13 changes: 13 additions & 0 deletions openedx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file describes this Open edX repo, as described in OEP-2:
# https://open-edx-proposals.readthedocs.io/en/latest/oep-0002-bp-repo-metadata.html#specification

nick: xblock-google-drive
owner: unknown

oeps:
oep-2: true
oep-7: true
oep-18: true
tags:
- xblock
- library
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Django>=1.8,<2 # Web application framework
mako # Used by xblock-utils.resources, but not declared as a requirement for it
XBlock[django] # Courseware component architecture
-e git+https://github.com/edx/xblock-utils.git@v1.1.1#egg=xblock-utils==1.1.1 # Utility functions shared by many XBlocks
-e git+https://github.com/edx/xblock-utils.git@v1.2.2#egg=xblock-utils==1.2.2 # Utility functions shared by many XBlocks
2 changes: 1 addition & 1 deletion requirements/dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
diff-cover # Changeset diff test coverage
pip-tools # Requirements file management
transifex-client # Client for Transifex.com to push and pull translation files
-e git://github.com/edx/xblock-sdk.git@v0.1.4#egg=xblock-sdk==v0.1.4 # XBlock SDK to render Django templates properly
-e git+https://github.com/edx/xblock-sdk.git#egg=xblock-sdk # XBlock SDK to render Django templates properly
8 changes: 4 additions & 4 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
# pip-compile --output-file requirements/dev.txt requirements/base.in requirements/dev.in requirements/quality.in requirements/test.in requirements/travis.in
#
-e git+https://github.com/edx/xblock-sdk.git@v0.1.4#egg=xblock-sdk==0.1.4
-e git+https://github.com/edx/xblock-utils.git@v1.1.1#egg=xblock-utils==1.1.1
-e git+https://github.com/edx/xblock-sdk.git#egg=xblock-sdk
-e git+https://github.com/edx/xblock-utils.git@v1.2.2#egg=xblock-utils==1.2.2
appdirs==1.4.3 # via fs
argparse==1.4.0 # via caniusepython3
asn1crypto==0.24.0 # via cryptography
Expand Down Expand Up @@ -45,7 +45,7 @@ fs-s3fs==1.0.0 # via django-pyfs
fs==2.1.0 # via django-pyfs, fs-s3fs, xblock
funcsigs==1.0.2 # via mock, pytest
future==0.16.0 # via backports.os
futures==3.2.0 # via caniusepython3, isort, s3transfer
futures==3.2.0; python_version == "2.7"
idna==2.7 # via cryptography, requests, urllib3
importlib-metadata==0.5 # via path.py
inflect==1.0.1 # via jinja2-pluralize
Expand Down Expand Up @@ -108,4 +108,4 @@ virtualenv==16.0.0 # via tox
web-fragments==0.2.2 # via xblock
webob==1.8.2 # via xblock
wrapt==1.10.11 # via astroid
xblock[django]==1.2.2
xblock[django]==1.2.6
8 changes: 4 additions & 4 deletions requirements/quality.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
# pip-compile --output-file requirements/quality.txt requirements/base.in requirements/quality.in requirements/test.in
#
-e git+https://github.com/edx/xblock-sdk.git@v0.1.4#egg=xblock-sdk==0.1.4
-e git+https://github.com/edx/xblock-utils.git@v1.1.1#egg=xblock-utils==1.1.1
-e git+https://github.com/edx/xblock-sdk.git#egg=xblock-sdk
-e git+https://github.com/edx/xblock-utils.git@v1.2.2#egg=xblock-utils==1.2.2
appdirs==1.4.3 # via fs
argparse==1.4.0 # via caniusepython3
astroid==1.5.2 # via edx-lint, pylint, pylint-celery
Expand Down Expand Up @@ -37,7 +37,7 @@ fs-s3fs==1.0.0 # via django-pyfs
fs==2.1.0 # via django-pyfs, fs-s3fs, xblock
funcsigs==1.0.2 # via mock, pytest
future==0.16.0 # via backports.os
futures==3.2.0 # via caniusepython3, isort, s3transfer
futures==3.2.0; python_version == "2.7"
idna==2.7 # via requests
isort==4.3.4
jinja2==2.10 # via cookiecutter
Expand Down Expand Up @@ -83,4 +83,4 @@ urllib3==1.23 # via botocore, requests, selenium
web-fragments==0.2.2 # via xblock
webob==1.8.2 # via xblock
wrapt==1.10.11 # via astroid
xblock[django]==1.2.2
xblock[django]==1.2.6
2 changes: 1 addition & 1 deletion requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ mock
pytest
pytest-cov
pytest-django
-e git+https://github.com/edx/xblock-sdk.git@v0.1.4#egg=xblock-sdk==0.1.4
-e git+https://github.com/edx/xblock-sdk.git#egg=xblock-sdk
Loading