Commit 25fe8e80 by JonahStanley

Now using context files and os.path

parent ef1f523c
...@@ -6,6 +6,7 @@ from django.conf import settings ...@@ -6,6 +6,7 @@ from django.conf import settings
import requests import requests
import string import string
import random import random
import os
TEST_ROOT = settings.COMMON_TEST_DATA_ROOT TEST_ROOT = settings.COMMON_TEST_DATA_ROOT
HTTP_PREFIX = "http://localhost:8001" HTTP_PREFIX = "http://localhost:8001"
...@@ -27,7 +28,8 @@ def upload_file(step, file_name): ...@@ -27,7 +28,8 @@ def upload_file(step, file_name):
file_css = '.file-input' file_css = '.file-input'
upload = world.css_find(file_css) upload = world.css_find(file_css)
#uploading the file itself #uploading the file itself
upload._element.send_keys(TEST_ROOT + '/uploads/' + file_name) path = os.path.join(TEST_ROOT, 'uploads/', file_name)
upload._element.send_keys(os.path.abspath(path))
close_css = '.close-button' close_css = '.close-button'
world.css_find(close_css).click() world.css_find(close_css).click()
...@@ -58,20 +60,20 @@ def no_duplicate(step, file_name): ...@@ -58,20 +60,20 @@ def no_duplicate(step, file_name):
@step(u'I can download the correct "([^"]*)" file$') @step(u'I can download the correct "([^"]*)" file$')
def check_download(step, file_name): def check_download(step, file_name):
cur_file = open(TEST_ROOT + '/uploads/' + file_name, 'r') path = os.path.join(TEST_ROOT, 'uploads/', file_name)
cur_text = cur_file.read() with open(os.path.abspath(path), 'r') as cur_file:
r = get_file(file_name) cur_text = cur_file.read()
downloaded_text = r.text r = get_file(file_name)
assert cur_text == downloaded_text downloaded_text = r.text
cur_file.close() assert cur_text == downloaded_text
@step(u'I modify "([^"]*)"$') @step(u'I modify "([^"]*)"$')
def modify_upload(step, file_name): def modify_upload(step, file_name):
new_text = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(10)) new_text = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(10))
cur_file = open(TEST_ROOT + '/uploads/' + file_name, 'w') path = os.path.join(TEST_ROOT, 'uploads/', file_name)
cur_file.write(new_text) with open(os.path.abspath(path), 'w') as cur_file:
cur_file.close() cur_file.write(new_text)
def get_index(file_name): def get_index(file_name):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment