Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/python/espressomd/zn.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ def _start_zndraw(self):
time.sleep(0.5)

url = f"{self.url}:{self.SERVER_PORT}"
self.zndraw = zndraw.zndraw.ZnDrawLocal(
r=self.r, url=url, token=self.token, timeout=config)
self.zndraw = zndraw.zndraw.ZnDraw(
url=url, token=self.token, timeout=config)
Comment on lines +522 to +523

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend not using internal zndraw modules and use from zndraw import ZnDraw.

parsed_url = urllib.parse.urlparse(
f"{self.zndraw.url}/token/{self.zndraw.token}")
self.address = parsed_url._replace(scheme="http").geturl()
Expand Down
58 changes: 58 additions & 0 deletions testsuite/python/zn_interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import unittest
import time
import espressomd.zn
from selenium import webdriver
from selenium.webdriver.common.by import By

system = espressomd.System(box_l=[1] * 3)
vis = espressomd.zn.Visualizer(system)
url = vis.address

# Default Methods
method_list = [['ConnectedParticles', 'NoneSelection', 'All', 'Invert', 'Range', 'Random', 'IdenticalSpecies', 'Neighbour'],
['Delete', 'Rotate', 'Translate', 'Duplicate', 'ChangeType', 'AddLineParticles',
'Wrap', 'Center', 'Replicate', 'Connect', 'NewCanvas', 'RemoveAtoms'],
['Plane', 'Sphere', 'Box', 'Circle', 'Cone', 'Cylinder', 'Dodecahedron', 'Icosahedron',
'Octahedron', 'Ring', 'Tetrahedron', 'Torus', 'TorusKnot', 'Rhomboid', 'Ellipsoid'],
['Properties1D', 'DihedralAngle', 'Distance', 'Properties2D']]


def s(t=1):
time.sleep(t)


class RegisterTestCase(unittest.TestCase):
def setUp(self):
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("headless")
self.driver = webdriver.Chrome(options=chrome_options)
self.driver.get(url)

def tearDown(self):
self.driver.quit()

def test_register(self):
next_option_names = []
idx = 0
driver = self.driver
buttons = driver.find_elements(
By.XPATH, '//button[@class="btn btn-outline-tertiary"]')
for button in buttons:
button.click()
s(t=0.1)
elements = driver.find_elements(By.ID, "root[method]switcher")
j = len(elements) - 1
options = [x for x in elements[j].find_elements(
By.TAG_NAME, "option")]
option_names = [x.get_attribute("value") for x in options]
if option_names == next_option_names:
continue
else:
assert option_names == method_list[idx], f"Difference: {
set(option_names) ^ set(method_list[idx])}"
idx += 1
next_option_names = option_names
Comment on lines +34 to +54

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a good chance this will break for future versions of ZnDraw for several reasons

Are there any ZnDraw extensions currently used by Espresso or within any tutorial?



if __name__ == "__main__":
unittest.main()