
    Vh\t                    @   d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZ  G d d	e      Z G d
 de      Z G d de      ZddZddZ G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Zy) z(
Test cases for positioning primitives.
    )annotations)verify)base)Angles
Directions)IPositioningBeacon)TestCasec                  0    e Zd ZdZddZddZddZddZy)
AngleTestsz@
    Tests for the L{twisted.positioning.base.Angle} class.
    c                b    t        j                         }| j                  dt        |             y)zd
        The repr of an empty angle says that is of unknown type and unknown
        value.
        z'<Angle of unknown type (unknown value)>Nr   AngleassertEqualreprselfas     R/home/dcms/DCMS/lib/python3.12/site-packages/twisted/positioning/test/test_base.py
test_emptyzAngleTests.test_empty   s$    
 JJLBDGL    c                    t        j                  t        j                        }| j	                  dt        |             y)zf
        The repr of an empty variation says that it is a variation of unknown
        value.
        	angleTypez<Variation (unknown value)>N)r   r   r   	VARIATIONr   r   r   s     r   test_variationzAngleTests.test_variation   s-    
 JJ!1!126Q@r   c                d    t        j                  d      }| j                  dt        |             y)zz
        The repr of an angle of unknown type but a given value displays that
        type and value in its repr.
              ?z%<Angle of unknown type (1.0 degrees)>Nr   r   s     r   test_unknownTypezAngleTests.test_unknownType%   s&    
 JJsO@$q'Jr   c                P    | j                  t        t        j                  d       y)zS
        Trying to create an angle with a bogus type raises C{ValueError}.
        BOGUSr   N)assertRaises
ValueErrorr   r   r   s    r   test_bogusTypezAngleTests.test_bogusType-   s     	*djjGDr   NreturnNone)__name__
__module____qualname____doc__r   r   r   r$    r   r   r   r      s    MAKEr   r   c                      e Zd ZdZddZddZddZddZddZddZ	ddZ
dd	Zdd
ZddZddZddZddZddZddZddZddZddZddZddZddZddZy)HeadingTestszB
    Tests for the L{twisted.positioning.base.Heading} class.
    c                   t        j                  d      }| j                  |j                  d       | j                  t	        |      d       | j                  |j                         | j                  |j                         y)z
        Tests that a simple heading has a value in decimal degrees, which is
        also its value when converted to a float. Its variation, and by
        consequence its corrected heading, is L{None}.
        r   N)r   Headingr   inDecimalDegreesfloatassertIsNone	variationcorrectedHeadingr   hs     r   test_simplezHeadingTests.test_simple9   sb     LL++S1q3'!++&!,,-r   c                h    t        j                  d      }d}| j                  t        |      |       y)zt
        A repr of a heading with no variation reports its value and that the
        variation is unknown.
        r   z*<Heading (1.0 degrees, unknown variation)>N)r   r0   r   r   )r   headingexpectedReprs      r    test_headingWithoutVariationReprz-HeadingTests.test_headingWithoutVariationReprE   s+    
 ,,s#Cg5r   c                    d\  }}t         j                  j                  ||      }d}| j                  t	        |      |j                  ||             y)zu
        A repr of a heading with known variation reports its value and the
        value of that variation.
        )r         $variationValuez2<Heading ({0} degrees, <Variation ({1} degrees)>)>N)r   r0   
fromFloatsr   r   format)r   angler4   r:   reprTemplates        r   test_headingWithVariationReprz*HeadingTests.test_headingWithVariationReprN   sM    
 &y,,))%	)JKg(;(;E9(MNr   c                t    | j                  t        j                  d      t        j                  d             y)z>
        Headings with the same values compare equal.
        r   N)r   r   r0   r#   s    r   test_valueEqualityzHeadingTests.test_valueEqualityX   s&     	c*DLL,=>r   c                t    | j                  t        j                  d      t        j                  d             y)zA
        Headings with different values compare unequal.
        r          @N)assertNotEqualr   r0   r#   s    r   test_valueInequalityz!HeadingTests.test_valueInequality^   s&     	DLL-t||C/@Ar   c                .    t        j                  d       y)zR
        Headings can be instantiated with a value of 0 and no variation.
        r   Nr   r0   r#   s    r   test_zeroHeadingEdgeCasez%HeadingTests.test_zeroHeadingEdgeCased   s     	Qr   c                0    t        j                  dd       y)zh
        Headings can be instantiated with a value of 0 and a variation of 180
        degrees.
        r      NrM   r#   s    r   *test_zeroHeading180DegreeVariationEdgeCasez7HeadingTests.test_zeroHeading180DegreeVariationEdgeCasej   s    
 	Qr   c                d     | j                   t        t        j                  j                  fi | y)z
        Helper function for verifying that bad values raise C{ValueError}.

        @param kw: The keyword arguments passed to L{base.Heading.fromFloats}.
        N)r!   r"   r   r0   rA   )r   kws     r   _badValueTestzHeadingTests._badValueTestq   s%     	*dll&=&=DDr   c                (    | j                  d       y)zO
        Headings can not be instantiated with a value of 360 degrees.
        g     v@
