Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
supervisor / tests / __pycache__ / test_events.cpython-38.pyc
Size: Mime:
U

VƧ\¸Qã@s¨ddlZddlZddlmZddlmZddlmZddlmZGdd„dejƒZGdd	„d	ejƒZ	Gd
d„dejƒZ
Gdd
„d
ejƒZdd„Ze
dkr¤ejdddS)éN)ÚDummyOptions)ÚDummyPConfig)ÚDummyProcess)Ú
DummyEventc@sLeZdZdd„Zdd„Zdd„Zdd„Zd	d
„Zdd„Zd
d„Z	dd„Z
dS)Ú"EventSubscriptionNotificationTestscCsddlm}g|jdd…<dS©Nr©Úevents©Ú
supervisorr	Ú	callbacks©Úselfr	©rú+./build/lib/supervisor/tests/test_events.pyÚsetUp
sz(EventSubscriptionNotificationTests.setUpcCsddlm}g|jdd…<dSrr
r
rrrÚtearDownsz+EventSubscriptionNotificationTests.tearDowncCs,ddlm}| dd¡| |jdg¡dS©Nrr)NN)rr	Z	subscribeÚassertEqualrr
rrrÚtest_subscribesz1EventSubscriptionNotificationTests.test_subscribecCsBddlm}dddg|jdd…<| dd¡| |jddg¡dS)Nrr)ér)ér)érr)rr	rZunsubscriberr
rrrÚtest_unsubscribesz3EventSubscriptionNotificationTests.test_unsubscribecCs6ddlm}dg|jdd…<| ¡| |jg¡dSr)rr	rÚclearrr
rrrÚ
test_clearsz-EventSubscriptionNotificationTests.test_clearcsNddlm}g‰‡fdd„}t|fg|jdd…<| tƒ¡| ˆdg¡dS)Nrrcsˆ d¡dS©Nr©Úappend©Úevent©ÚLrrÚcallback&szEEventSubscriptionNotificationTests.test_notify_true.<locals>.callbackr©rr	rrÚnotifyr)rr	r#rr!rÚtest_notify_true#sz3EventSubscriptionNotificationTests.test_notify_truecsZddlm}g‰‡fdd„}Gdd„dƒ}||fg|jdd…<| tƒ¡| ˆg¡dS)Nrrcsˆ d¡dSrrrr!rrr#/szFEventSubscriptionNotificationTests.test_notify_false.<locals>.callbackc@seZdZdS)zJEventSubscriptionNotificationTests.test_notify_false.<locals>.AnotherEventN©Ú__name__Ú
__module__Ú__qualname__rrrrÚAnotherEvent1sr+)rr	rr%rr)rr	r#r+rr!rÚtest_notify_false,sz4EventSubscriptionNotificationTests.test_notify_falsecs^ddlm}g‰‡fdd„}Gdd„dtƒ}t|fg|jdd…<| |ƒ¡| ˆdg¡dS)Nrrcsˆ d¡dSrrrr!rrr#:szMEventSubscriptionNotificationTests.test_notify_via_subclass.<locals>.callbackc@seZdZdS)zSEventSubscriptionNotificationTests.test_notify_via_subclass.<locals>.ASubclassEventNr'rrrrÚASubclassEvent<sr-rr$)rr	r#r-rr!rÚtest_notify_via_subclass7sz;EventSubscriptionNotificationTests.test_notify_via_subclassN)r(r)r*rrrrrr&r,r.rrrrr	s	rc@sÌeZdZdd„Zdd„Zdd„Zdd„Zd	d
„Zdd„Zd
d„Z	dd„Z
dd„Zdd„Zdd„Z
dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1S)2ÚTestEventTypescCsFddlm}|dddƒ}| |jd¡| |jd¡| |jd¡dS)Nr©ÚProcessLogEventrrr)Úsupervisor.eventsr1rÚprocessÚpidÚdata)rr1ÚinstrrrÚtest_ProcessLogEvent_attributesDs
z.TestEventTypes.test_ProcessLogEvent_attributescCs,ddlm}ddlm}| t||ƒ¡dS)Nrr0©ÚEvent)r2r1r9Ú
assertTrueÚ
issubclass)rr1r9rrrÚ test_ProcessLogEvent_inheritenceKs
ÿz/TestEventTypes.test_ProcessLogEvent_inheritencecCsTddlm}|dddƒ}| |jd¡| |jd¡| |jd¡| |jd¡dS)Nr©ÚProcessLogStdoutEventrrrÚstdout)r2r>rr3r4r5Úchannel)rr>r6rrrÚ%test_ProcessLogStdoutEvent_attributesRsz4TestEventTypes.test_ProcessLogStdoutEvent_attributescCs,ddlm}ddlm}| t||ƒ¡dS)Nrr=r0)r2r>r1r:r;)rr>r1rrrÚ&test_ProcessLogStdoutEvent_inheritenceZs
ÿz5TestEventTypes.test_ProcessLogStdoutEvent_inheritencecCsTddlm}|dddƒ}| |jd¡| |jd¡| |jd¡| |jd¡dS)Nr©ÚProcessLogStderrEventrrrÚstderr)r2rDrr3r4r5r@)rrDr6rrrÚ%test_ProcessLogStderrEvent_attributesasz4TestEventTypes.test_ProcessLogStderrEvent_attributescCs,ddlm}ddlm}| t||ƒ¡dS)NrrCr0)r2rDr1r:r;)rrDr1rrrÚ&test_ProcessLogStderrEvent_inheritenceis
ÿz5TestEventTypes.test_ProcessLogStderrEvent_inheritencecCsFddlm}|dddƒ}| |jd¡| |jd¡| |jd¡dS)Nr©ÚProcessCommunicationEventrrr)r2rIrr3r4r5)rrIr6rrrÚ)test_ProcessCommunicationEvent_attributesps
z8TestEventTypes.test_ProcessCommunicationEvent_attributescCs,ddlm}ddlm}| t||ƒ¡dS)NrrHr8)r2rIr9r:r;)rrIr9rrrÚ*test_ProcessCommunicationEvent_inheritencews
ÿz9TestEventTypes.test_ProcessCommunicationEvent_inheritencecCsTddlm}|dddƒ}| |jd¡| |jd¡| |jd¡| |jd¡dS)Nr©ÚProcessCommunicationStdoutEventrrrr?)r2rMrr3r4r5r@)rrMr6rrrÚ/test_ProcessCommunicationStdoutEvent_attributes~sz>TestEventTypes.test_ProcessCommunicationStdoutEvent_attributescCs,ddlm}ddlm}| t||ƒ¡dS)NrrLrH)r2rMrIr:r;)rrMrIrrrÚ0test_ProcessCommunicationStdoutEvent_inheritence†sÿÿz?TestEventTypes.test_ProcessCommunicationStdoutEvent_inheritencecCsTddlm}|dddƒ}| |jd¡| |jd¡| |jd¡| |jd¡dS)Nr©ÚProcessCommunicationStderrEventrrrrE)r2rQrr3r4r5r@)rrQr6rrrÚ/test_ProcessCommunicationStderrEvent_attributesŽsz>TestEventTypes.test_ProcessCommunicationStderrEvent_attributescCs,ddlm}ddlm}| t||ƒ¡dS)NrrPrH)r2rQrIr:r;)rrQrIrrrÚ0test_ProcessCommunicationStderrEvent_inheritence–sÿÿz?TestEventTypes.test_ProcessCommunicationStderrEvent_inheritencecCs6ddlm}|ddƒ}| |jd¡| |jd¡dS)Nr©ÚRemoteCommunicationEventrr)r2rUrÚtyper5)rrUr6rrrÚ(test_RemoteCommunicationEvent_attributesžs
z7TestEventTypes.test_RemoteCommunicationEvent_attributescCs,ddlm}ddlm}| t||ƒ¡dS)NrrTr8)r2rUr9r:r;)rrUr9rrrÚ)test_RemoteCommunicationEvent_inheritence¤s
ÿz8TestEventTypes.test_RemoteCommunicationEvent_inheritencecCsXddlm}tƒ}t|dddƒ}t|ƒ}tƒ}|||ƒ}| |j|¡| |j|¡dS)Nr©ÚEventRejectedEventÚprocess1ú
/bin/process1)	r2rZrrrrrr3r )rrZÚoptionsÚpconfig1r3Zrejected_eventr rrrÚ"test_EventRejectedEvent_attributes«s
z1TestEventTypes.test_EventRejectedEvent_attributescCs,ddlm}ddlm}| t||ƒ¡dS)NrrYr8)r2rZr9ÚassertFalser;)rrZr9rrrÚ3test_EventRejectedEvent_does_not_inherit_from_eventµs
ÿzBTestEventTypes.test_EventRejectedEvent_does_not_inherit_from_eventcCs0ddlm}|j|j|jfD]}| |¡qdSr)rr	ÚSupervisorStateChangeEventÚSupervisorRunningEventZSupervisorStoppingEventÚ$_test_one_SupervisorStateChangeEvent©rr	ÚklassrrrÚ$test_all_SupervisorStateChangeEvents¼sýz3TestEventTypes.test_all_SupervisorStateChangeEventscCs ddlm}| t||ƒ¡dS)Nr)rb)r2rbr:r;)rrfrbrrrrdÅsz3TestEventTypes._test_one_SupervisorStateChangeEventc	CsHddlm}|j|j|j|j|j|j|j|j	|j
f	D]}| |¡q4dSr)rr	ÚProcessStateEventÚProcessStateStoppedEventÚProcessStateExitedEventÚProcessStateFatalEventÚProcessStateBackoffEventÚProcessStateRunningEventÚProcessStateUnknownEventÚProcessStateStoppingEventÚProcessStateStartingEventÚ_test_one_ProcessStateEventrerrrÚtest_all_ProcessStateEventsÉs÷z*TestEventTypes.test_all_ProcessStateEventscCs€ddlm}ddlm}| t||ƒ¡tƒ}t|dddƒ}t|ƒ}|||j	ƒ}| 
|j|¡| 
|j|j	¡| 
|j
d¡dS)Nr©Ú
ProcessStates)rhr[r\T)Úsupervisor.statesrtr2rhr:r;rrrÚSTARTINGrr3Ú
from_stateÚexpected)rrfrtrhr]r^r3r6rrrrqØsz*TestEventTypes._test_one_ProcessStateEventcCs4ddlm}|j|j|j|jfD]}| |¡q dSr)rr	Ú	TickEventÚ
Tick5EventÚTick60EventÚ
Tick3600EventÚ_test_one_TickEventrerrrÚtest_all_TickEventsäsüz"TestEventTypes.test_all_TickEventscCsFddlm}| t||ƒ¡|ddƒ}| |jd¡| |jd¡dS)Nr)ryrr)r2ryr:r;rÚwhenZsupervisord)rrfryr6rrrr}îs

