Skip to content

Commit

Permalink
Merge pull request #112 from edx/sstudent/upgrade-x
Browse files Browse the repository at this point in the history
upgrade xblock
  • Loading branch information
sanfordstudent authored Mar 15, 2017
2 parents 0e6d13c + 34b5aac commit 0c98735
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local_settings.py
.treerc
.coverage
htmlcov
geckodriver.log

*.DS_Store
workbench/static/djpyfs/
Expand Down
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ sudo: false

language: python

addons:
firefox: "52.0esr"

python:
- "2.7"

Expand All @@ -15,6 +18,10 @@ cache:
before_install:
- "export DISPLAY=:99"
- "sh -e /etc/init.d/xvfb start"
- "wget https://github.com/mozilla/geckodriver/releases/download/v0.15.0/geckodriver-v0.15.0-linux64.tar.gz"
- "mkdir geckodriver"
- "tar -xzf geckodriver-v0.15.0-linux64.tar.gz -C geckodriver"
- "export PATH=$PATH:$PWD/geckodriver"

install:
- "make install"
Expand Down
7 changes: 1 addition & 6 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ requests
webob
simplejson
lazy

# XBlock
# This is not in/from PyPi, since it moves fast
-e git+https://github.com/edx/[email protected]#egg=XBlock==0.4.7
#-e ../XBlock

XBlock>=0.5.0
fs
pypng
-e git+https://github.com/edx/[email protected]#egg=django-pyfs==1.0.3
Expand Down
14 changes: 7 additions & 7 deletions sample_xblocks/filethumbs/filethumbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ def student_view(self, context=None): # pylint: disable=W0613
html_str = pkg_resources.resource_string(__name__, "static/html/thumbs.html")
frag = Fragment(unicode(html_str))

if not self.fs.exists("thumbsvotes.json"):
with self.fs.open('thumbsvotes.json', 'wb') as file_output:
if not self.fs.exists(u"thumbsvotes.json"):
with self.fs.open(u'thumbsvotes.json', 'wb') as file_output:
json.dump({'up': 0, 'down': 0}, file_output)
file_output.close()

votes = json.load(self.fs.open("thumbsvotes.json"))
votes = json.load(self.fs.open(u"thumbsvotes.json"))
self.upvotes = votes['up']
self.downvotes = votes['down']

Expand All @@ -92,10 +92,10 @@ def student_view(self, context=None): # pylint: disable=W0613
"static/js/src/thumbs.js")
frag.add_javascript(unicode(js_str))

with self.fs.open('uparrow.png', 'wb') as file_output:
with self.fs.open(u'uparrow.png', 'wb') as file_output:
png.Writer(len(ARROW[0]), len(ARROW), greyscale=True, bitdepth=1).write(file_output, ARROW)

with self.fs.open('downarrow.png', 'wb') as file_output:
with self.fs.open(u'downarrow.png', 'wb') as file_output:
png.Writer(len(ARROW[0]), len(ARROW), greyscale=True, bitdepth=1).write(file_output, ARROW[::-1])

frag.initialize_js('FileThumbsBlock', {'up': self.upvotes,
Expand All @@ -119,7 +119,7 @@ def vote(self, data, suffix=''): # pylint: disable=unused-argument
# log.error("cheater!")
# return

votes = json.load(self.fs.open("thumbsvotes.json"))
votes = json.load(self.fs.open(u"thumbsvotes.json"))
self.upvotes = votes['up']
self.downvotes = votes['down']

Expand All @@ -132,7 +132,7 @@ def vote(self, data, suffix=''): # pylint: disable=unused-argument
else:
self.downvotes += 1

with self.fs.open('thumbsvotes.json', 'wb') as file_output:
with self.fs.open(u'thumbsvotes.json', 'wb') as file_output:
json.dump({'up': self.upvotes, 'down': self.downvotes}, file_output)

self.voted = True
Expand Down
13 changes: 13 additions & 0 deletions workbench/test/selenium_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

from workbench.runtime import reset_global_state

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.expected_conditions import staleness_of


@attr('selenium')
class SeleniumTest(WebAppTest, StaticLiveServerTestCase):
Expand All @@ -19,3 +22,13 @@ def setUp(self):
# Clear the in-memory key value store, the usage store, and whatever
# else needs to be cleared and re-initialized.
reset_global_state()

def wait_for_page_load(self, old_element, timeout=30):
"""
Uses Selenium's built-in "staleness" hook to wait until the page has
loaded. For use when clicking a link to ensure that the new page
has loaded before selecting elements. I think that this could be used
to check that elements have been made stale via ajax as well, but it
is not being used for that in any of the tests here.
"""
return WebDriverWait(self.browser, timeout).until(staleness_of(old_element))
1 change: 1 addition & 0 deletions workbench/test/test_filethumbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def test_three_thumbs_initial_state(self):
# She clicks on the three thumbs at once scenario
link = self.browser.find_element_by_link_text('three file thumbs test')
link.click()
self.wait_for_page_load(link, timeout=10)

# The header reflects the XBlock
header1 = self.browser.find_element_by_css_selector('h1')
Expand Down
3 changes: 3 additions & 0 deletions workbench/test/test_thumbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def test_three_thumbs_initial_state(self):
# She clicks on the three thumbs at once scenario
link = self.browser.find_element_by_link_text('three thumbs test')
link.click()
self.wait_for_page_load(link, timeout=10)

# The header reflects the XBlock
header1 = self.browser.find_element_by_css_selector('h1')
Expand Down Expand Up @@ -58,6 +59,7 @@ def test_three_upvoting(self):
# She clicks on the three thumbs at once scenario
link = self.browser.find_element_by_link_text('three thumbs test')
link.click()
self.wait_for_page_load(link, timeout=10)

# The vertical that contains the thumbs
vertical_css = 'div.student_view > div.xblock-v1 > div.vertical'
Expand Down Expand Up @@ -88,6 +90,7 @@ def test_three_downvoting(self):
# She clicks on the three thumbs at once scenario
link = self.browser.find_element_by_link_text('three thumbs test')
link.click()
self.wait_for_page_load(link, timeout=10)

# The vertical that contains the thumbs
vertical_css = 'div.student_view > div.xblock-v1 > div.vertical'
Expand Down

0 comments on commit 0c98735

Please sign in to comment.