<s> import unittest <EOL> from libsaas import port <EOL> from libsaas . services import stripe <EOL> from libsaas . executors import test_executor <EOL> from libsaas . services . base import MethodNotSupported <EOL> class StripeTestCase ( 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 = stripe . Stripe ( '<STR_LIT>' ) <EOL> def expect ( self , method = None , uri = None , params = { } , headers = 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> if params : <EOL> self . assertEqual ( self . executor . request . params , params ) <EOL> if headers : <EOL> self . assertEqual ( self . executor . request . headers , headers ) <EOL> def test_account ( self ) : <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . account ( ) . create ( ) <EOL> self . service . account ( ) . update ( ) <EOL> self . service . account ( ) . delete ( ) <EOL> self . service . account ( ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> def test_plans ( self ) : <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . plans ( ) . update ( ) <EOL> self . service . plans ( ) . delete ( ) <EOL> self . service . plans ( ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : <NUM_LIT:10> } ) <EOL> self . service . plans ( ) . get ( limit = <NUM_LIT> ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : <NUM_LIT> } ) <EOL> self . service . plans ( ) . create ( { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . plan ( '<STR_LIT>' ) . create ( ) <EOL> self . service . plan ( '<STR_LIT>' ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . plan ( '<STR_LIT>' ) . update ( { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . service . plan ( '<STR_LIT>' ) . delete ( ) <EOL> self . expect ( '<STR_LIT>' , '<STR_LIT>' , { } ) <EOL> def test_charges ( self ) : <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . charges ( ) . update ( ) <EOL> self . service . charges ( ) . delete ( ) <EOL> self . service . charges ( ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . charges ( ) . get ( customer = '<STR_LIT>' , limit = <NUM_LIT> ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . service . charges ( ) . create ( { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . charge ( '<STR_LIT>' ) . create ( ) <EOL> self . service . charge ( '<STR_LIT>' ) . update ( ) <EOL> self . service . charge ( '<STR_LIT>' ) . delete ( ) <EOL> self . service . charge ( '<STR_LIT>' ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . charge ( '<STR_LIT>' ) . dispute ( { } ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { } ) <EOL> self . service . charge ( '<STR_LIT>' ) . refund ( ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { } ) <EOL> self . service . charge ( '<STR_LIT>' ) . refund ( amount = <NUM_LIT> ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { '<STR_LIT>' : <NUM_LIT> } ) <EOL> def test_customers ( self ) : <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . customers ( ) . update ( ) <EOL> self . service . customers ( ) . delete ( ) <EOL> self . service . customers ( ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . customers ( ) . get ( limit = <NUM_LIT> , ending_before = '<STR_LIT>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . service . customers ( ) . create ( { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . customer ( '<STR_LIT>' ) . create ( ) <EOL> self . service . customer ( '<STR_LIT>' ) . subscription ( ) . create ( ) <EOL> self . service . customer ( '<STR_LIT>' ) . discount ( ) . get ( ) <EOL> self . service . customer ( '<STR_LIT>' ) . discount ( ) . create ( ) <EOL> self . service . customer ( '<STR_LIT>' ) . discount ( ) . update ( ) <EOL> self . service . customer ( '<STR_LIT>' ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . customer ( '<STR_LIT>' ) . update ( { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . service . customer ( '<STR_LIT>' ) . delete ( ) <EOL> self . expect ( '<STR_LIT>' , '<STR_LIT>' , { } ) <EOL> self . service . customer ( '<STR_LIT>' ) . subscriptions ( ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . customer ( '<STR_LIT>' ) . subscription ( '<STR_LIT>' ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . customer ( '<STR_LIT>' ) . subscription ( '<STR_LIT>' ) . update ( <EOL> { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , <EOL> { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . service . customer ( '<STR_LIT>' ) . subscription ( '<STR_LIT>' ) . delete ( ) <EOL> self . expect ( '<STR_LIT>' , '<STR_LIT>' , <EOL> { } ) <EOL> self . service . customer ( '<STR_LIT>' ) . discount ( ) . delete ( ) <EOL> self . expect ( '<STR_LIT>' , '<STR_LIT>' , { } ) <EOL> def test_tokens ( self ) : <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . tokens ( ) . get ( ) <EOL> self . service . tokens ( ) . update ( ) <EOL> self . service . tokens ( ) . delete ( ) <EOL> self . service . tokens ( ) . create ( { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . token ( '<STR_LIT>' ) . create ( ) <EOL> self . service . token ( '<STR_LIT>' ) . update ( ) <EOL> self . service . token ( '<STR_LIT>' ) . delete ( ) <EOL> self . service . token ( '<STR_LIT>' ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> def test_invoices ( self ) : <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . invoices ( ) . update ( ) <EOL> self . service . invoices ( ) . delete ( ) <EOL> self . service . invoices ( ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . invoices ( ) . get ( customer = <NUM_LIT> ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : <NUM_LIT> } ) <EOL> self . service . invoices ( ) . upcoming ( '<STR_LIT>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . service . invoices ( ) . create ( { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . invoice ( '<STR_LIT>' ) . create ( ) <EOL> self . service . invoice ( '<STR_LIT>' ) . delete ( ) <EOL> self . service . invoice ( '<STR_LIT>' ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . invoice ( '<STR_LIT>' ) . update ( { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . service . invoice ( '<STR_LIT>' ) . pay ( ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { } ) <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . invoice ( '<STR_LIT>' ) . lines ( ) . create ( ) <EOL> self . service . invoice ( '<STR_LIT>' ) . lines ( ) . update ( ) <EOL> self . service . invoice ( '<STR_LIT>' ) . lines ( ) . delete ( ) <EOL> self . service . invoice ( '<STR_LIT>' ) . lines ( ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . invoice ( '<STR_LIT>' ) . lines ( ) . get ( limit = <NUM_LIT:1> ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> def test_events ( self ) : <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . events ( ) . create ( ) <EOL> self . service . events ( ) . update ( ) <EOL> self . service . events ( ) . delete ( ) <EOL> self . service . events ( ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . events ( ) . get ( type = '<STR_LIT:type>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT:type>' : '<STR_LIT:type>' } ) <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . event ( '<STR_LIT>' ) . create ( ) <EOL> self . service . event ( '<STR_LIT>' ) . update ( ) <EOL> self . service . event ( '<STR_LIT>' ) . delete ( ) <EOL> self . service . event ( '<STR_LIT>' ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> def test_coupons ( self ) : <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . coupons ( ) . update ( ) <EOL> self . service . coupons ( ) . delete ( ) <EOL> self . service . coupons ( ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . coupons ( ) . get ( limit = <NUM_LIT> ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : <NUM_LIT> } ) <EOL> self . service . coupons ( ) . create ( { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . coupon ( '<STR_LIT>' ) . create ( ) <EOL> self . service . coupon ( '<STR_LIT>' ) . update ( ) <EOL> self . service . coupon ( '<STR_LIT>' ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . coupon ( '<STR_LIT>' ) . delete ( ) <EOL> self . expect ( '<STR_LIT>' , '<STR_LIT>' , { } ) <EOL> def test_invoiceitems ( self ) : <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . invoiceitems ( ) . update ( ) <EOL> self . service . invoiceitems ( ) . delete ( ) <EOL> self . service . invoiceitems ( ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . invoiceitems ( ) . get ( limit = <NUM_LIT> ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : <NUM_LIT> } ) <EOL> self . service . invoiceitems ( ) . create ( { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> self . expect ( '<STR_LIT:POST>' , '<STR_LIT>' , { '<STR_LIT:key>' : '<STR_LIT:value>' } ) <EOL> with port . assertRaises ( MethodNotSupported ) : <EOL> self . service . invoiceitem ( '<STR_LIT>' ) . create ( ) <EOL> self . service . invoiceitem ( '<STR_LIT>' ) . update ( ) <EOL> self . service . invoiceitem ( '<STR_LIT>' ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . invoiceitem ( '<STR_LIT>' ) . delete ( ) <EOL> self . expect ( '<STR_LIT>' , '<STR_LIT>' , { } ) </s>
