Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 905d014

Browse files
author
Michael Smith
committed
Fixed test for large number of contracts
1 parent 081db8c commit 905d014

1 file changed

Lines changed: 51 additions & 4 deletions

File tree

applications/multisite/multisite_test.py

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from selenium import webdriver
2+
from selenium.common.exceptions import NoSuchElementException
23
from selenium.webdriver.common.keys import Keys
34
from acitoolkit.acitoolkit import *
45
import time
@@ -27,13 +28,23 @@
2728
class TestBasicExport(unittest.TestCase):
2829
@staticmethod
2930
def _start_server(db_filename, server_port):
31+
"""
32+
Start the GUI server application using a certain filename and TCP port
33+
34+
:param db_filename: String containing the database filename
35+
:param server_port: String containing the TCP L4 port number to host the application
36+
"""
3037
os.environ["MULTISITE_DATABASE_FILE"] = db_filename
3138
subprocess.call(["rm", "-rf", db_filename])
3239
subprocess.Popen(["python", "multisite-gui.py", "--port", server_port, "--test"])
3340
time.sleep(1)
3441

3542
@classmethod
3643
def setUpClass(cls):
44+
"""
45+
Set up the test environment
46+
Run the application for 2 sites and start a web browser to access them
47+
"""
3748
# Run the multisite tool for first site
3849
cls._start_server('site1_db.sqlite', '5000')
3950

@@ -44,6 +55,17 @@ def setUpClass(cls):
4455
cls.driver = webdriver.Firefox()
4556

4657
def _enter_credentials(self, driver, site_name, ip_address, user_name, password, local):
58+
"""
59+
Enter the site credentials into the GUI
60+
61+
:param driver: Instance of webdriver
62+
:param site_name: String containing the site name
63+
:param ip_address: String containing the APIC IP address of the site
64+
:param user_name: String containing the APIC username of the site
65+
:param password: String containing the APIC password of the site
66+
:param local: True or False. True if this site is the local site for the tool.
67+
:return: None
68+
"""
4769
# Enter the Site 1 credentials
4870
typing = [('site_name', site_name),
4971
('ip_address', ip_address),
@@ -57,6 +79,14 @@ def _enter_credentials(self, driver, site_name, ip_address, user_name, password,
5779
input_elem.click()
5880

5981
def _login_session(self, url, login, password):
82+
"""
83+
Login to a particular APIC
84+
85+
:param url: String containing the URL to login to the APIC
86+
:param login: String containing the username to login to the APIC
87+
:param password: String containing the password to login to the APIC
88+
:return: Instance of Session class
89+
"""
6090
session = Session(url, login, password)
6191
resp = session.login()
6292
self.assertTrue(resp.ok)
@@ -122,9 +152,16 @@ def test_01_site1(self):
122152
def test_02_site2(self):
123153
self.setup_site('http://127.0.0.1:5001', site1_local=False)
124154

125-
# TODO test removing a site
126-
# TODO test adding the same site twice
127-
# TODO
155+
# def test_03_remove_site1(self):
156+
# pass # TODO implement and renumber tests
157+
#
158+
# def test_04_remove_site2(self):
159+
# pass # TODO implement and renumber tests
160+
#
161+
# def test_05_add_same_site_twice
162+
# # TODO test removing a site
163+
# # TODO test adding the same site twice
164+
# # TODO
128165

129166
def test_03_export_contract(self):
130167
driver = self.__class__.driver
@@ -135,7 +172,17 @@ def test_03_export_contract(self):
135172
driver.find_element_by_link_text('Site Contracts').click()
136173

137174
# Select the contract to export
138-
driver.find_element_by_xpath("//td[contains(text(),'multisite')]/preceding-sibling::td/input[@name='rowid']").click()
175+
page_number = '2'
176+
loop_again = True
177+
while (loop_again):
178+
loop_again = False
179+
try:
180+
#driver.find_element_by_xpath("//td[contains(text(),'multisite')]/preceding-sibling::td/input[@name='rowid']").click()
181+
driver.find_element_by_xpath("//td[text()='multisite']/preceding-sibling::td/input[@name='rowid']").click()
182+
except NoSuchElementException:
183+
loop_again = True
184+
driver.find_element_by_link_text(page_number).click()
185+
page_number = str(int(page_number) + 1)
139186

140187
# Select the pulldown
141188
driver.find_element_by_link_text('With selected').click()

0 commit comments

Comments
 (0)