z"TestEventTypes._test_one_TickEventcCs&ddlm}|dƒ}| |jd¡dS)Nr©ÚProcessGroupAddedEventÚ	myprocess)r2rrÚgroup)rrr6rrrÚ&test_ProcessGroupAddedEvent_attributesösz5TestEventTypes.test_ProcessGroupAddedEvent_attributescCs&ddlm}|dƒ}| |jd¡dS)Nr©ÚProcessGroupRemovedEventr‚)r2r†rrƒ)rr†r6rrrÚ(test_ProcessGroupRemovedEvent_attributesûsz7TestEventTypes.test_ProcessGroupRemovedEvent_attributesN)r(r)r*r7r<rArBrFrGrJrKrNrOrRrSrWrXr_rargrdrrrqr~r}r„r‡rrrrr/Cs0
	
r/c@s„eZdZdd„Zdd„Zdd„Zdd„Zd	d
„Zdd„Zd
d„Z	dd„Z
dd„Zdd„Zdd„Z
dd„Zdd„Zdd„Zdd„ZdS) ÚTestSerializationscCsv| d¡}|d}d}i}t|ƒdkr.|d}|rnztdd„| ¡Dƒƒ}Wn tk
rltd|ƒ‚YnX||fS)NÚ
rÚrcSsg|]}| dd¡‘qS)ú:r)Úsplit)Ú.0ÚxrrrÚ
<listcomp>
sz3TestSerializations._deserialize.<locals>.<listcomp>z'headerdata %r could not be deserialized)rŒÚlenÚdictÚ
ValueErrorÚAssertionError)rZ
serializationr5Z
headerdataÚpayloadÚheadersrrrÚ_deserializes 
ÿÿzTestSerializations._deserializecs¤tƒ}t|dddƒ‰tˆƒ}ddlm}G‡fdd„dƒ}||_||ddƒ}| | ¡¡\}}| |d	d|¡| |d
d|¡| |dd|¡| |d¡dS)
Nr[r\rr=cseZdZ”ZdS)z=TestSerializations.test_plog_stdout_event.<locals>.DummyGroupN©r(r)r*Zconfigr©r^rrÚ
DummyGroupsr™rÚyoÚprocessnameÚ	groupnamer4Ú1)	rrrr2r>rƒr–r”r)rr]r[r>r™r r•r”rr˜rÚtest_plog_stdout_eventsz)TestSerializations.test_plog_stdout_eventcs¤tƒ}t|dddƒ‰tˆƒ}ddlm}G‡fdd„dƒ}||_||ddƒ}| | ¡¡\}}| |d	d|¡| |d
d|¡| |dd|¡| |d¡dS)
Nr[r\rrCcseZdZ”ZdS)z=TestSerializations.test_plog_stderr_event.<locals>.DummyGroupNr—rr˜rrr™%sr™rršr›rœr4r)	rrrr2rDrƒr–r”r)rr]r[rDr™r r•r”rr˜rÚtest_plog_stderr_event sz)TestSerializations.test_plog_stderr_eventcs¤tƒ}t|dddƒ‰tˆƒ}ddlm}G‡fdd„dƒ}||_||ddƒ}| | ¡¡\}}| |d	d|¡| |d
d|¡| |dd|¡| |d¡dS)
Nr[r\rrLcseZdZ”ZdS)z>TestSerializations.test_pcomm_stdout_event.<locals>.DummyGroupNr—rr˜rrr™4sr™rršr›rœr4r)	rrrr2rMrƒr–r”r)rr]r[rMr™r r•r”rr˜rÚtest_pcomm_stdout_event/sz*TestSerializations.test_pcomm_stdout_eventcs¤tƒ}t|dddƒ‰tˆƒ}G‡fdd„dƒ}||_ddlm}||ddƒ}| | ¡¡\}}| |d	d|¡| |d
d|¡| |dd|¡| |d¡dS)
Nr[r\cseZdZ”ZdS)z>TestSerializations.test_pcomm_stderr_event.<locals>.DummyGroupNr—rr˜rrr™Bsr™rrPrršr›rœr4r)	rrrrƒr2rQr–r”r)rr]r[r™rQr r•r”rr˜rÚtest_pcomm_stderr_event>sz*TestSerializations.test_pcomm_stderr_eventcCsJddlm}|ddƒ}| | ¡¡\}}| |dd|¡| |d¡dS)NrrTÚfooZbarrV)r2rUr–r”r)rrUr r•r”rrrÚtest_remote_comm_eventMs

