<s> from xml . etree import ElementTree <EOL> from unittest import TestCase <EOL> from tapioca . spec import APISpecification , Resource , Path , Param , Method , WADLSpecification <EOL> class WADLSpecGeneration ( TestCase ) : <EOL> def gen ( self , spec ) : <EOL> return WADLSpecification ( spec ) . generate ( ) <EOL> def test_generate_basic_spec ( self ) : <EOL> api = APISpecification ( version = '<STR_LIT>' , base_url = '<STR_LIT>' ) <EOL> result = self . gen ( api ) <EOL> assert '<STR_LIT>' in result , result <EOL> def test_generate_with_resource ( self ) : <EOL> api = APISpecification ( version = '<STR_LIT>' , base_url = '<STR_LIT>' ) <EOL> api . add_resource ( <EOL> Resource ( '<STR_LIT>' , <EOL> paths = [ <EOL> Path ( '<STR_LIT>' , methods = [ Method ( '<STR_LIT:GET>' ) ] ) <EOL> ] ) ) <EOL> result = self . gen ( api ) <EOL> doc = ElementTree . fromstring ( result ) <EOL> assert doc . tag . endswith ( '<STR_LIT>' ) <EOL> resources = doc . getchildren ( ) [ <NUM_LIT:0> ] <EOL> assert resources . tag . endswith ( '<STR_LIT>' ) <EOL> assert resources . get ( '<STR_LIT>' ) == '<STR_LIT>' <EOL> resource = resources . getchildren ( ) [ <NUM_LIT:0> ] <EOL> assert resource . tag . endswith ( '<STR_LIT>' ) <EOL> assert resource . get ( '<STR_LIT:path>' ) == '<STR_LIT>' <EOL> method = resource . getchildren ( ) [ <NUM_LIT:0> ] <EOL> assert method . tag . endswith ( '<STR_LIT>' ) <EOL> assert method . get ( '<STR_LIT:name>' ) == '<STR_LIT:GET>' <EOL> def test_genetate_with_more_than_one_resource ( self ) : <EOL> api = APISpecification ( version = '<STR_LIT>' , base_url = '<STR_LIT>' ) <EOL> api . add_resource ( Resource ( '<STR_LIT>' , <EOL> paths = [ <EOL> Path ( '<STR_LIT>' , methods = [ <EOL> Method ( '<STR_LIT>' ) ] ) ] ) ) <EOL> api . add_resource ( Resource ( '<STR_LIT>' , <EOL> paths = [ <EOL> Path ( '<STR_LIT>' , methods = [ <EOL> Method ( '<STR_LIT>' ) ] ) ] ) ) <EOL> result = self . gen ( api ) <EOL> doc = ElementTree . fromstring ( result ) <EOL> assert doc . tag . endswith ( '<STR_LIT>' ) <EOL> resource = doc . getchildren ( ) [ <NUM_LIT:0> ] <EOL> resources = resource . getchildren ( ) <EOL> assert len ( resources ) == <NUM_LIT:2> <EOL> assert resources [ <NUM_LIT:0> ] . tag . endswith ( '<STR_LIT>' ) <EOL> assert resources [ <NUM_LIT:0> ] . get ( '<STR_LIT:path>' ) == '<STR_LIT>' <EOL> method = resources [ <NUM_LIT:0> ] . getchildren ( ) [ <NUM_LIT:0> ] <EOL> assert method . tag . endswith ( '<STR_LIT>' ) <EOL> assert method . get ( '<STR_LIT:name>' ) == '<STR_LIT>' <EOL> assert resources [ <NUM_LIT:1> ] . tag . endswith ( '<STR_LIT>' ) <EOL> assert resources [ <NUM_LIT:1> ] . get ( '<STR_LIT:path>' ) == '<STR_LIT>' <EOL> method = resources [ <NUM_LIT:1> ] . getchildren ( ) [ <NUM_LIT:0> ] <EOL> assert method . tag . endswith ( '<STR_LIT>' ) <EOL> assert method . get ( '<STR_LIT:name>' ) == '<STR_LIT>' <EOL> def test_generate_with_params ( self ) : <EOL> api = APISpecification ( version = '<STR_LIT>' , base_url = '<STR_LIT>' ) <EOL> api . add_resource ( Resource ( '<STR_LIT>' , <EOL> paths = [ <EOL> Path ( '<STR_LIT>' , <EOL> params = [ <EOL> Param ( '<STR_LIT:key>' ) <EOL> ] , <EOL> methods = [ <EOL> Method ( '<STR_LIT:POST>' ) , <EOL> Method ( '<STR_LIT:GET>' ) <EOL> ] <EOL> ) , <EOL> ] ) <EOL> ) <EOL> result = self . gen ( api ) <EOL> doc = ElementTree . fromstring ( result ) <EOL> resources = doc . getchildren ( ) [ <NUM_LIT:0> ] <EOL> resource = resources . getchildren ( ) [ <NUM_LIT:0> ] <EOL> param = resource . getchildren ( ) [ <NUM_LIT:0> ] <EOL> assert param . tag . endswith ( '<STR_LIT>' ) <EOL> assert param . get ( '<STR_LIT:name>' ) == '<STR_LIT:key>' <EOL> assert param . get ( '<STR_LIT>' ) == '<STR_LIT:true>' <EOL> assert param . get ( '<STR_LIT:type>' ) == '<STR_LIT>' <EOL> assert param . get ( '<STR_LIT>' ) == '<STR_LIT>' <EOL> method_1 = resource . getchildren ( ) [ <NUM_LIT:1> ] <EOL> assert method_1 . tag . endswith ( '<STR_LIT>' ) <EOL> assert method_1 . get ( '<STR_LIT:name>' ) == '<STR_LIT:POST>' <EOL> method_2 = resource . getchildren ( ) [ <NUM_LIT:2> ] <EOL> assert method_2 . tag . endswith ( '<STR_LIT>' ) <EOL> assert method_2 . get ( '<STR_LIT:name>' ) == '<STR_LIT:GET>' </s>
