chatbot for one-to-one chats

Signed-off-by: Anton Danchenko <ant.danchenko@gmail.com>
This commit is contained in:
Anton Danchenko 2018-09-04 00:18:18 +03:00
parent e0e205f565
commit 64589d526f
No known key found for this signature in database
GPG Key ID: C2D4819B698627E4
3 changed files with 56 additions and 7 deletions

View File

@ -151,14 +151,13 @@ class Driver(webdriver.Remote):
class SingleDeviceTestCase(AbstractTestCase):
def setup_method(self, method):
capabilities = {'local': {'executor': self.executor_local,
'capabilities': self.capabilities_local},
'sauce': {'executor': self.executor_sauce_lab,
'capabilities': self.capabilities_sauce_lab}}
def setup_method(self, method, max_duration=1800):
(executor, capabilities) = (self.executor_sauce_lab, self.capabilities_sauce_lab) if \
self.environment == 'sauce' else (self.executor_local, self.capabilities_local)
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
self.driver.implicitly_wait(self.implicitly_wait)

View File

@ -22,6 +22,7 @@ testrail_report = TestrailReport(sauce_username, sauce_access_key)
def pytest_addoption(parser):
parser.addoption("--build",
action="store",
default=datetime.now().strftime('%Y-%m-%d-%H-%M'),
@ -52,6 +53,7 @@ def pytest_addoption(parser):
help='string; ropsten or rinkeby')
# message reliability
parser.addoption('--rerun_count',
action='store',
default=0,
@ -77,6 +79,17 @@ def pytest_addoption(parser):
default=None,
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():
return int(pytest.config.getoption('rerun_count'))

View File

@ -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()