z)TestSerializations.test_remote_comm_eventcCsFddlm}|dƒ}| | ¡¡\}}| |dd¡| |d¡dS)Nrr€r¢rœrŠ)r2rr–r”r)rrr r•r”rrrÚtest_process_group_added_eventTs
z1TestSerializations.test_process_group_added_eventcCsFddlm}|dƒ}| | ¡¡\}}| |dd¡| |d¡dS)Nrr…r¢rœrŠ)r2r†r–r”r)rr†r r•r”rrrÚ test_process_group_removed_event[s
z3TestSerializations.test_process_group_removed_eventc
sÌddlm}ddlm}|j|jfD]¢}tƒ}t|dddƒ‰G‡fdd„dƒ}tˆƒ}||_	|||j
ƒ}| | ¡¡\}}	| 
t|ƒd¡| 
|d	d¡| 
|d
d¡| 
|dd¡| 
|	d
¡q$dS)Nrrsrr[r\cseZdZ”ZdS)zUTestSerializations.test_process_state_events_without_extra_values.<locals>.DummyGroupNr—rr˜rrr™lsr™rr›rœrwrvrŠ)rurtrr	rkrnrrrrƒrvr–r”rr©
rrtr	rfr]r™r[r r•r”rr˜rÚ.test_process_state_events_without_extra_valuesbs&þÿzATestSerializations.test_process_state_events_without_extra_valuesc
sæddlm}ddlm}|j|j|jfD]¸}tƒ}t|dddƒ‰G‡fdd„dƒ}t	ˆƒ}||_
d|_|||jƒ}| 
| ¡¡\}}	| t|ƒd	¡| |d
d¡| |dd¡| |dd
¡| |dd¡| |	d¡q(dS)Nrrsrr[r\cseZdZ”ZdS)zITestSerializations.test_process_state_events_with_pid.<locals>.DummyGroupNr—rr˜rrr™ƒsr™rér›rœrwrvr4rrŠ)rurtrr	rmrirorrrrƒr4rvr–r”rrr¦rr˜rÚ"test_process_state_events_with_pidxs,ýÿz5TestSerializations.test_process_state_events_with_pidc
sFddlm}ddlm}|j|jfD]}tƒ}t|dddƒ‰G‡fdd„dƒ}tˆƒ}||_	|||j
ƒ}| | ¡¡\}}	| 
t|ƒd¡| 
|d	d¡| 
|d
d¡| 
|dd¡| 
|d
d¡| 
|	d¡d|_|||j
ƒ}| | ¡¡\}}	| 
|d
d¡d|_|||j
ƒ}| | ¡¡\}}	| 
|d
d¡q$dS)Nrrsrr[r\cseZdZ”ZdS)zUTestSerializations.test_process_state_events_starting_and_backoff.<locals>.DummyGroupNr—rr˜rrr™›sr™r¨r›rœrwrvZtriesÚ0rŠrrrÚ2)rurtrr	rprlrrrrƒrvr–r”rrZbackoffr¦rr˜rÚ.test_process_state_events_starting_and_backoff‘s8þ
ÿzATestSerializations.test_process_state_events_starting_and_backoffc	sæddlm}ddlm}tƒ}t|dddƒ‰tˆƒ}G‡fdd„dƒ}||_d|_|j	||j
d	d
}| | ¡¡\}}| 
t|ƒd¡| 
|dd¡| 
|d
d¡| 
|dd¡| 
|dd¡| 
|dd¡| 
|d¡dS)Nrrrsr[r\cseZdZ”ZdS)zOTestSerializations.test_process_state_exited_event_expected.<locals>.DummyGroupNr—rr˜rrr™¶sr™rT©rxér›rœr4rrwrvrxrŠ©rr	rurtrrrrƒr4rjrvr–r”rr©	rr	rtr]r[r™r r•r”rr˜rÚ(test_process_state_exited_event_expected°s(þz;TestSerializations.test_process_state_exited_event_expectedc	sæddlm}ddlm}tƒ}t|dddƒ‰tˆƒ}G‡fdd„dƒ}||_d|_|j	||j
d	d
}| | ¡¡\}}| 
t|ƒd¡| 
|dd¡| 
|d
d¡| 
|dd¡| 
|dd¡| 
|dd¡| 
|d¡dS)Nrrrsr[r\cseZdZ”ZdS)zQTestSerializations.test_process_state_exited_event_unexpected.<locals>.DummyGroupNr—rr˜rrr™Ìsr™rFr­r®r›rœr4rrwrvrxrªrŠr¯r°rr˜rÚ*test_process_state_exited_event_unexpectedÆs(þz=TestSerializations.test_process_state_exited_event_unexpectedcCsBddlm}| ¡}| | ¡¡\}}| |i¡| |d¡dS)NrrrŠ)rr	rcr–r”r)rr	r r•r”rrrÚtest_supervisor_sc_eventÜs
z+TestSerializations.test_supervisor_sc_eventcCs^ddlm}|j|j|jfD]<}|ddƒ}| | ¡¡\}}| |ddi¡| |d¡qdS)NrrrrrrrŠ)rr	rzr{r|r–r”r)rr	rfr r•r”rrrÚtest_tick_eventsãsý
z#TestSerializations.test_tick_eventsN)r(r)r*r–ržrŸr r¡r£r¤r¥r§r©r¬r±r²r³r´rrrrrˆsrˆc@seZdZdd„Zdd„ZdS)ÚTestUtilityFunctionscCs8ddlm}|jj ¡D]\}}| | |¡|¡qdSr)rr	Ú
EventTypesÚ__dict__ÚitemsrZgetEventNameByType)rr	ÚnameÚvaluerrrÚtest_getEventNameByTypeðsz,TestUtilityFunctions.test_getEventNameByTypecCs`ddlm}| t|jdƒ¡Gdd„d|jƒ}z"| d|¡| |jj|k¡W5|j`XdS)NrrÚFOOc@seZdZdS)z4TestUtilityFunctions.test_register.<locals>.FooEventNr'rrrrÚFooEventøsr½)	rr	r`Úhasattrr¶r9r¼Úregisterr:)rr	r½rrrÚ
test_registerõsz"TestUtilityFunctions.test_registerN)r(r)r*r»rÀrrrrrµïsrµcCst tjt¡S)N)ÚunittestZ
findTestCasesÚsysÚmodulesr(rrrrÚ
test_suitesrÄÚ__main__)ZdefaultTest)rÂrÁZsupervisor.tests.baserrrrZTestCaserr/rˆrµrÄr(ÚmainrrrrÚ<module>s:>p