angleValueNrT   r#   s    r   test_badAngleValueEdgeCasez'HeadingTests.test_badAngleValueEdgeCasey        	e,r   c                (    | j                  d       y)zT
        Headings can not be instantiated with a variation of -180 degrees.
             fr?   NrX   r#   s    r   test_badVariationEdgeCasez&HeadingTests.test_badVariationEdgeCase        	&1r   c                (    | j                  d       y)z>
        Negative heading values raise C{ValueError}.
        r>   rV   NrX   r#   s    r   test_negativeHeadingz!HeadingTests.test_negativeHeading   rZ   r   c                (    | j                  d       y)zK
        Heading values greater than C{360.0} raise C{ValueError}.
        g      w@rV   NrX   r#   s    r   test_headingTooLargez!HeadingTests.test_headingTooLarge   rZ   r   c                (    | j                  d       y)zK
        Variation values less than C{-180.0} raise C{ValueError}.
        g     gr?   NrX   r#   s    r   test_variationTooNegativez&HeadingTests.test_variationTooNegative   r^   r   c                (    | j                  d       y)zM
        Variation values greater than C{180.0} raise C{ValueError}.
        g     g@r?   NrX   r#   s    r   test_variationTooPositivez&HeadingTests.test_variationTooPositive   s     	%0r   c                    t         j                  j                  dd      }| j                  |j                  t        j
                  dt        j                               y)zQ
        A heading with a value and a variation has a corrected heading.
        r   r>   r?   g      &@Nr   r0   rA   r   r5   r   r   HEADINGr6   s     r   test_correctedHeadingz"HeadingTests.test_correctedHeading   sB     LL##C#>++TZZfnn-MNr   c                    t         j                  j                  dd      }| j                  |j                  t        j
                  dt        j                               y)z
        A heading with a value and a variation has the appropriate corrected
        heading value, even when the variation puts it across the 360 degree
        boundary.
             pv@g       r?   r   Nrh   r6   s     r   test_correctedHeadingOverflowz*HeadingTests.test_correctedHeadingOverflow   B     LL##E$#?++TZZV^^-LMr   c                    t         j                  j                  dd      }| j                  |j                  t        j
                  dt        j                               y)z
        A heading with a value and a variation has the appropriate corrected
        heading value, even when the variation puts it exactly at the 360
        degree boundary.
        rl         r?           Nrh   r6   s     r   %test_correctedHeadingOverflowEdgeCasez2HeadingTests.test_correctedHeadingOverflowEdgeCase   rn   r   c                    t         j                  j                  dd      }| j                  |j                  t        j
                  dt        j                               y)z
        A heading with a value and a variation has the appropriate corrected
        heading value, even when the variation puts it under the 0 degree
        boundary.
        r   rI   r?   rl   Nrh   r6   s     r   test_correctedHeadingUnderflowz+HeadingTests.test_correctedHeadingUnderflow   sB     LL##C#<++TZZv~~-NOr   c                    t         j                  j                  dd      }| j                  |j                  t        j
                  dt        j                               y)z
        A heading with a value and a variation has the appropriate corrected
        heading value, even when the variation puts it exactly at the 0
        degree boundary.
        r   r?   rq   Nrh   r6   s     r   &test_correctedHeadingUnderflowEdgeCasez3HeadingTests.test_correctedHeadingUnderflowEdgeCase   sB     LL##C#<++TZZV^^-LMr   c                "   t         j                  j                  dd      }|j                  d       | j	                  |j
                  j                  d       |j                  d       | j	                  |j
                  j                  d       y)zK
        Setting the sign of a heading changes the variation sign.
        r   r?      rp   N)r   r0   rA   setSignr   r4   r1   r6   s     r   test_setVariationSignz"HeadingTests.test_setVariationSign   sg     LL##C#<			!55s;			"55t<r   c                   t         j                  j                  dd      }| j                  t        |j
                  d       | j                  |j                  j                  d       | j                  t        |j
                  d       | j                  |j                  j                  d       | j                  t        |j
                  d       | j                  |j                  j                  d       y)z
        Setting the sign of a heading to values that aren't C{-1} or C{1}
        raises C{ValueError} and does not affect the heading.
        r   r?   r   2   N)	r   r0   rA   r!   r"   rz   r   r4   r1   r6   s     r   test_setBadVariationSignz%HeadingTests.test_setBadVariationSign   s    
 LL##C#<*aii555s;*aii355s;*aii455s;r   c                    t         j                  j                  d      }| j                  |j                  j
                         | j                  t        |j                  d       y)zd
        Setting the sign on a heading with unknown variation raises
        C{ValueError}.
        r   rx   N)	r   r0   rA   r3   r4   r1   r!   r"   rz   r6   s     r   test_setUnknownVariationSignz)HeadingTests.test_setUnknownVariationSign   sF    
 LL##C(!++667*aii3r   Nr%   )rS   r2   r&   r'   )r(   r)   r*   r+   r8   r<   rE   rG   rK   rN   rQ   rT   rY   r]   r`   rb   rd   rf   rj   rm   rr   rt   rv   r{   r   r   r,   r   r   r.   r.   4   s}    
