@@ -99,6 +99,36 @@ def test(self):
9999 self .failUnlessEqual (a .samples [0 ].timestamp , 1434110794000 )
100100 self .failUnlessEqual (a .samples [0 ].val , 1 )
101101
102+ # test clear_samples
103+ self .failUnlessEqual (len (a .metrics ), 1 )
104+ a .clear_samples ()
105+ self .failUnlessEqual (len (a .metrics ), 0 )
106+ self .failUnlessEqual (len (a .samples ), 0 )
107+
108+ # test sparseDataStrategy
109+ a .add_sample (
110+ 'nonsparseDataStrategy' , 1434110794 , 1 , 'COUNTER' , host = 'hostname' )
111+ a .add_sample (
112+ 'sparseDataStrategy' , 1434110794 , 1 , 'COUNTER' , host = 'hostname' , sparseDataStrategy = 'ReplaceWithZero' )
113+
114+ self .failUnlessEqual (a .metrics [0 ].sparseDataStrategy , 'None' )
115+ self .failUnlessEqual (
116+ a .metrics [1 ].sparseDataStrategy , 'ReplaceWithZero' )
117+
118+ a .clear_samples ()
119+
120+ # test unit
121+ a .add_sample (
122+ 'unit' , 1434110794 , 1 , 'COUNTER' , host = 'hostname' , unit = 'Bytes' )
123+
124+ a .add_sample (
125+ 'nonunit' , 1434110794 , 1 , 'COUNTER' , host = 'hostname' )
126+
127+ self .failUnlessEqual (
128+ a .metrics [0 ].unit , 'Bytes' )
129+
130+ self .failUnlessEqual (a .metrics [1 ].unit , '' )
131+
102132 def tearDown (self ):
103133 pass
104134
0 commit comments