ϪfZdZddlZddlmZddlmZdZdZGddZGd d ejZ Gd d ejZ Gd dejZ GddZGddeeZy)z" Tests for positioning sentences. N) _sentence)TestCasesomeStringValuesomeOtherStringValuec eZdZdZedZy) DummyProtocolz" A simple, fake protocol. cdttgS)Ntype)sentinelValueOnesentinelValueTwoH/usr/lib/python3/dist-packages/twisted/positioning/test/test_sentence.pygetSentenceAttributesz#DummyProtocol.getSentenceAttributess(*:;;rN)__name__ __module__ __qualname____doc__ staticmethodrr rrrrs<rrceZdZdZdeedgiZy) MixinProtocolz A simple, fake protocol that declaratively tells you the sentences it produces using L{base.PositioningSentenceProducerMixin}. N)rrrrr r _SENTENCE_CONTENTSr rrrr#s"    rrc0eZdZdZej Zy) MixinSentencez* A sentence for L{MixinProtocol}. N)rrrrrrrr rrrr2rrrc>eZdZdZdZdZdZdZdZd dZ dZ d Z y ) SentenceTestsMixinzI Tests for positioning protocols and their respective sentences. ct}|jt|i}|jt |t||j t |t y)z A sentence attribute gets the correct value, and accessing an unset attribute (which is specified as being a valid sentence attribute) gets L{None}. N)object sentenceClassr assertEqualgetattr assertIsNoner )self thisSentinelsentences rtest_attributeAccessz'SentenceTestsMixin.test_attributeAccess?sO x %%'7&FG +;rc^|ji}|jtt|dy)zM Accessing a nonexistent attribute raises C{AttributeError}. BOGUSNr# assertRaisesAttributeErrorr%r'r)s r"test_raiseOnMissingAttributeAccessz5SentenceTestsMixin.test_raiseOnMissingAttributeAccessJs(%%b) .'8WErcb|jddi}|jtt|dy)z Accessing bogus attributes raises C{AttributeError}, *even* when that attribute actually is in the sentence data. r,Nr-r0s rtest_raiseOnBadAttributeAccessz1SentenceTestsMixin.test_raiseOnBadAttributeAccessQs, %%wo6 .'8WErtummiesz<%s (%s) {%s}>cR|jj}|j|||fzS)aQ Builds the expected repr for a sentence. @param sentenceType: The name of the sentence type (e.g "GPGGA"). @type sentenceType: C{str} @param dataRepr: The repr of the data in the sentence. @type dataRepr: C{str} @return: The expected repr of the sentence. @rtype: C{str} )r#r reprTemplate)r' sentenceTypedataReprclsNames r _expectedReprz SentenceTestsMixin._expectedRepr\s-$$--  G\8#DDDrc||ji}|j}|jt||y)zE Test the repr of an empty sentence of unknown type. N)r#r:r$reprr'r) expectedReprs rtest_unknownTypeReprz'SentenceTestsMixin.test_unknownTypeReprjs6%%b)))+  h6rc|jd|ji}|j|j}|jt ||y)zC Test the repr of an empty sentence of known type. r N)r#r7r:r$r<r=s rtest_knownTypeReprz%SentenceTestsMixin.test_knownTypeReprrsI%%vt/@/@&AB))$*;*;<  h6rN)z unknown type) rrrrr*r1r3r7r6r:r?rAr rrr r :s4 ?FFL#L E77rr ceZdZdZdZdZy) MixinTestszm Tests for protocols deriving from L{base.PositioningSentenceProducerMixin} and their sentences. c8t|_t|_y)N)rprotocolrr#)r's rsetUpzMixinTests.setUps% *rc|jj}|jd||jj}t j |j }|jd|y)a L{None} does not appear in the sentence attributes of the protocol, even though it's in the specification. This is because L{None} is a placeholder for parts of the sentence you don't really need or want, but there are some bits later on in the sentence that you do want. The alternative would be to have to specify things like "_UNUSED0", "_UNUSED1"... which would end up cluttering the sentence data and eventually adapter state. N)rFr assertNotInr itertoolschainvaluesassertIn)r'sentenceAttributessentenceContentssentenceSpecAttributess rtest_noNoneInSentenceAttributesz*MixinTests.test_noNoneInSentenceAttributess`"]]@@B 12==;;!*2B2I2I2K!L d23rN)rrrrrGrQr rrrDrD{s +4rrD)rrJtwisted.positioningrtwisted.trial.unittestrr r r _BaseSentencer!_PositioningSentenceProducerMixinrrr rDr rrrVs{ )+$)<<?I++? I?? ?I++?>7>7B4-4r