.6O?BE-2--21ONNPN=<4r   r.   c                      e Zd ZddZddZddZddZddZddZddZ	ddZ
dd	Zdd
ZddZddZddZddZddZddZddZddZddZddZddZddZddZddZy)CoordinateTestsc                d    t        j                  d      }| j                  t        |      d       y)z9
        Coordinates can be converted to floats.
              $@N)r   
Coordinater   r2   r   
coordinates     r   
test_floatzCoordinateTests.test_float   s'     __T*
z*D1r   c                p    t        j                  d      }dd d}| j                  t        |      |       y)zn
        Coordinates that aren't explicitly latitudes or longitudes have an
        appropriate repr.
        r   z<Angle of unknown type (
 degrees)>N)r   r   r   r   r   r   r;   s      r   	test_reprzCoordinateTests.test_repr   s5    
 __T*
1$zBj)<8r   c                    t        j                  dt        j                        }dd d}| j	                  t        |      |       y)zU
        Positive latitudes have a repr that specifies their type and value.
        r   <Latitude (r   Nr   r   r   LATITUDEr   r   r   s      r   test_positiveLatitudez%CoordinateTests.test_positiveLatitude   s;     __T6??;
$TF*5j)<8r   c                    t        j                  dt        j                        }dd d}| j	                  t        |      |       y)zU
        Negative latitudes have a repr that specifies their type and value.
              Ir   r   Nr   r   s      r   test_negativeLatitudez%CoordinateTests.test_negativeLatitude  s;     __UFOO<
$UG:6j)<8r   c                    t        j                  dt        j                        }dd d}| j	                  t        |      |       y)zV
        Positive longitudes have a repr that specifies their type and value.
              I@<Longitude (r   Nr   r   r   	LONGITUDEr   r   r   	longituder;   s      r   test_positiveLongitudez&CoordinateTests.test_positiveLongitude  s<     OOD&*:*:;	%dV:6i,7r   c                    t        j                  dt        j                        }dd d}| j	                  t        |      |       y)zV
        Negative longitudes have a repr that specifies their type and value.
        r   r   r   Nr   r   s      r   test_negativeLongitudez&CoordinateTests.test_negativeLongitude  s<     OOE6+;+;<	%eWJ7i,7r   c                P    | j                  t        t        j                  dd       y)zM
        Creating coordinates with bogus types rasies C{ValueError}.
             b@r    N)r!   r"   r   r   r#   s    r   test_bogusCoordinateTypez(CoordinateTests.test_bogusCoordinateType  s     	*doougFr   c                l    | j                  t        t        j                  dt        j
                         y)zm
        Creating coordinates with angle types that aren't coordinates raises
        C{ValueError}.
        r   N)r!   r"   r   r   r   ri   r#   s    r   test_angleTypeNotCoordinatez+CoordinateTests.test_angleTypeNotCoordinate"  s     
 	*dooufnnMr   c                D    dd}| j                   |        |              y)zE
        Coordinates with the same value and type are equal.
        c                 J    t        j                  dt        j                        S )Nr   r   r   r   r   r,   r   r   makeCoordinatez5CoordinateTests.test_equality.<locals>.makeCoordinate.  s    ??3(8(899r   N)r&   base.Coordinate)r   )r   r   s     r   test_equalityzCoordinateTests.test_equality)  s    
	: 	)>+;<r   c                |    t        j                  d      }t        j                  d      }| j                  ||       y)zA
        Coordinates with different values aren't equal.
        r   rp   N)r   r   rJ   r   c1c2s      r   test_differentAnglesInequalityz.CoordinateTests.test_differentAnglesInequality3  s0     __S!__T"B#r   c                    t        j                  dt        j                        }t        j                  dt        j                        }| j                  ||       y)zT
        Coordinates with the same values but different types aren't equal.
        r   N)r   r   r   r   r   rJ   r   s      r   test_differentTypesInequalityz-CoordinateTests.test_differentTypesInequality;  s>     __S&//2__S&"2"23B#r   c                    t        j                  dt        j                        }|j	                  d       | j                  |j                  d       |j	                  d       | j                  |j                  d       y)zh
        Setting the sign on a coordinate sets the sign of the value of the
        coordinate.
        r   rx   ry   r   N)r   r   r   r   rz   r   r1   r   cs     r   	test_signzCoordinateTests.test_signC  sZ    
 OOD&//2			!++T2			"++U3r   c                   d}t        j                  |t        j                        }| j	                  t
        |j                  d       | j                  |j                  d       | j	                  t
        |j                  d       | j                  |j                  d       | j	                  t
        |j                  d       | j                  |j                  d       y)z
        Setting a bogus sign value (not -1 or 1) on a coordinate raises
        C{ValueError} and doesn't affect the coordinate.
        r   r}   r   r~   N)	r   r   r   r   r!   r"   rz   r   r1   )r   valuer   s      r   test_badVariationSignz%CoordinateTests.test_badVariationSignN  s    
 OOE6??3*aii5++T2*aii3++T2*aii4++T2r   c                    t        j                  dt        j                        }| j	                  |j
                  t        j                         y)zD
        Positive latitudes are in the northern hemisphere.
        r   N)r   r   r   r   r   
