parent
51191256f8
commit
ffcaef0ae0
7 changed files with 104 additions and 27 deletions
@ -1,18 +1,60 @@ |
|||||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||||
|
|
||||||
|
import time |
||||||
|
from datetime import datetime, timedelta |
||||||
|
|
||||||
from django.test import TestCase |
from django.test import TestCase |
||||||
from django.shortcuts import reverse |
from django.shortcuts import reverse |
||||||
|
from django.utils.timezone import now |
||||||
|
from selene.api import * |
||||||
|
|
||||||
from project.tests import SeleniumTestCase |
from project.tests import SeleniumTestCase |
||||||
from project.tests.factories import UserFactory, User |
from project.tests.factories import UserFactory, User, CourseFactory, LiveLessonFactory |
||||||
|
from project.utils.selenium_utils import SeleniumExtensions as SE |
||||||
|
|
||||||
|
|
||||||
class PaymentsTestCase(SeleniumTestCase): |
class PaymentsTestCase(SeleniumTestCase): |
||||||
|
fixtures = ['school_schedules.json'] |
||||||
|
|
||||||
@classmethod |
@classmethod |
||||||
def setUpTestData(cls): |
def setUpTestData(cls): |
||||||
cls.simple_user = UserFactory(role=User.USER_ROLE) |
UserFactory.create_batch(2, role=User.AUTHOR_ROLE) |
||||||
|
UserFactory(role=User.USER_ROLE) |
||||||
|
CourseFactory.create_batch(4, user=User.objects.filter(role=User.AUTHOR_ROLE)) |
||||||
|
for i in range(11): |
||||||
|
LiveLessonFactory(date=now() - timedelta(i + 2)) |
||||||
|
|
||||||
|
|
||||||
def test_can_buy_school(self): |
def test_can_buy_school(self): |
||||||
self.client.force_login(self.simple_user) |
simple_user = UserFactory(role=User.USER_ROLE) |
||||||
self.driver.get(reverse('')) |
self.login(simple_user) |
||||||
|
browser.set_driver(self.driver) |
||||||
|
browser.open_url(self.get_url(reverse('index'))) |
||||||
|
self.wait_for_js_load() |
||||||
|
|
||||||
|
pay_btn = s('#lilcity-vue-app > div.main.main_default > div > div.main__actions > a[data-popup=".js-popup-buy"]') |
||||||
|
h = s('header.header').size.get('height') |
||||||
|
location = pay_btn.location |
||||||
|
self.driver.execute_script("window.scrollTo({x},{y});".format(x=location['x'], y=location['y'] - h - 10)) |
||||||
|
pay_btn.should(be.visible) |
||||||
|
pay_btn.click() |
||||||
|
|
||||||
|
popup = s('.js-popup-buy') |
||||||
|
popup.should(be.visible) |
||||||
|
|
||||||
|
popup.s('a.buy__btn').click() |
||||||
|
|
||||||
|
SE.switch_iframe_css('[allowpaymentrequest]') |
||||||
|
s('#cardNumber').set_value('4242424242424242') |
||||||
|
s('#inputMonth').set_value('12') |
||||||
|
s('#inputYear').set_value('33') |
||||||
|
s('div.cvv > div > div > input[type="text"]').set_value('333') |
||||||
|
s('#cardHolder').set_value('TEST') |
||||||
|
s('#sizingContainer button[type=submit]').click() |
||||||
|
|
||||||
|
SE.switch_iframe_css('#threeDSContainer > iframe') |
||||||
|
s('#password').set_value('4') |
||||||
|
s('button[type=submit]').click() |
||||||
|
|
||||||
|
SE.switch_iframe_css('[allowpaymentrequest]') |
||||||
|
s('#statusContainer > div.bottom > a.button').click() |
||||||
|
|||||||
Loading…
Reference in new issue