Worked on modifying test_setting module

This commit is contained in:
cis 2021-07-13 13:07:55 +05:30
parent 1d20859486
commit 7e87ece36b
No known key found for this signature in database
GPG Key ID: 11DC6F36E8B65B24
4 changed files with 22 additions and 11 deletions

View File

@ -1 +0,0 @@
16342

View File

@ -1,6 +1,7 @@
import os import os
import shutil import shutil
import tempfile import tempfile
from time import time, sleep
from telenium.tests import TeleniumTestCase from telenium.tests import TeleniumTestCase
@ -58,5 +59,19 @@ class TeleniumTestProcess(TeleniumTestCase):
self.cli.sleep(seconds) self.cli.sleep(seconds)
def drag(self, xpath1, xpath2): def drag(self, xpath1, xpath2):
self.cli.drag(xpath1, xpath2, 1) """this method is for dragging"""
self.cli.drag(xpath1, xpath2, 1.5)
self.cli.sleep(0.3) self.cli.sleep(0.3)
def assertCheckScrollDown(self, scroll_distance, destination, timeout=-1):
"""this method is for checking scroll"""
start = time()
while True:
if scroll_distance <= destination:
self.assertLessEqual(scroll_distance, destination)
return True
if timeout == -1:
return False
if timeout > 0 and time() - start > timeout:
raise Exception("Timeout")
sleep(0.1)

View File

@ -9,15 +9,15 @@ class SettingScreen(TeleniumTestProcess):
print("=====================Test -Show Setting Screen=====================") print("=====================Test -Show Setting Screen=====================")
self.cli.sleep(3) self.cli.sleep(3)
# this is for opening Nav drawer # this is for opening Nav drawer
self.click_on('//MDActionTopAppBarButton[@icon=\"menu\"]') self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=2)
# checking state of Nav drawer # checking state of Nav drawer
self.assertEqual(self.cli.getattr('//MDNavigationDrawer', 'state'), 'open') self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
# this is for scrolling Nav drawer # this is for scrolling Nav drawer
self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]")
# assert for checking scroll funcation # assert for checking scroll funcation
scroll_distance = self.cli.getattr('//ContentNavigationDrawer//ScrollView[0]', 'scroll_y') scroll_distance = self.cli.getattr('//ContentNavigationDrawer//ScrollView[0]', 'scroll_y')
self.assertLessEqual(scroll_distance, -0.0) self.assertCheckScrollDown(scroll_distance, -0.0, timeout=1)
# this is for opening setting screen # this is for opening setting screen
self.click_on('//NavigationItem[@text=\"Settings\"]') self.cli.wait_click('//NavigationItem[@text=\"Settings\"]', timeout=1)
# Checking current screen # Checking current screen
self.assertExists("//Setting[@name~=\"set\"]", timeout=2) self.assertExists("//Setting[@name~=\"set\"]", timeout=2)

View File

@ -35,6 +35,7 @@ fake_addresses = {
class FakeAddressGenerator(StoppableThread): class FakeAddressGenerator(StoppableThread):
"""A thread for creating fake addresses""" """A thread for creating fake addresses"""
name = "addressGenerator" name = "addressGenerator"
address_list = list(fake_addresses.keys())
def stopThread(self): def stopThread(self):
try: try:
@ -52,11 +53,7 @@ class FakeAddressGenerator(StoppableThread):
queueValue = queues.addressGeneratorQueue.get() queueValue = queues.addressGeneratorQueue.get()
streamNumber = 1 streamNumber = 1
try: try:
if len(BMConfigParser().addresses()) > 0: address = self.address_list.pop(0)
address = list(fake_addresses.keys())[len(BMConfigParser().addresses())]
else:
address = list(fake_addresses.keys())[0]
label = queueValue[3] label = queueValue[3]
BMConfigParser().add_section(address) BMConfigParser().add_section(address)