Commit 74e83247 by Clinton Blackburn

Merge pull request #84 from edx/test-updates

Updated Acceptance Tests
parents a0f0b829 a773a953
......@@ -19,7 +19,7 @@ ECOMMERCE_API_TOKEN = os.environ.get('ECOMMERCE_API_AUTH_TOKEN', ACCESS_TOKEN)
ORDER_PROCESSING_TIME = int(os.environ.get('ORDER_PROCESSING_TIME', 15))
# Test configuration
ENABLE_AUTO_AUTH = str2bool(os.environ.get('ENABLE_AUTO_AUTH', False))
ENABLE_LMS_AUTO_AUTH = str2bool(os.environ.get('ENABLE_LMS_AUTO_AUTH', False))
ENABLE_OAUTH_TESTS = str2bool(os.environ.get('ENABLE_OAUTH_TESTS', True))
COURSE_ID = os.environ.get('COURSE_ID', 'edX/DemoX/Demo_Course')
VERIFIED_COURSE_ID = os.environ.get('VERIFIED_COURSE_ID', 'edX/victor101/Victor_s_test_course')
......
......@@ -2,13 +2,13 @@ import logging
import uuid
import requests
from ecommerce_api_client.client import EcommerceApiClient
from acceptance_tests.api import EnrollmentApiClient
from acceptance_tests.config import (ENABLE_AUTO_AUTH, APP_SERVER_URL, LMS_PASSWORD, LMS_EMAIL, LMS_URL,
from acceptance_tests.config import (ENABLE_LMS_AUTO_AUTH, APP_SERVER_URL, LMS_PASSWORD, LMS_EMAIL, LMS_URL,
BASIC_AUTH_USERNAME, BASIC_AUTH_PASSWORD, ECOMMERCE_API_SERVER_URL,
ECOMMERCE_API_SIGNING_KEY)
LMS_USERNAME, ECOMMERCE_API_TOKEN)
from acceptance_tests.pages import LMSLoginPage
from ecommerce_api_client.client import EcommerceApiClient
log = logging.getLogger(__name__)
......@@ -20,21 +20,14 @@ class LoginMixin(object):
self.lms_login_page = LMSLoginPage(self.browser)
def login(self):
if ENABLE_AUTO_AUTH:
self.login_with_auto_auth()
else:
self.login_with_lms()
def login_with_auto_auth(self):
url = '{}/test/auto_auth/'.format(APP_SERVER_URL)
self.browser.get(url)
self.login_with_lms()
def login_with_lms(self, email=None, password=None, course_id=None):
""" Visit LMS and login. """
email = email or LMS_EMAIL
password = password or LMS_PASSWORD
# Note: We use Selenium directly here (as opposed to Bok Choy) to avoid issues with promises being broken.
# Note: We use Selenium directly here (as opposed to bok-choy) to avoid issues with promises being broken.
self.lms_login_page.browser.get(self.lms_login_page.url(course_id)) # pylint: disable=not-callable
self.lms_login_page.login(email, password)
......@@ -48,6 +41,12 @@ class LogoutMixin(object):
class LmsUserMixin(object):
password = 'edx'
def get_lms_user(self):
if ENABLE_LMS_AUTO_AUTH:
return self.create_lms_user()
return LMS_USERNAME, LMS_PASSWORD, LMS_EMAIL
def create_lms_user(self, username=None, password=None, email=None):
username = username or ('auto_auth_' + uuid.uuid4().hex[0:20])
password = password or 'edx'
......@@ -78,10 +77,10 @@ class EnrollmentApiMixin(object):
class EcommerceApiMixin(object):
@property
def ecommerce_api_client(self):
return EcommerceApiClient(ECOMMERCE_API_SERVER_URL, ECOMMERCE_API_SIGNING_KEY, self.username, self.email)
return EcommerceApiClient(ECOMMERCE_API_SERVER_URL, oauth_access_token=ECOMMERCE_API_TOKEN)
def assert_order_created_and_completed(self):
orders = self.ecommerce_api_client.get_orders()
orders = self.ecommerce_api_client.orders.get()['results']
self.assertGreater(len(orders), 0, 'No orders found for the user!')
# TODO Validate this is the correct order.
......
......@@ -8,7 +8,7 @@ class LoginEnrollmentTests(EcommerceApiMixin, EnrollmentApiMixin, LmsUserMixin,
def setUp(self):
super(LoginEnrollmentTests, self).setUp()
self.course_id = COURSE_ID
self.username, self.password, self.email = self.create_lms_user()
self.username, self.password, self.email = self.get_lms_user()
def test_honor_enrollment_and_login(self):
""" Verifies that a user can login and enroll in a course via the login page. """
......
......@@ -14,7 +14,7 @@ class VerifiedCertificatePaymentTests(EcommerceApiMixin, EnrollmentApiMixin, Lms
def setUp(self):
super(VerifiedCertificatePaymentTests, self).setUp()
self.course_id = VERIFIED_COURSE_ID
self.username, self.password, self.email = self.create_lms_user()
self.username, self.password, self.email = self.get_lms_user()
def test_payment(self):
self.login_with_lms(self.email, self.password)
......
......@@ -15,4 +15,4 @@ logutils==0.3.3
pycountry==1.10
requests==2.6.0
git+https://github.com/edx/ecommerce-api-client.git@0.1.0#egg=ecommerce-api-client
git+https://github.com/edx/ecommerce-api-client.git@0.4.0#egg=ecommerce-api-client==0.4.0
# Packages required for testing
-r base.txt
bok-choy==0.3.3
git+https://github.com/edx/bok-choy.git@e4e5934b9645e389d14ef22587e8462be4c1cd74#egg=bok_choy
#bok-choy==0.3.3
coverage==3.7.1
ddt==1.0.0
django-nose==1.3
......
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