hemispherer   NORTHr   s     r   test_northernHemispherez'CoordinateTests.test_northernHemisphere_  s4     __S&//:
..
0@0@Ar   c                    t        j                  dt        j                        }| j	                  |j
                  t        j                         y)zD
        Positive longitudes are in the eastern hemisphere.
        r   N)r   r   r   r   r   r   r   EASTr   s     r   test_easternHemispherez&CoordinateTests.test_easternHemispheref  s4     __S&*:*:;
..
@r   c                    t        j                  dt        j                        }| j	                  |j
                  t        j                         y)zD
        Negative latitudes are in the southern hemisphere.
        rp   N)r   r   r   r   r   r   r   SOUTHr   s     r   test_southernHemispherez'CoordinateTests.test_southernHemispherem  s4     __T6??;
..
0@0@Ar   c                    t        j                  dt        j                        }| j	                  |j
                  t        j                         y)zD
        Negative longitudes are in the western hemisphere.
        rp   N)r   r   r   r   r   r   r   WESTr   s     r   test_westernHemispherez&CoordinateTests.test_westernHemispheret  s4     __T6+;+;<
..
@r   c                d    t        j                  dd      | j                  t        fd       y)zo
        Accessing the hemisphere for a coordinate that can't compute it
        raises C{ValueError}.
        r   Nc                      j                   S )N)r   )r   s   r   <lambda>z4CoordinateTests.test_badHemisphere.<locals>.<lambda>  s    j.C.C r   )r   r   r!   r"   r   s    @r   test_badHemispherez"CoordinateTests.test_badHemisphere{  s&    
 __S$/
*&CDr   c                p    | j                  t        t        d       | j                  t        t        d       y)zt
        Creating a latitude with a value greater than or equal to 90 degrees
        raises C{ValueError}.
        r   g     V@Nr!   r"   _makeLatituder#   s    r   test_latitudeTooLargez%CoordinateTests.test_latitudeTooLarge  s(    
 	*mU;*mT:r   c                p    | j                  t        t        d       | j                  t        t        d       y)zr
        Creating a latitude with a value less than or equal to -90 degrees
        raises C{ValueError}.
        g     bg     VNr   r#   s    r   test_latitudeTooSmallz%CoordinateTests.test_latitudeTooSmall  s(    
 	*mV<*mU;r   c                p    | j                  t        t        d       | j                  t        t        d       y)zv
        Creating a longitude with a value greater than or equal to 180 degrees
        raises C{ValueError}.
        g     @o@g     f@Nr!   r"   _makeLongituder#   s    r   test_longitudeTooLargez&CoordinateTests.test_longitudeTooLarge  s(    
 	*ne<*ne<r   c                p    | j                  t        t        d       | j                  t        t        d       y)zt
        Creating a longitude with a value less than or equal to -180 degrees
        raises C{ValueError}.
        g     @or\   Nr   r#   s    r   test_longitudeTooSmallz&CoordinateTests.test_longitudeTooSmall  s(    
 	*nf=*nf=r   c                   t        j                  dt        j                        }| j	                  |j
                  d       t        j                  dt        j                        }| j	                  |j
                  d       y)zQ
        Coordinate values can be accessed in degrees, minutes, seconds.
        g     @I@)r~      r   g%CI@)r~      .   N)r   r   r   r   r   inDegreesMinutesSecondsr   s     r   test_inDegreesMinutesSecondsz,CoordinateTests.test_inDegreesMinutesSeconds  sX     OOD&//222K@OOFFOO422LAr   c                f    t        j                  dd      }| j                  |j                         y)zz
        If the vaue of a coordinate is L{None}, its values in degrees,
        minutes, seconds is also L{None}.
        N)r   r   r3   r   r   s     r   (test_unknownAngleInDegreesMinutesSecondsz8CoordinateTests.test_unknownAngleInDegreesMinutesSeconds  s(    
 OOD$'!334r   Nr%   )r(   r)   r*   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r,   r   r   r   r      s    299988GN=$$	43"BABAE;<=>B5r   r   c                J    t        j                  | t        j                        S )z7
    Builds and returns a latitude of given value.
    )r   r   r   r   r   s    r   r   r     s     ??5&//22r   c                J    t        j                  | t        j                        S )z8
    Builds and returns a longitude of given value.
    r   r   s    r   r   r     s     ??5&"2"233r   c                  0    e Zd ZdZddZddZddZddZy)AltitudeTestszC
    Tests for the L{twisted.positioning.base.Altitude} class.
    c                    t        j                  d      }| j                  t        |      d       | j                  |j                  d       | j                  |j
                  dt         j                  z         y)z
        Altitudes can be instantiated and reports the correct value in
        meters and feet, as well as when converted to float.
        r   N)r   Altituder   r2   inMetersinFeetMETERS_PER_FOOTr   altitudes     r   
