M test/harness/interface/CDCSerial.py => test/harness/interface/CDCSerial.py +1 -1
@@ 135,7 135,7 @@ class CDCSerial:
@staticmethod
def find_Pures() -> str:
'''
- Return a list of paths (str) to any Mudita Pure phone found connected to the system
+ Return a list of unique paths to all the Mudita Pure phones found connected to the system
'''
import serial.tools.list_ports as list_ports
return [_.device for _ in list_ports.comports() if _.manufacturer == 'Mudita' and _.product == 'Mudita Pure']
M test/pytest/conftest.py => test/pytest/conftest.py +26 -3
@@ 13,6 13,7 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.
from harness import log
from harness.harness import Harness
from harness.interface.error import TestError, Error
+from harness.interface.CDCSerial import CDCSerial as serial
simulator_port = 'simulator'
@@ 48,10 49,13 @@ def sms_text(request):
@pytest.fixture(scope='session')
def harness(request):
+ '''
+ Try to init one Pure phone with serial port path or automatically
+ '''
port_name = request.config.option.port
- RETRY_EVERY = 0.7 # second
- retries = request.config.option.timeout / RETRY_EVERY
+ RETRY_EVERY_SECONDS = 0.7
+ retries = request.config.option.timeout / RETRY_EVERY_SECONDS
if port_name is None:
log.warning("no port provided! trying automatic detection")
@@ 71,7 75,7 @@ def harness(request):
file = open("/tmp/purephone_pts_name", "r")
break
except FileNotFoundError as err:
- time.sleep(RETRY_EVERY)
+ time.sleep(RETRY_EVERY_SECONDS)
retries -= 1
log.info("waiting for simulator port...")
else:
@@ 86,11 90,30 @@ def harness(request):
harness = Harness(port_name)
return harness
+
+@pytest.fixture(scope='session')
+def harnesses():
+ '''
+ Automatically init at least two Pure phones
+ '''
+ found_pures = serial.find_Pures()
+ harnesses = [Harness(pure) for pure in found_pures]
+ if not len(harnesses) >= 2:
+ pytest.skip("At least two phones are needed for this test")
+ assert len(harnesses) >= 2
+ return harnesses
+
@pytest.fixture(scope='session')
def phone_unlocked(harness):
harness.unlock_phone()
assert harness.is_phone_unlocked
+@pytest.fixture(scope='session')
+def phone_unlocked(harnesses):
+ for harness in harnesses:
+ harness.unlock_phone()
+ assert harness.is_phone_unlocked
+
def pytest_configure(config):
config.addinivalue_line("markers",
"service_desktop_test: mark test if it's related to service-desktop API")
A test/pytest/test_two_phones.py => test/pytest/test_two_phones.py +42 -0
@@ 0,0 1,42 @@
+# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+import time
+import pytest
+
+from test_call import get_calllog_count, test_call as call
+from test_call_back import test_call as call_back
+
+
+@pytest.fixture(scope='function')
+def two_phones_available(harnesses):
+ assert len(harnesses) == 2
+
+@pytest.mark.rt1051
+@pytest.mark.usefixtures("phone_unlocked")
+@pytest.mark.usefixtures("two_phones_available")
+def test_call_number(harnesses, phone_number, call_duration):
+ role_calling = harnesses[1]
+ role_receiving = harnesses[0]
+
+ reciving_calllog_count = get_calllog_count(role_receiving)
+
+ call(role_calling, phone_number, call_duration) # asserts calling calllog count
+
+ time.sleep(1) # let the db transactions settle…
+ assert (get_calllog_count(role_receiving) == reciving_calllog_count + 1)
+
+
+@pytest.mark.rt1051
+@pytest.mark.usefixtures("phone_unlocked")
+@pytest.mark.usefixtures("two_phones_available")
+def test_call_back(harnesses, phone_number, call_duration):
+ role_calling = harnesses[0]
+ role_receiving = harnesses[1]
+
+ reciving_calllog_count = get_calllog_count(role_receiving)
+
+ call_back(role_calling, call_duration)
+
+ time.sleep(1) # let the db transactions settle…
+ assert (get_calllog_count(role_receiving) == reciving_calllog_count + 1)