You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.1 KiB
60 lines
2.1 KiB
# -*- coding: utf-8 -*-
|
|
|
|
import time
|
|
from datetime import datetime, timedelta
|
|
|
|
from django.test import TestCase
|
|
from django.shortcuts import reverse
|
|
from django.utils.timezone import now
|
|
from selene.api import *
|
|
|
|
from project.tests import SeleniumTestCase
|
|
from project.tests.factories import UserFactory, User, CourseFactory, LiveLessonFactory
|
|
from project.utils.selenium_utils import SeleniumExtensions as SE
|
|
|
|
|
|
class PaymentsTestCase(SeleniumTestCase):
|
|
fixtures = ['school_schedules.json']
|
|
|
|
@classmethod
|
|
def setUpTestData(cls):
|
|
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):
|
|
simple_user = UserFactory(role=User.USER_ROLE)
|
|
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()
|
|
|