test_valuezAltitudeTests.test_value  s[    
 ==%x#.**C0#0D0D*DEr   c                d    t        j                  d      }| j                  t        |      d       y)zF
        Altitudes report their type and value in their repr.
        r   z<Altitude (1.0 m)>N)r   r   r   r   r   s     r   r   zAltitudeTests.test_repr  s'     ==%h)=>r   c                |    t        j                  d      }t        j                  d      }| j                  ||       y)z<
        Altitudes with equal values compare equal.
        r   N)r   r   r   r   firstAltitudesecondAltitudes      r   r   zAltitudeTests.test_equality  s0     c*s+7r   c                |    t        j                  d      }t        j                  d      }| j                  ||       y)zF
        Altitudes with different values don't compare equal.
        r   rp   N)r   r   rJ   r   s      r   test_inequalityzAltitudeTests.test_inequality  s0     c*t,M>:r   Nr%   )r(   r)   r*   r+   r   r   r   r   r,   r   r   r   r     s    F?8;r   r   c                  8    e Zd ZdZddZddZddZddZddZy)	
SpeedTestsz@
    Tests for the L{twisted.positioning.base.Speed} class.
    c                    t        j                  d      }| j                  |j                  d       | j                  t	        |      d       y)
        Speeds can be instantiated, and report their value in meters
        per second, and can be converted to floats.
        r   N)r   Speedr   inMetersPerSecondr2   r   speeds     r   r   zSpeedTests.test_value  <    
 

4 00$7ut,r   c                d    t        j                  d      }| j                  t        |      d       y)zC
        Speeds report their type and value in their repr.
        r   z<Speed (50.0 m/s)>N)r   r   r   r   r   s     r   r   zSpeedTests.test_repr  '     

4 e&:;r   c                N    | j                  t        t        j                  d       y)zA
        Creating a negative speed raises C{ValueError}.
        rp   N)r!   r"   r   r   r#   s    r   test_negativeSpeedszSpeedTests.test_negativeSpeeds   s     	*djj$7r   c                    t        j                  d      }| j                  dt         j                  z  |j                         y)zC
        A speed can be converted into its value in knots.
        r   rx   N)r   r   r   MPS_PER_KNOTinKnotsr   s     r   test_inKnotszSpeedTests.test_inKnots  0     

