def test_service_serialization(self): srv = Service(name="http") srv.setDescription("Some description") srv.setOwned(True) srv.setProtocol("tcp") srv.setPorts(80) srv.setStatus("open") srv.setVersion("Apache 2.4") sserialized = self.smapper.serialize(srv) # if serialization fails, returns None self.assertNotEqual(sserialized, None, "Serialized service shouldn't be None") # we check the service attributes self.assertEquals(sserialized.get("_id"), srv.getID(), "Serialized ID is not the same as Service ID") self.assertEquals(sserialized.get("name"), srv.getName(), "Serialized name is not the same as Service name") self.assertEquals( sserialized.get("protocol"), srv.getProtocol(), "Serialized protocol is not the same as Service protocol") self.assertEquals( sserialized.get("status"), srv.getStatus(), "Serialized status is not the same as Service status") self.assertEquals(sserialized.get("ports"), srv.getPorts(), "Serialized ports is not the same as Service ports") self.assertEquals( sserialized.get("description"), srv.getDescription(), "Serialized description is not the same as Interface description") self.assertEquals( sserialized.get("owned"), srv.isOwned(), "Serialized owned flag is not the same as Interface owned flag")
def test_service_creation(self): srv = Service(name="http") srv.setDescription("Some description") srv.setOwned(True) srv.setProtocol("tcp") srv.setPorts(80) srv.setStatus("open") srv.setVersion("Apache 2.4") self.smapper.save(srv) s = self.smapper.find(srv.getID()) self.assertEquals(s, srv, "Service retrieved should be the same as persisted") self.assertEquals( s.getID(), srv.getID(), "Service retrieved's Id should be the same as persisted's Id")
def test_service_creation(self): srv = Service(name="http") srv.setDescription("Some description") srv.setOwned(True) srv.setProtocol("tcp") srv.setPorts(80) srv.setStatus("open") srv.setVersion("Apache 2.4") self.smapper.save(srv) s = self.smapper.find(srv.getID()) self.assertEquals( s, srv, "Service retrieved should be the same as persisted") self.assertEquals( s.getID(), srv.getID(), "Service retrieved's Id should be the same as persisted's Id")
def test_service_serialization(self): srv = Service(name="http") srv.setDescription("Some description") srv.setOwned(True) srv.setProtocol("tcp") srv.setPorts(80) srv.setStatus("open") srv.setVersion("Apache 2.4") sserialized = self.smapper.serialize(srv) # if serialization fails, returns None self.assertNotEqual( sserialized, None, "Serialized service shouldn't be None") # we check the service attributes self.assertEquals( sserialized.get("_id"), srv.getID(), "Serialized ID is not the same as Service ID") self.assertEquals( sserialized.get("name"), srv.getName(), "Serialized name is not the same as Service name") self.assertEquals( sserialized.get("protocol"), srv.getProtocol(), "Serialized protocol is not the same as Service protocol") self.assertEquals( sserialized.get("status"), srv.getStatus(), "Serialized status is not the same as Service status") self.assertEquals( sserialized.get("ports"), srv.getPorts(), "Serialized ports is not the same as Service ports") self.assertEquals( sserialized.get("description"), srv.getDescription(), "Serialized description is not the same as Interface description") self.assertEquals( sserialized.get("owned"), srv.isOwned(), "Serialized owned flag is not the same as Interface owned flag")