<s> """<STR_LIT>""" <EOL> import datetime <EOL> import ConfigParser <EOL> import os <EOL> import time <EOL> import timetric <EOL> import unittest <EOL> from cStringIO import StringIO <EOL> class TimetricTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> conf = ConfigParser . ConfigParser ( ) <EOL> conf . read ( os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' ) ) <EOL> self . client = timetric . TimetricClient ( dict ( conf . items ( '<STR_LIT>' ) ) ) <EOL> def tearDown ( self ) : <EOL> self . client = None <EOL> def make_series ( self , data = None ) : <EOL> return self . client . create_series ( <EOL> caption = '<STR_LIT>' , <EOL> title = '<STR_LIT>' , <EOL> data = data , <EOL> ) <EOL> def test_create_series ( self ) : <EOL> series = self . make_series ( ) <EOL> self . assertEqual ( list ( series ) , [ ] ) <EOL> series . delete ( ) <EOL> def test_create_series_with_data ( self ) : <EOL> data = [ <EOL> ( <NUM_LIT> , <NUM_LIT:1.0> ) , <EOL> ( <NUM_LIT> , <NUM_LIT> ) , <EOL> ( <NUM_LIT> , <NUM_LIT> ) , <EOL> ] <EOL> series = self . make_series ( data ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> self . assertEqual ( list ( series ) , data ) <EOL> series . delete ( ) <EOL> def test_update_single_value ( self ) : <EOL> series = self . make_series ( ) <EOL> series . update ( <NUM_LIT> ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> self . assertEqual ( float ( series ) , <NUM_LIT> ) <EOL> series . delete ( ) <EOL> def test_update_from_iterable ( self ) : <EOL> series = self . make_series ( ) <EOL> data = [ <EOL> ( <NUM_LIT> , <NUM_LIT:1.0> ) , <EOL> ( <NUM_LIT> , <NUM_LIT> ) , <EOL> ( <NUM_LIT> , <NUM_LIT> ) , <EOL> ] <EOL> series . update ( data ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> self . assertEqual ( len ( list ( series ) ) , <NUM_LIT:3> ) <EOL> series . delete ( ) <EOL> def test_update_from_file ( self ) : <EOL> io = StringIO ( '<STR_LIT>' ) <EOL> series = self . make_series ( ) <EOL> series . update ( io ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> self . assertEqual ( len ( list ( series ) ) , <NUM_LIT:3> ) <EOL> series . delete ( ) <EOL> def test_increment_decrement ( self ) : <EOL> series = self . make_series ( ) <EOL> series . update ( <NUM_LIT> ) <EOL> series . increment ( <NUM_LIT> ) <EOL> series . increment ( - <NUM_LIT> ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> self . assertEqual ( float ( series ) , <NUM_LIT> ) <EOL> series . delete ( ) <EOL> def test_increment_syntactic_sugar ( self ) : <EOL> series = self . make_series ( ) <EOL> series . update ( <NUM_LIT> ) <EOL> series += <NUM_LIT> <EOL> series -= <NUM_LIT> <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> self . assertEqual ( float ( series ) , <NUM_LIT> ) <EOL> series . delete ( ) <EOL> def test_rewrite ( self ) : <EOL> series = self . make_series ( ) <EOL> data = [ <EOL> ( <NUM_LIT> , <NUM_LIT:1.0> ) , <EOL> ( <NUM_LIT> , <NUM_LIT> ) , <EOL> ( <NUM_LIT> , <NUM_LIT> ) , <EOL> ] <EOL> series . update ( data ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> self . assertEqual ( len ( list ( series ) ) , <NUM_LIT:3> ) <EOL> data2 = [ <EOL> ( <NUM_LIT> , <NUM_LIT:9> ) , <EOL> ( <NUM_LIT> , <NUM_LIT:10> ) , <EOL> ( <NUM_LIT> , <NUM_LIT:11> ) , <EOL> ] <EOL> series . rewrite ( data2 ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> self . assertEqual ( list ( series ) , data2 ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import httplib2 <EOL> unittest . main ( ) </s>
