diff --git a/cms/djangoapps/contentstore/features/upload.feature b/cms/djangoapps/contentstore/features/upload.feature new file mode 100644 index 0000000000..5717cfb907 --- /dev/null +++ b/cms/djangoapps/contentstore/features/upload.feature @@ -0,0 +1,15 @@ +Feature: Upload Files + As a course author, I want to be able to upload files for my students + + Scenario: Users can upload files + Given I have opened a new course in Studio + And I go to the files and uploads page + When I upload the file "upload.feature" + Then I see the file "upload.feature" was uploaded + + Scenario: Users can update files + Given I have opened a new course in studio + And I go to the files and uploads page + When I upload the file "upload.feature" + And I upload the file "upload.feature" + Then I see only one "upload.feature" diff --git a/cms/djangoapps/contentstore/features/upload.py b/cms/djangoapps/contentstore/features/upload.py new file mode 100644 index 0000000000..6c53741dcc --- /dev/null +++ b/cms/djangoapps/contentstore/features/upload.py @@ -0,0 +1,57 @@ +#pylint: disable=C0111 +#pylint: disable=W0621 + +from lettuce import world, step +import os + + +@step(u'I go to the files and uploads page') +def go_to_uploads(step): + menu_css = 'li.nav-course-courseware' + uploads_css = '.nav-course-courseware-uploads' + world.css_find(menu_css).click() + world.css_find(uploads_css).click() + + +@step(u'I upload the file "([^"]*)"$') +def upload_file(step, file_name): + upload_css = '.upload-button' + world.css_find(upload_css).click() + + file_css = '.file-input' + upload = world.css_find(file_css) + upload._element.send_keys(os.getcwd() + '/' + file_name) + + close_css = '.close-button' + world.css_find(close_css).click() + + +@step(u'I see the file "([^"]*)" was uploaded') +def check_upload(step, file_name): + index = get_index(file_name) + assert index != -1 + + +@step(u'I see only one "([^"]*)"$') +def no_duplicate(step, file_name): + names_css = '.name-col > a.filename' + all_names = world.css_find(names_css) + only_one = False + for i in range(len(all_names)): + if file_name == all_names[i].html: + only_one = not only_one + assert only_one + + +@step(u'I PAUSE') +def pause(step): + from pdb import set_trace; set_trace() + + +def get_index(file_name): + names_css = '.name-col > a.filename' + all_names = world.css_find(names_css) + for i in range(len(all_names)): + if file_name == all_names[i].html: + return i + return -1