SamStationStruct.SamStationStatus.SamStationStatus
python wrapper around the IDL data structure SAMStation.Status
This documentation was generated by and for sam_common_pylib v8_6_0.
IDL definition:
struct Status {
boolean success;
string msg;
}
API Usage Example:
# importing the data structure:
from SamStationStruct.SamStationStatus import SamStationStatus
################################################################################
For educational purposes, the selftest used in validating this
data structure is shown below. Hopefully it will prove to be
illuminating and useful; but for further details, RTFC.
################################################################################
class selftest(SamStructSelftestBaseClass):
def runTest(self):
print("Commencing unit tests of SamStationStatus wrapper class.")
# necessary so that the namespace match (we want our class name
# to be "SamStationStruct.XXX.XXX", not "__main__.XXX")
from SamStationStruct.SamStationStatus import SamStationStatus
try:
print("testing constructors.")
#
# INSERT TESTS OF ALL CONSTRUCTOR FORMS HERE.
s = SamStationStatus(1, 'all good')
assert(s.getSuccess())
assert(s.getMessage() == 'all good')
t = SamStationStatus(s)
assert(t == s)
t1 = SamStationStatus({'success':1, 'msg':'all good'})
assert(t1 == 1)
# INSERT TESTS OF ARGUMENT ERROR CONDITIONS HERE.
try:
print("no args")
x = SamStationStatus()
raise("Did NOT catch ArgumentError")
except SamExceptions.ArgumentError:
pass
# Marshalling/Unmarshalling tests:
print("testing passthrough to dbserver and back.")
from SamStruct.Any import Any
originalObject = SamStationStatus(s)
returnObject = self.proxy().testArbitrarySamDataStructure(originalObject.__class__.__name__,
Any(originalObject))
assert(returnObject == originalObject)
# INSERT TESTS FOR INEQUALITY BETWEEN TWO INSTANCES HERE.
print("testing inequality...")
y = SamStationStatus(0, 'all bad')
assert(y != s)
print("\nAll tests passed. Congratulations.")
return 0
except:
print("TEST FAILED. Bummer.")
self.fail("%s" % sys.exc_info()[1])
return 1
if __name__ == "__main__":
from SamStationStatus import selftest
from SamUtility.SamUnitTest import unitTestRunner
unitTestRunner(selftest)