ϪfdZddlmZddlmZddlmZddlmZm Z m Z m Z m Z ddl mZddlmZee Gdd ZGd d eZGd d eZy)z+ Tests for L{twisted.application.service}. ) implementer)BrokenImplementation) verifyObject) ApplicationIProcessIServiceIServiceCollectionService) IPersistable)TestCaseceZdZdZdedededdfdZddZdd Z dd Z de ddfd Z de ddfd Z dd ZddZddZddZy) AlmostServicea Implement IService in a way that can fail. In general, classes should maintain invariants that adhere to the interfaces that they claim to implement -- otherwise, it is a bug. This is a buggy class -- the IService implementation is fragile, and several methods will break it. These bugs are intentional, as the tests trigger them -- and then check that the class, indeed, no longer complies with the interface (IService) that it claims to comply with. Since the verification will, by definition, only fail on buggy classes -- in other words, those which do not actually support the interface they claim to support, we have to write a buggy class to properly verify the interface. nameparentrunningreturnNc.||_||_||_y)N)rrr)selfrrrs G/usr/lib/python3/dist-packages/twisted/application/test/test_service.py__init__zAlmostService.__init__-s   c|`y)z Probably not a wise method to call. This method removes the :code:`name` attribute, which has to exist in IService classes. N)rrs rmakeInvalidByDeletingNamez'AlmostService.makeInvalidByDeletingName2s  Irc|`y)z Probably not a wise method to call. This method removes the :code:`parent` attribute, which has to exist in IService classes. N)rrs rmakeInvalidByDeletingParentz)AlmostService.makeInvalidByDeletingParent;s  Krc|`y)z Probably not a wise method to call. This method removes the :code:`running` attribute, which has to exist in IService classes. N)rrs rmakeInvalidByDeletingRunningz*AlmostService.makeInvalidByDeletingRunningDs  Lrcy)z\ See L{twisted.application.service.IService}. @param name: ignored N)rrs rsetNamezAlmostService.setNameMrcy)z^ See L{twisted.application.service.IService}. @param parent: ignored Nr )rrs rsetServiceParentzAlmostService.setServiceParentTr"rcyz> See L{twisted.application.service.IService}. Nr rs rdisownServiceParentz!AlmostService.disownServiceParent[r"rcyr&r rs rprivilegedStartServicez$AlmostService.privilegedStartService`r"rcyr&r rs r startServicezAlmostService.startServiceer"rcyr&r rs r stopServicezAlmostService.stopServicejr"rrN)__name__ __module__ __qualname____doc__strr boolrrrrobjectr!r$r'r)r+r-r rrrrss&S*<tPT  F t  v $     rrc@eZdZdZd dZd dZd dZd dZd dZd dZ y) ServiceInterfaceTestszK Tests for L{twisted.application.service.IService} implementation. Nc*tddd|_y)z; Build something that implements IService. NF)rrr)r almostServicers rsetUpzServiceInterfaceTests.setUpus+$DQrc8t}tt|y)z. Service implements IService. N)r rr)r myServices rtest_realServicez&ServiceInterfaceTests.test_realService{sI Xy)rc8tt|jy)z4 AlmostService implements IService. N)rrr9rs r test_hasAllz!ServiceInterfaceTests.test_hasAlls Xt112rc|jj|jt5t t |jdddy#1swYyxYw)zI AlmostService with no name does not implement IService. N)r9r assertRaisesrrrrs r test_noNamez!ServiceInterfaceTests.test_noNamesJ 446   3 4 7 4#5#5 6 7 7 7 AAc|jj|jt5t t |jdddy#1swYyxYw)zK AlmostService with no parent does not implement IService. N)r9rrArrrrs r test_noParentz#ServiceInterfaceTests.test_noParentsJ 668   3 4 7 4#5#5 6 7 7 7rCc|jj|jt5t t |jdddy#1swYyxYw)zL AlmostService with no running does not implement IService. N)r9rrArrrrs rtest_noRunningz$ServiceInterfaceTests.test_noRunningsJ 779   3 4 7 4#5#5 6 7 7 7rCr.) r/r0r1r2r:r=r?rBrErGr rrr7r7ps&R *3 777rr7ceZdZdZddZy)ApplicationTestsz? Tests for L{twisted.application.service.Application}. NcZtd}|jttt||jttt ||jtt t ||jtt t |y)zQ Check L{twisted.application.service.Application} instantiation. zapp-nameN)r assertTruerrr rr )rapps rtest_applicationComponentsz+ApplicationTests.test_applicationComponentssn*%  Xx}=>  %79KC9PQR  Xx}=>  \<3DEFrr.)r/r0r1r2rMr rrrIrIs  GrrIN)r2zope.interfacerzope.interface.exceptionsrzope.interface.verifyrtwisted.application.servicerrrr r twisted.persisted.sobr twisted.trial.unittestr rr7rIr rrrTsd ':./+ XT T T n.7H.7bGxGr