chatbot for one-to-one chats
Signed-off-by: Anton Danchenko <ant.danchenko@gmail.com>
This commit is contained in:
parent
e0e205f565
commit
64589d526f
|
@ -151,14 +151,13 @@ class Driver(webdriver.Remote):
|
||||||
|
|
||||||
class SingleDeviceTestCase(AbstractTestCase):
|
class SingleDeviceTestCase(AbstractTestCase):
|
||||||
|
|
||||||
def setup_method(self, method):
|
def setup_method(self, method, max_duration=1800):
|
||||||
capabilities = {'local': {'executor': self.executor_local,
|
|
||||||
'capabilities': self.capabilities_local},
|
(executor, capabilities) = (self.executor_sauce_lab, self.capabilities_sauce_lab) if \
|
||||||
'sauce': {'executor': self.executor_sauce_lab,
|
self.environment == 'sauce' else (self.executor_local, self.capabilities_local)
|
||||||
'capabilities': self.capabilities_sauce_lab}}
|
capabilities['maxDuration'] = max_duration
|
||||||
|
self.driver = Driver(executor, capabilities)
|
||||||
|
|
||||||
self.driver = Driver(capabilities[self.environment]['executor'],
|
|
||||||
capabilities[self.environment]['capabilities'])
|
|
||||||
test_suite_data.current_test.testruns[-1].jobs[self.driver.session_id] = 1
|
test_suite_data.current_test.testruns[-1].jobs[self.driver.session_id] = 1
|
||||||
self.driver.implicitly_wait(self.implicitly_wait)
|
self.driver.implicitly_wait(self.implicitly_wait)
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ testrail_report = TestrailReport(sauce_username, sauce_access_key)
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
|
|
||||||
parser.addoption("--build",
|
parser.addoption("--build",
|
||||||
action="store",
|
action="store",
|
||||||
default=datetime.now().strftime('%Y-%m-%d-%H-%M'),
|
default=datetime.now().strftime('%Y-%m-%d-%H-%M'),
|
||||||
|
@ -52,6 +53,7 @@ def pytest_addoption(parser):
|
||||||
help='string; ropsten or rinkeby')
|
help='string; ropsten or rinkeby')
|
||||||
|
|
||||||
# message reliability
|
# message reliability
|
||||||
|
|
||||||
parser.addoption('--rerun_count',
|
parser.addoption('--rerun_count',
|
||||||
action='store',
|
action='store',
|
||||||
default=0,
|
default=0,
|
||||||
|
@ -77,6 +79,17 @@ def pytest_addoption(parser):
|
||||||
default=None,
|
default=None,
|
||||||
help='Public key of user for 1-1 chat')
|
help='Public key of user for 1-1 chat')
|
||||||
|
|
||||||
|
# chat bot
|
||||||
|
|
||||||
|
parser.addoption('--public_keys',
|
||||||
|
action='store',
|
||||||
|
default=None,
|
||||||
|
help='List of public keys for one-to-one chats')
|
||||||
|
parser.addoption('--running_time',
|
||||||
|
action='store',
|
||||||
|
default=None,
|
||||||
|
help='Running time in seconds')
|
||||||
|
|
||||||
|
|
||||||
def get_rerun_count():
|
def get_rerun_count():
|
||||||
return int(pytest.config.getoption('rerun_count'))
|
return int(pytest.config.getoption('rerun_count'))
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
import time
|
||||||
|
import pytest
|
||||||
|
import numpy
|
||||||
|
from tests.base_test_case import SingleDeviceTestCase
|
||||||
|
from random import randint
|
||||||
|
from views.sign_in_view import SignInView
|
||||||
|
|
||||||
|
stop = int(time.time()) + int(pytest.config.getoption('running_time'))
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.chatbot
|
||||||
|
class TestChatBot(SingleDeviceTestCase):
|
||||||
|
|
||||||
|
def setup_method(self, method, max_duration=10800):
|
||||||
|
super(TestChatBot, self).setup_method(method, max_duration=10800)
|
||||||
|
|
||||||
|
public_keys = pytest.config.getoption('public_keys').split()
|
||||||
|
repeats = 24 / len(public_keys)
|
||||||
|
|
||||||
|
@pytest.mark.chatbot
|
||||||
|
@pytest.mark.parametrize('key', numpy.repeat(public_keys, repeats))
|
||||||
|
def test_one_to_one_chatbot(self, key):
|
||||||
|
sign_in = SignInView(self.driver)
|
||||||
|
home = sign_in.create_user()
|
||||||
|
chat = home.add_contact(key)
|
||||||
|
|
||||||
|
message_text = 'test'
|
||||||
|
chat.chat_message_input.send_keys(message_text)
|
||||||
|
chat.send_message_button.click()
|
||||||
|
|
||||||
|
message = 'Message # %s, sent by e2e test, to %s '
|
||||||
|
counter = 0
|
||||||
|
while int(time.time()) < stop:
|
||||||
|
counter += 1
|
||||||
|
time.sleep(randint(60, 120))
|
||||||
|
chat.chat_message_input.send_keys(message % (counter, key))
|
||||||
|
chat.send_message_button.click()
|
Loading…
Reference in New Issue