3T...>r   c                `    | j                  dt        t        j                  d                   y)z;
        A speed can be converted into a C{float}.
        r   N)r   r2   r   r   r#   s    r   test_asFloatzSpeedTests.test_asFloat  !     	eDJJsO45r   Nr%   )	r(   r)   r*   r+   r   r   r   r  r  r,   r   r   r   r     s     -<8?6r   r   c                  8    e Zd ZdZddZddZddZddZddZy)	
ClimbTestsz6
    Tests for L{twisted.positioning.base.Climb}.
    c                    t        j                  d      }| j                  |j                  d       | j                  t	        |      d       y)r         E@Nr   Climbr   r   r2   r   climbs     r   r8   zClimbTests.test_simple  r   r   c                d    t        j                  d      }| j                  t        |      d       y)zC
        Climbs report their type and value in their repr.
        r
  z<Climb (42.0 m/s)>N)r   r  r   r   r  s     r   r   zClimbTests.test_repr"  r   r   c                    t        j                  d      }| j                  |j                  d       | j                  t	        |      d       y)z
        Climbs can have negative values, and still report that value
        in meters per second and when converted to floats.
        g      ENr  r  s     r   test_negativeClimbszClimbTests.test_negativeClimbs)  s<    
 

5!00%8uu-r   c                    t        j                  d      }| j                  dt         j                  z  |j                         y)zC
        A climb can be converted into its value in knots.
        r   rx   N)r   r  r   r   r  r  s     r   test_speedInKnotszClimbTests.test_speedInKnots2  r  r   c                `    | j                  dt        t        j                  d                   y)z;
        A climb can be converted into a C{float}.
        r   N)r   r2   r   r  r#   s    r   r  zClimbTests.test_asFloat9  r  r   Nr%   )	r(   r)   r*   r+   r8   r   r  r  r  r,   r   r   r  r    s     -<.?6r   r  c                      e Zd ZdZddZddZddZddZddZddZ	ddZ
