11-15-2019, 08:57 PM
I am trying to create a unit test suite to test the validity/existence of multiple Items in my RoboDK station. The station is opened each time the tests are run, so after running the tests few times the station tree becomes extremely crowded with multiple copies of the original station. To avoid having to repeatedly close each copy individually, I would like to write a cleanup method to close the station after the tests are finished. The method 'CloseStation()' defined in the Robolink Python API seems to be exactly what I am looking for, but the documentation is not very clear on how it is meant to be used and everything I try seems to cause errors. Can someone please explain the proper usage of this method? Sample code of it working would be extremely helpful.
Below is the code I have tried so far and the corresponding results. It seems to me that the first code snippet should be the correct usage since CloseStation() is defined as a member of the class Robolink() in robolink.py.
1.) Calling the method directly on a Robolink() object:
Code:
Result (from console):
2.) Calling the method on a station Item object:
Code:
Result:
Below is the code I have tried so far and the corresponding results. It seems to me that the first code snippet should be the correct usage since CloseStation() is defined as a member of the class Robolink() in robolink.py.
1.) Calling the method directly on a Robolink() object:
Code:
Quote:"robolink.Robolink().CloseStation()"
Result (from console):
Quote: line 521, in _check_status
raise Exception(self.LAST_STATUS_MESSAGE)
Exception: Invalid item provided: The item identifier provided is not valid or it does not exist.
2.) Calling the method on a station Item object:
Code:
Quote:station = robolink.Robolink().ActiveStation()
station.CloseStation()
Result:
Quote:AttributeError: 'Item' object has no attribute 'CloseStation'