Address PR comments:

- Internationalize upload errors.
- Move upload tests into their own files.
- Refactor upload dialog acceptance tests.
This commit is contained in:
Peter Fogg
2013-08-19 11:27:17 -04:00
parent e4302e62d2
commit 9632f4fed8
11 changed files with 184 additions and 169 deletions

View File

@@ -5,9 +5,11 @@ from lettuce import world, step
from nose.tools import assert_true
from auth.authz import get_user_by_email, get_course_groupname_for_role
from django.conf import settings
from selenium.webdriver.common.keys import Keys
import time
import os
from django.contrib.auth.models import Group
from logging import getLogger
@@ -15,6 +17,8 @@ logger = getLogger(__name__)
from terrain.browser import reset_data
TEST_ROOT = settings.COMMON_TEST_DATA_ROOT
########### STEP HELPERS ##############
@@ -257,3 +261,12 @@ def type_in_codemirror(index, text):
g._element.send_keys(text)
if world.is_firefox():
world.trigger_event('div.CodeMirror', index=index, event='blur')
def upload_file(filename):
file_css = '.upload-dialog input[type=file]'
upload = world.css_find(file_css).first
path = os.path.join(TEST_ROOT, filename)
upload._element.send_keys(os.path.abspath(path))
button_css = '.upload-dialog .action-upload'
world.css_click(button_css)

View File

@@ -76,6 +76,7 @@ Feature: Course Settings
Scenario: User can upload course image
Given I have opened a new course in Studio
When I select Schedule and Details
And I click the "Upload Course Image" button
And I upload a new course image
Then I should see the new course image
And the image URL should be present in the field

View File

@@ -4,9 +4,8 @@
from lettuce import world, step
from terrain.steps import reload_the_page
from selenium.webdriver.common.keys import Keys
from common import type_in_codemirror
from common import type_in_codemirror, upload_file
from django.conf import settings
import os
from nose.tools import assert_true, assert_false, assert_equal
@@ -150,16 +149,15 @@ def test_change_course_overview(_step):
type_in_codemirror(0, "<h1>Overview</h1>")
@step('I click the "Upload Course Image" button')
def click_upload_button(_step):
button_css = '.action-upload-image'
world.css_click(button_css)
@step('I upload a new course image$')
def upload_new_course_image(_step):
upload_css = '.action-upload-image'
world.css_click(upload_css)
file_css = '.upload-dialog input[type=file]'
upload = world.css_find(file_css)
path = os.path.join(TEST_ROOT, 'image.jpg')
upload._element.send_keys(os.path.abspath(path))
button_css = '.upload-dialog .action-upload'
world.css_click(button_css)
upload_file('image.jpg')
@step('I should see the new course image$')

View File

@@ -3,7 +3,7 @@
from lettuce import world, step
from django.conf import settings
import os
from common import upload_file
TEST_ROOT = settings.COMMON_TEST_DATA_ROOT
@@ -24,14 +24,8 @@ def assert_create_new_textbook_msg(_step):
@step(u'I upload the textbook "([^"]*)"$')
def upload_file(_step, file_name):
file_css = '.upload-dialog input[type=file]'
upload = world.css_find(file_css)
# uploading the file itself
path = os.path.join(TEST_ROOT, 'uploads', file_name)
upload._element.send_keys(os.path.abspath(path))
button_css = ".upload-dialog .action-upload"
world.css_click(button_css)
def upload_textbook(_step, file_name):
upload_file(file_name)
@step(u'I click (on )?the New Textbook button')