dd	Zd
Z	 	 	 	 	 	 	 	 	 	 ddZddZddZddZy)PositionErrorTestsz>
    Tests for L{twisted.positioning.base.PositionError}.
    c                    t        j                         }| j                  |j                         | j                  |j                         | j                  |j
                         y)z~
        In an empty L{base.PositionError} with no invariant testing, all
        dilutions of positions are L{None}.
        Nr   PositionErrorr3   pdophdopvdopr   positionErrors     r   test_allUnsetz PositionErrorTests.test_allUnsetE  sN    
 **,-,,--,,--,,-r   c                    t        j                  d      }| j                  |j                         | j                  |j                         | j                  |j
                         y)z{
        In an empty L{base.PositionError} with invariant testing, all
        dilutions of positions are L{None}.
        T)testInvariantNr  r  s     r   test_allUnsetWithInvariantz-PositionErrorTests.test_allUnsetWithInvariantO  sP    
 **>-,,--,,--,,-r   c                h    t        j                  d      }| j                  |j                  d       y)zN
        L{base.PositionError}s can be instantiated with just a HDOP.
        r   )r  Nr   r  r   r  r  s     r   test_withoutInvariantz(PositionErrorTests.test_withoutInvariantY  s*     **4++S1r   c                j    t        j                  dd      }| j                  |j                  d       y)zv
        Creating a simple L{base.PositionError} with just a HDOP while
        checking the invariant works.
        r   T)r  r!  Nr$  r  s     r   test_withInvariantz%PositionErrorTests.test_withInvariant`  s,    
 **4H++S1r   c                    t        j                  ddd      }| j                  |j                  d       | j                  |j                  d       | j                  |j
                  d       y)z
        Creating a L{base.PositionError} with values set to an impossible
        combination works if the invariant is not checked.
        r   )r  r  r  N)r   r  r   r  r  r  )r   errors     r   test_invalidWithoutInvariantz/PositionErrorTests.test_invalidWithoutInvarianth  sT    
 ""#C@S)S)S)r   c                V    | j                  t        t        j                  dddd       y)z
        Creating a L{base.PositionError} with values set to an impossible
        combination raises C{ValueError} if the invariant is being tested.
        r   T)r  r  r  r!  N)r!   r"   r   r  r#   s    r   test_invalidWithInvariantz,PositionErrorTests.test_invalidWithInvariantr  s/    
 	 	 	
r   c                x    t        j                  dd      }d|_        | j                  |j                  d       y)z}
        You can set the PDOP value to value inconsisted with HDOP and VDOP
        when not checking the invariant.
        r   r  r        Y@N)r   r  r  r   )r   pes     r   test_setDOPWithoutInvariantz.PositionErrorTests.test_setDOPWithoutInvariant  s1    
 Ss3%(r   c                    t        j                  ddd      }|j                  }dd}| j                  t        ||       | j                  |j                  |       y)z
        Attempting to set the PDOP value to value inconsisted with HDOP and
        VDOP when checking the invariant raises C{ValueError}.
        r   T)r  r  r!  c                    d| _         y )Nr/  )r  )r0  s    r   setPDOPz<PositionErrorTests.test_setDOPWithInvariant.<locals>.setPDOP  s	    BGr   N)r0  base.PositionErrorr&   r'   )r   r  r  r!   r"   r   )r   r0  r  r4  s       r   test_setDOPWithInvariantz+PositionErrorTests.test_setDOPWithInvariant  sN    
 Ss$Gww	 	*gr2$'r   z.<PositionError (pdop: %s, hdop: %s, vdop: %s)>c                   | j                  |j                  |       | j                  |j                  |       | j                  |j                  |       | j                  t	        |      | j
                  |||fz         y)a  
        Tests the DOP values in a position error, and the repr of that
        position error.

        @param pe: The position error under test.
        @type pe: C{PositionError}
        @param pdop: The expected position dilution of precision.
        @type pdop: C{float} or L{None}
        @param hdop: The expected horizontal dilution of precision.
        @type hdop: C{float} or L{None}
        @param vdop: The expected vertical dilution of precision.
        @type vdop: C{float} or L{None}
        N)r   r  r  r  r   REPR_TEMPLATE)r   r0  r  r  r  s        r   _testDOPzPositionErrorTests._testDOP  sf    ( 	$'$'$'b4#5#5tT8J#JKr   c                    d\  }}|dz  |dz  z
  dz  }t        j                  ||      }| j                  ||||       y)zF
        The VDOP is correctly determined from PDOP and HDOP.
        rI   r            ?)r  r  Nr   r  r9  )r   r  r  r  r0  s        r   test_positionAndHorizontalSetz0PositionErrorTests.test_positionAndHorizontalSet  H     
da$'!c)T5b$d+r   c                    d\  }}|dz  |dz  z
  dz  }t        j                  ||      }| j                  ||||       y)zF
        The HDOP is correctly determined from PDOP and VDOP.
        r;  r<  r=  )r  r  Nr>  )r   r  r  r  r0  s        r   test_positionAndVerticalSetz.PositionErrorTests.test_positionAndVerticalSet  r@  r   c                    d\  }}|dz  |dz  z   dz  }t        j                  ||      }| j                  ||||       y)zF
        The PDOP is correctly determined from HDOP and VDOP.
        )r   r   r<  r=  r.  Nr>  )r   r  r  r  r0  s        r   test_horizontalAndVerticalSetz0PositionErrorTests.test_horizontalAndVerticalSet  r@  r   Nr%   )
r0  r5  r  float | Noner  rE  r  rE  r&   r'   )r(   r)   r*   r+   r  r"  r%  r'  r*  r,  r1  r6  r8  r9  r?  rB  rD  r,   r   r   r  r  @  s    ..22*
)( EMLL L 	L
 L 
L2,,,r   r  c                  4    e Zd ZdZd	dZddddZd	dZd	dZy)
BeaconInformationTestszB
    Tests for L{twisted.positioning.base.BeaconInformation}.
    c                    t        j                         }| j                  t        |j                        d       d}| j                  t        |      |       y)z
        For an empty beacon information object, the number of used
        beacons is zero, the number of seen beacons is zero, and the
        repr of the object reflects that.
        r   z><BeaconInformation (used beacons (0): [], unused beacons: [])>N)r   BeaconInformationr   lenusedBeaconsr   )r   bir;   s      r   test_minimalz#BeaconInformationTests.test_minimal  sI     ##%R^^,a0R 	 	b<0r   rx   r   )azimuth	elevationsignalToNoiseRatioc                l    d	 fd}t               }t        dd      D ]  }|j                   ||              t        j                  |      } j                  t        |j                        d        j                  t        |j                        d        j                  t        |      d       y)
zw
        Tests a beacon information with a bunch of satellites, none of
        which used in computing a fix.
        c                 z    t        j                        }|j                  |        t        j                  di |S )Nr,   )dictsatelliteKwargsupdater   	Satellite)rS   kwargsr   s     r   _buildSatellitez;BeaconInformationTests.test_simple.<locals>._buildSatellite  s1    $../FMM">>+F++r   rx   
   )
identifier	   r   a  <BeaconInformation (used beacons (0): [], unused beacons: [<Satellite (1), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (2), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (3), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (4), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (5), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (6), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (7), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (8), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (9), azimuth: 1, elevation: 1, snr: 1.0>])>N)rS   r2   r&   zbase.Satellite)
setrangeaddr   rI  r   rJ  seenBeaconsrK  r   )r   rX  beaconsprnrL  s   `    r   r8   z"BeaconInformationTests.test_simple  s    	,
 %B< 	9CKK378	9 ##G,R^^,a0R^^,a0H	
