<s> import json <EOL> import unittest <EOL> from libsaas import port <EOL> from libsaas . executors import test_executor <EOL> from libsaas . services import compete <EOL> from libsaas . services . base import MethodNotSupported <EOL> class CompeteTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . executor = test_executor . use ( ) <EOL> self . executor . set_response ( b'<STR_LIT:{}>' , <NUM_LIT:200> , { } ) <EOL> self . service = compete . Compete ( '<STR_LIT>' ) <EOL> def expect ( self , method = None , uri = None , params = None ) : <EOL> if method : <EOL> self . assertEqual ( method , self . executor . request . method ) <EOL> if uri : <EOL> self . assertEqual ( self . executor . request . uri , <EOL> '<STR_LIT>' + uri ) <EOL> params = params or { } <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEqual ( self . executor . request . params , params ) <EOL> def test_sites ( self ) : <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . site ( '<STR_LIT>' ) . get ( ) <EOL> self . service . site ( '<STR_LIT>' ) . create ( ) <EOL> self . service . site ( '<STR_LIT>' ) . update ( ) <EOL> self . service . site ( '<STR_LIT>' ) . delete ( ) <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . site ( '<STR_LIT>' ) . metric ( '<STR_LIT>' ) . create ( ) <EOL> self . service . site ( '<STR_LIT>' ) . metric ( '<STR_LIT>' ) . update ( ) <EOL> self . service . site ( '<STR_LIT>' ) . metric ( '<STR_LIT>' ) . delete ( ) <EOL> self . service . site ( '<STR_LIT>' ) . metric ( '<STR_LIT>' ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . site ( '<STR_LIT>' ) . metric ( '<STR_LIT>' ) . get ( latest = <NUM_LIT:9> ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : <NUM_LIT:9> } ) <EOL> ( self . service . site ( '<STR_LIT>' ) <EOL> . metric ( '<STR_LIT>' ) . get ( start_date = '<STR_LIT>' , end_date = '<STR_LIT>' ) ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> ( self . service . site ( '<STR_LIT>' ) <EOL> . metric ( '<STR_LIT>' ) . get ( start_date = '<STR_LIT>' , end_date = '<STR_LIT>' ) ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) </s>
