Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/scripts/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyc


=Nc	@sdZddlZddlmZmZddlmZddlmZddl	m
Z
ddlmZdZ
d	Zddddddddd
ZdZdefd
YZdS(s'
Tests for L{twisted.scripts.tap2rpm}.
iN(tTestCasetSkipTest(t	procutils(tFailure(tutils(ttap2rpmssc
Cs"g}|s;d}t|d}	|	jd|	jn|jdd|g|rm|jd|gn|r|jd|gn|r|jd|gn|r|jd	|gn|r|jd
|gn|r|jd|gn|r|jd|gntj|S(
sF
    Helper function to invoke tap2rpm with the given parameters.
    sdummy-tap-filetws# Dummy TAP file
s--quiets	--tapfiles--maintainers
--protocols
--descriptions--long_descriptions
--set-versions	--rpmfiles--type(topentwritetclosetextendRtrun(
ttapfilet
maintainertprotocoltdescriptiontlongDescriptiont
setVersiontrpmfilettype_targsthandle((sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyt	_makeRPMss,

csytjgD]}d|tf^q
}fd}d}tjddd|d|f}|j|||S(s
    Helper function to read the given header tags from the given RPM file.

    Returns a Deferred that fires with dictionary mapping a tag name to a list
    of the associated values in the RPM header. If a tag has only a single
    value in the header (like NAME or VERSION), it will be returned as a 1-item
    list.

    Run "rpm --querytags" to see what tags can be queried.
    s
[%%{%s}%s]csUi}xHt|jtD].\}}|jtjt}|||<qW|S(N(tziptsplittRECORD_SEPARATORtstriptUNIT_SEPARATOR(toutputtresttagtvalues(ttaglist(sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pytparseTagValuesKs
%csf|jtt|jjdr:ttdn||jj}|jfd|S(Nsgot stderr: 'error: sRrpm is missing its package database. Run 'sudo rpm -qa > /dev/null' to create one.csS(N((t_(t
newFailure(sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyt<lambda>os(	ttraptIOErrortstrtvaluet
startswithRRtprocessEndedtaddBoth(tfailuretd((R#sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pytcheckErrorResultTs
trpms-qs
--queryformats-p(RtjoinRRtgetProcessOutputtaddCallbacks(RR RtqueryFormatR!R.R-((R sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyt
_queryRPMTags8s&			tTestTap2RPMcBseZdZdZddZdZdZdZdZdZ	d	Z
d
ZdZdZ
d
ZdZdZRS(cCs
|jS(N(t_checkForRpmbuild(tself((sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pytsetUp|scCs"tjdstdndS(sS
        tap2rpm requires rpmbuild; skip tests if rpmbuild is not present.
        trpmbuilds(rpmbuild must be present to test tap2rpmN(RtwhichR(R7((sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyR6stdummycCs4|d}t|d}|jd|j|S(sK
        Make a temporary .tap file and returns the absolute path.
        s.tapRs# Dummy .tap file(RRR	(R7tbasenametpathR((sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyt_makeTapFiles



cKs,t||j}|j|j||S(sR
        Check the given file has the given tags set to the given values.
        (R4tkeystaddCallbacktassertEqual(R7RttagsR-((sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyt_verifyRPMTagsscCstj}|jg|j|dd|j|dd|j|dd|j|dd|j|d	d
|j|dd|j|d
d|j|dd|j|dt|j|dd|j|dddS(s
        Commandline options should default to sensible values.

        "sensible" here is defined as "the same values that previous versions
        defaulted to".
        Rs
twistd.tapR
RRttwistdRsA TCP server for twistdtlong_descriptions Automatically created by tap2rpmsset-versions1.0Rstwisted-twistdttypettaptquiett
twistd_optiontfilesrelease-namestwisted-twistd-1.0N(Rt	MyOptionstparseOptionsRAtFalse(R7tconfig((sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyttest_optionDefaultss

cCsKtj}|jddg|j|dd|j|dddS(sS
        The protocol name defaults to a value based on the tapfile value.
        s	--tapfilespancakes.tapRRtpancakesN(RRKRLRA(R7RN((sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyt"test_protocolCalculatedFromTapFilescCstj}|jddddg|j|dd|j|dd|j|dd|j|d	d
|j|dd|j|d
d|j|dd|j|dd|j|dt|j|dd|j|dddS(sT
        Many options default to a value calculated from the protocol name.
        s	--tapfilessausages.taps
--protocolteggsRR
RRRsA TCP server for eggsREs Automatically created by tap2rpmsset-versions1.0Rstwisted-eggsRFRGRHRIRJsrelease-namestwisted-eggs-1.0N(RRKRLRARM(R7RN((sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyt"test_optionsDefaultToProtocolValues 

cCs=tj}|jddddg|j|dddS(sU
        The release-name option is calculated from rpmfile and set-version.
        s	--rpmfiletbeanss
--set-versions1.2.3srelease-namesbeans-1.2.3N(RRKRLRA(R7RN((sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyt&test_releaseNameDefaultsToRpmfileValues

csdtdj\}j|ddfgddgddgd	d
fgddg}|jfd
|S(sW
        Calling tap2rpm should produce an RPM and SRPM with default metadata.
        tfrenchtoastRtNAMEs
twisted-%stVERSIONs1.0tRELEASEt1tSUMMARYsA TCP server for %stDESCRIPTIONs Automatically created by tap2rpmcsHjddfgddgddgddfgd	d
gS(NRWs
twisted-%sRXs1.0RYRZR[sA TCP server for %sR\s Automatically created by tap2rpm(RC(R"(R7tsrpmR<(sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyR$s
		(RR>RCR@(R7R/R-((R<R7R]sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyttest_basicOperations		csd}dtdj|d\}j|ddfgddfg}|jfd	|S(
sU
        Setting 'protocol' should change the name of the resulting package.
        tacorntbananaRRRWs
twisted-%sR[sA TCP server for %scs-jddfgddfgS(NRWs
twisted-%sR[sA TCP server for %s(RC(R"(R7RR](sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyR$s(RR>RCR@(R7R<R/R-((RR7R]sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyttest_protocolOverridescs{ddtdjd\}j|dgddfg}|jfd|S(	sT
        Setting 'rpmfile' should change the name of the resulting package.
        tcherrytdonutRRRWR[sA TCP server for %scs&jdgddfgS(NRWR[sA TCP server for %s(RC(R"(R7RR]R<(sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyR$)s	(RR>RCR@(R7R/R-((R<R7RR]sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyttest_rpmfileOverrides	cs_dtdjd\}j|dg}|jfd|S(sF
        Setting 'description' should change the SUMMARY tag.
        teggplantRRR[csjdgS(NR[(RC(R"(R7R]R(sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyR$?s(RR>RCR@(R7R/R-((RR7R]sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyttest_descriptionOverride1scs_dtdjd\}j|dg}|jfd|S(sN
        Setting 'longDescription' should change the DESCRIPTION tag.
        tfigRRR\csjdgS(NR\(RC(R"(R7R]R(sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyR$Ts(RR>RCR@(R7R/R-((R7RR]sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyttest_longDescriptionOverrideFscsed}tdjd|\}j|ddgddg}|jfd|S(sL
        Setting 'setVersion' should change the RPM's version info.
        s123.456RRRXRYRZcsjddgddgS(NRXs123.456RYRZ(RC(R"(R7R](sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyR$js	(RR>RCR@(R7tversionR/R-((R7R]sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyttest_setVersionOverride[s	cCsH|j}tj||jtjj|d}td|dS(sI
        tap2rpm handles tapfiles outside the current directory.
        tbaconRN(tmktemptostmkdirR>R=R0R(R7ttempdirR((sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyttest_tapInOtherDirectoryrs
(t__name__t
__module__R8R6R>RCRORQRSRUR^RaRdRfRhRjRp(((sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyR5ys			
				
						(t__doc__Rmttwisted.trial.unittestRRttwisted.pythonRttwisted.python.failureRttwisted.internetRttwisted.scriptsRRRtNoneRR4R5(((sE/usr/lib/python2.7/dist-packages/twisted/scripts/test/test_tap2rpm.pyt<module>s!	A