r   c                   t        j                         }t        dd      D ]_  }t        j                  d	d|i| j                  }|j
                  j                  |       |dz  sE|j                  j                  |       a | j                  t        |j
                        d       | j                  t        |j                        d       | j                  t        |      d       y)
zv
        Tests a beacon information with a bunch of satellites, some of
        them used in computing a fix.
        rx   rY  rZ  r<  r[     a  <BeaconInformation (used beacons (5): [<Satellite (1), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (3), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (5), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (7), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (9), azimuth: 1, elevation: 1, snr: 1.0>], unused beacons: [<Satellite (2), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (4), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (6), azimuth: 1, elevation: 1, snr: 1.0>, <Satellite (8), azimuth: 1, elevation: 1, snr: 1.0>])>Nr,   )r   rI  r]  rV  rT  r_  r^  rK  r   rJ  r   )r   rL  ra  	satellites       r   test_someSatellitesUsedz.BeaconInformationTests.test_someSatellitesUsed  s    
 ##%B< 	.CN#N9M9MNINNy)Qw""9-		. 	R^^,a0R^^,a0H
E	
r   Nr%   )r(   r)   r*   r+   rM  rT  r8   re  r,   r   r   rG  rG    s%    1 #$!3OO!
F
r   rG  c                       e Zd ZdZddZddZy)PositioningBeaconTestsz.
    Tests for L{base.PositioningBeacon}.
    c                    t        j                  t        j                        }| j	                  |       t        j                  t         t        j                  d             y)zX
        Tests that L{base.PositioningBeacon} implements L{IPositioningBeacon}.
        rx   N)r   implementedByr   PositioningBeacon
assertTruer   verifyObject)r   
implementss     r   test_interfacez%PositioningBeaconTests.test_interface*  sB     (55d6L6LM

#.0F0Fq0IJr   c                `    | j                  t        t        j                  d            d       y)z9
        Tests the repr of a positioning beacon.
        Az<Beacon (A)>N)r   r   r   rj  r#   s    r   r   z PositioningBeaconTests.test_repr2  s$     	d44S9:NKr   Nr%   )r(   r)   r*   r+   rn  r   r,   r   r   rg  rg  %  s    KLr   rg  c                       e Zd ZdZddZddZy)SatelliteTestsz:
    Tests for L{twisted.positioning.base.Satellite}.
    c                >   t        j                  d      }| j                  |j                  d       | j	                  |j
                         | j	                  |j                         | j	                  |j                         | j                  t        |      d       y)z
        Tests a minimal satellite that only has a known PRN.

        Tests that the azimuth, elevation and signal to noise ratios
        are L{None} and verifies the repr.
        rx   z:<Satellite (1), azimuth: None, elevation: None, snr: None>N)	r   rV  r   rZ  r3   rN  rO  rP  r   r   ss     r   rM  zSatelliteTests.test_minimal>  sv     NN1q)!))$!++&!../GT	
r   c                L   t        j                  dddd      }| j                  |j                  d       | j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       | j                  t        |      d       y)z
        Tests a minimal satellite that only has a known PRN.

        Tests that the azimuth, elevation and signal to noise ratios
        are correct and verifies the repr.
        rx   g     p@g      >@g      9@)rZ  rN  rO  rP  z;<Satellite (1), azimuth: 270.0, elevation: 30.0, snr: 25.0>N)r   rV  r   rZ  rN  rO  rP  r   rt  s     r   r8   zSatelliteTests.test_simpleN  s     NN%4D
 	q)E*d+--t4GU	
r   Nr%   )r(   r)   r*   r+   rM  r8   r,   r   r   rr  rr  9  s    
 
r   rr  N)r   r2   r&   r   )r+   
__future__r   zope.interfacer   twisted.positioningr   twisted.positioning.baser   r    twisted.positioning.ipositioningr   twisted.trial.unittestr	   r   r.   r   r   r   r   r   r  r  rG  rg  rr  r,   r   r   <module>r}     s    # ! $ 7 ? +!E !EHt48 t4nH5h H5V34$;H $;N&6 &6R)6 )6XK, K,\T
X T
nLX L(&
X &
r   