<s> """<STR_LIT>""" <EOL> import datetime <EOL> import hashlib <EOL> import httplib2 <EOL> import json <EOL> import os <EOL> import tempfile <EOL> from glance . common import utils <EOL> from glance . tests import functional <EOL> from glance . tests . utils import execute , skip_if_disabled <EOL> FIVE_KB = <NUM_LIT:5> * <NUM_LIT> <EOL> FIVE_GB = <NUM_LIT:5> * <NUM_LIT> * <NUM_LIT> * <NUM_LIT> <EOL> class TestApi ( functional . FunctionalTest ) : <EOL> """<STR_LIT>""" <EOL> @ skip_if_disabled <EOL> def test_get_head_simple_post ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cleanup ( ) <EOL> self . start_servers ( ** self . __dict__ . copy ( ) ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( content , '<STR_LIT>' ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( content , '<STR_LIT>' ) <EOL> image_data = "<STR_LIT:*>" * FIVE_KB <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers , <EOL> body = image_data ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> data = json . loads ( content ) <EOL> image_id = data [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] , <EOL> hashlib . md5 ( image_data ) . hexdigest ( ) ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT:size>' ] , FIVE_KB ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT:name>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] , True ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , <EOL> image_id ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , <EOL> image_id ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> expected_image_headers = { <EOL> '<STR_LIT>' : image_id , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : str ( FIVE_KB ) } <EOL> expected_std_headers = { <EOL> '<STR_LIT>' : str ( FIVE_KB ) , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> for expected_key , expected_value in expected_image_headers . items ( ) : <EOL> self . assertEqual ( response [ expected_key ] , expected_value , <EOL> "<STR_LIT>" <EOL> % ( expected_key , expected_value , <EOL> response [ expected_key ] ) ) <EOL> for expected_key , expected_value in expected_std_headers . items ( ) : <EOL> self . assertEqual ( response [ expected_key ] , expected_value , <EOL> "<STR_LIT>" <EOL> % ( expected_key , <EOL> expected_value , <EOL> response [ expected_key ] ) ) <EOL> self . assertEqual ( content , "<STR_LIT:*>" * FIVE_KB ) <EOL> self . assertEqual ( hashlib . md5 ( content ) . hexdigest ( ) , <EOL> hashlib . md5 ( "<STR_LIT:*>" * FIVE_KB ) . hexdigest ( ) ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> expected_result = { "<STR_LIT>" : [ <EOL> { "<STR_LIT>" : None , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT:id>" : image_id , <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:size>" : <NUM_LIT> } ] } <EOL> self . assertEqual ( json . loads ( content ) , expected_result ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> expected_image = { <EOL> "<STR_LIT:status>" : "<STR_LIT>" , <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : False , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT:id>" : image_id , <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : { } , <EOL> "<STR_LIT:size>" : <NUM_LIT> } <EOL> image = json . loads ( content ) <EOL> for expected_key , expected_value in expected_image . items ( ) : <EOL> self . assertEqual ( expected_value , image [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ expected_key ] , <EOL> "<STR_LIT>" <EOL> % ( expected_key , <EOL> expected_value , <EOL> image [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ expected_key ] ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , <EOL> image_id ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> expected_image = { <EOL> "<STR_LIT:status>" : "<STR_LIT>" , <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : False , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT:id>" : image_id , <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } , <EOL> "<STR_LIT:size>" : <NUM_LIT> } <EOL> image = json . loads ( content ) <EOL> for expected_key , expected_value in expected_image . items ( ) : <EOL> self . assertEqual ( expected_value , image [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ expected_key ] , <EOL> "<STR_LIT>" <EOL> % ( expected_key , <EOL> expected_value , <EOL> image [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ expected_key ] ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , <EOL> image_id ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , <EOL> image_id ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , <EOL> image_id ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . stop_servers ( ) <EOL> @ skip_if_disabled <EOL> def test_queued_process_flow ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cleanup ( ) <EOL> self . start_servers ( ** self . __dict__ . copy ( ) ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( content , '<STR_LIT>' ) <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT:size>' ] , <NUM_LIT:0> ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT:name>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] , True ) <EOL> image_id = data [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] , image_id ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:size>' ] , <NUM_LIT:0> ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:name>' ] , "<STR_LIT>" ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , <EOL> image_id ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , '<STR_LIT:0>' ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , image_id ) <EOL> image_data = "<STR_LIT:*>" * FIVE_KB <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , <EOL> image_id ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' , headers = headers , <EOL> body = image_data ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] , <EOL> hashlib . md5 ( image_data ) . hexdigest ( ) ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT:size>' ] , FIVE_KB ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT:name>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] , True ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , <EOL> image_id ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , <EOL> hashlib . md5 ( image_data ) . hexdigest ( ) ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] , image_id ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:size>' ] , FIVE_KB ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:name>' ] , "<STR_LIT>" ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , <EOL> image_id ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . stop_servers ( ) <EOL> @ skip_if_disabled <EOL> def test_version_variations ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cleanup ( ) <EOL> self . start_servers ( ** self . __dict__ . copy ( ) ) <EOL> versions = { '<STR_LIT>' : [ { <EOL> "<STR_LIT:id>" : "<STR_LIT>" , <EOL> "<STR_LIT:status>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" % self . api_port } ] } , { <EOL> "<STR_LIT:id>" : "<STR_LIT>" , <EOL> "<STR_LIT:status>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" % self . api_port } ] } ] } <EOL> versions_json = json . dumps ( versions ) <EOL> images = { '<STR_LIT>' : [ ] } <EOL> images_json = json . dumps ( images ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> self . assertEqual ( content , versions_json ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> self . assertEqual ( content , versions_json ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( content , images_json ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response , content = http . request ( path , '<STR_LIT:GET>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> self . assertEqual ( content , versions_json ) <EOL> self . assertTrue ( '<STR_LIT>' <EOL> in open ( self . api_server . log_file ) . read ( ) ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response , content = http . request ( path , '<STR_LIT:GET>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( content , images_json ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response , content = http . request ( path , '<STR_LIT:GET>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> self . assertEqual ( content , versions_json ) <EOL> self . assertTrue ( '<STR_LIT>' <EOL> in open ( self . api_server . log_file ) . read ( ) ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( content , images_json ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( content , images_json ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> self . assertEqual ( content , versions_json ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> self . assertEqual ( content , versions_json ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response , content = http . request ( path , '<STR_LIT:GET>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> self . assertEqual ( content , versions_json ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> self . assertEqual ( content , versions_json ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response , content = http . request ( path , '<STR_LIT:GET>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> self . assertEqual ( content , versions_json ) <EOL> self . assertTrue ( '<STR_LIT>' <EOL> in open ( self . api_server . log_file ) . read ( ) ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> self . assertEqual ( content , versions_json ) <EOL> self . assertTrue ( '<STR_LIT>' <EOL> in open ( self . api_server . log_file ) . read ( ) ) <EOL> self . stop_servers ( ) <EOL> @ skip_if_disabled <EOL> def test_size_greater_2G_mysql ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cleanup ( ) <EOL> self . start_servers ( ** self . __dict__ . copy ( ) ) <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : str ( FIVE_GB ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> path = response . get ( '<STR_LIT:location>' ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , str ( FIVE_GB ) ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , '<STR_LIT:True>' ) <EOL> self . stop_servers ( ) <EOL> @ skip_if_disabled <EOL> def test_traceback_not_consumed ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cleanup ( ) <EOL> self . start_servers ( ** self . __dict__ . copy ( ) ) <EOL> with tempfile . NamedTemporaryFile ( ) as test_data_file : <EOL> test_data_file . write ( "<STR_LIT>" ) <EOL> test_data_file . flush ( ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , <EOL> body = test_data_file . name ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> expected = "<STR_LIT>" <EOL> self . assertTrue ( expected in content , <EOL> "<STR_LIT>" % ( expected , content ) ) <EOL> self . stop_servers ( ) <EOL> @ skip_if_disabled <EOL> def test_filtered_images ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cleanup ( ) <EOL> self . start_servers ( ** self . __dict__ . copy ( ) ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( content , '<STR_LIT>' ) <EOL> image_ids = [ ] <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] , True ) <EOL> image_ids . append ( data [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] ) <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' , <EOL> '<STR_LIT>' : '<STR_LIT:False>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] , True ) <EOL> image_ids . append ( data [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] ) <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' , <EOL> '<STR_LIT>' : '<STR_LIT:False>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] , True ) <EOL> image_ids . append ( data [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] ) <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:False>' , <EOL> '<STR_LIT>' : '<STR_LIT:False>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( data [ '<STR_LIT:image>' ] [ '<STR_LIT>' ] , False ) <EOL> image_ids . append ( data [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:3> ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> for image in data [ '<STR_LIT>' ] : <EOL> self . assertEqual ( image [ '<STR_LIT:name>' ] , "<STR_LIT>" ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:3> ) <EOL> for image in data [ '<STR_LIT>' ] : <EOL> self . assertEqual ( image [ '<STR_LIT:status>' ] , "<STR_LIT>" ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:0> ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> for image in data [ '<STR_LIT>' ] : <EOL> self . assertEqual ( image [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> for image in data [ '<STR_LIT>' ] : <EOL> self . assertEqual ( image [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> for image in data [ '<STR_LIT>' ] : <EOL> self . assertTrue ( image [ '<STR_LIT:size>' ] <= <NUM_LIT:20> ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> for image in data [ '<STR_LIT>' ] : <EOL> self . assertTrue ( image [ '<STR_LIT:size>' ] >= <NUM_LIT:20> ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:4> ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> for image in data [ '<STR_LIT>' ] : <EOL> self . assertEqual ( image [ '<STR_LIT:name>' ] , "<STR_LIT>" ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:3> ) <EOL> for image in data [ '<STR_LIT>' ] : <EOL> self . assertNotEqual ( image [ '<STR_LIT:name>' ] , "<STR_LIT>" ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> for image in data [ '<STR_LIT>' ] : <EOL> self . assertNotEqual ( image [ '<STR_LIT:name>' ] , "<STR_LIT>" ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> for image in data [ '<STR_LIT>' ] : <EOL> self . assertEqual ( image [ '<STR_LIT:name>' ] , "<STR_LIT>" ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> for image in data [ '<STR_LIT>' ] : <EOL> self . assertEqual ( image [ '<STR_LIT>' ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> for image in data [ '<STR_LIT>' ] : <EOL> self . assertEqual ( image [ '<STR_LIT>' ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( image [ '<STR_LIT:name>' ] , "<STR_LIT>" ) <EOL> dt1 = datetime . datetime . utcnow ( ) - datetime . timedelta ( <NUM_LIT:1> ) <EOL> iso1 = utils . isotime ( dt1 ) <EOL> params = "<STR_LIT>" % iso1 <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:3> ) <EOL> dt2 = datetime . datetime . utcnow ( ) + datetime . timedelta ( <NUM_LIT:1> ) <EOL> iso2 = utils . isotime ( dt2 ) <EOL> params = "<STR_LIT>" % iso2 <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:0> ) <EOL> self . stop_servers ( ) <EOL> @ skip_if_disabled <EOL> def test_limited_images ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cleanup ( ) <EOL> self . start_servers ( ** self . __dict__ . copy ( ) ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( content , '<STR_LIT>' ) <EOL> image_ids = [ ] <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> image_ids . append ( json . loads ( content ) [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] ) <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> image_ids . append ( json . loads ( content ) [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] ) <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> image_ids . append ( json . loads ( content ) [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> images = json . loads ( content ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( len ( images ) , <NUM_LIT:3> ) <EOL> print images <EOL> params = "<STR_LIT>" <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( len ( data ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] , images [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( data [ <NUM_LIT:1> ] [ '<STR_LIT:id>' ] , images [ <NUM_LIT:1> ] [ '<STR_LIT:id>' ] ) <EOL> params = "<STR_LIT>" % images [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( len ( data ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] , images [ <NUM_LIT:1> ] [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( data [ <NUM_LIT:1> ] [ '<STR_LIT:id>' ] , images [ <NUM_LIT:2> ] [ '<STR_LIT:id>' ] ) <EOL> params = "<STR_LIT>" % images [ <NUM_LIT:1> ] [ '<STR_LIT:id>' ] <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( len ( data ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] , images [ <NUM_LIT:2> ] [ '<STR_LIT:id>' ] ) <EOL> params = "<STR_LIT>" % images [ <NUM_LIT:1> ] [ '<STR_LIT:id>' ] <EOL> path = "<STR_LIT>" % ( <EOL> "<STR_LIT>" , self . api_port , params ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( len ( data ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] , images [ <NUM_LIT:2> ] [ '<STR_LIT:id>' ] ) <EOL> for image_id in image_ids : <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , <EOL> image_id ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . stop_servers ( ) <EOL> @ skip_if_disabled <EOL> def test_ordered_images ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cleanup ( ) <EOL> self . start_servers ( ** self . __dict__ . copy ( ) ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( content , '<STR_LIT>' ) <EOL> image_ids = [ ] <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> image_ids . append ( json . loads ( content ) [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] ) <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> image_ids . append ( json . loads ( content ) [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] ) <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:5>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> image_ids . append ( json . loads ( content ) [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] , image_ids [ <NUM_LIT:2> ] ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT:id>' ] , image_ids [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:2> ] [ '<STR_LIT:id>' ] , image_ids [ <NUM_LIT:0> ] ) <EOL> params = '<STR_LIT>' <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , params ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] , image_ids [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT:id>' ] , image_ids [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:2> ] [ '<STR_LIT:id>' ] , image_ids [ <NUM_LIT:2> ] ) <EOL> params = '<STR_LIT>' <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , params ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] , image_ids [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT:id>' ] , image_ids [ <NUM_LIT:2> ] ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:2> ] [ '<STR_LIT:id>' ] , image_ids [ <NUM_LIT:1> ] ) <EOL> params = '<STR_LIT>' % image_ids [ <NUM_LIT:0> ] <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , params ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] , image_ids [ <NUM_LIT:2> ] ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT:id>' ] , image_ids [ <NUM_LIT:1> ] ) <EOL> params = '<STR_LIT>' % image_ids [ <NUM_LIT:2> ] <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , params ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> data = json . loads ( content ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:0> ) <EOL> for image_id in image_ids : <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port , <EOL> image_id ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . stop_servers ( ) <EOL> @ skip_if_disabled <EOL> def test_duplicate_image_upload ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cleanup ( ) <EOL> self . start_servers ( ** self . __dict__ . copy ( ) ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( content , '<STR_LIT>' ) <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:True>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> image = json . loads ( content ) [ '<STR_LIT:image>' ] <EOL> headers = { '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : image [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : '<STR_LIT:True>' } <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:POST>' , headers = headers ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> self . stop_servers ( ) <EOL> @ skip_if_disabled <EOL> def test_delete_not_existing ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cleanup ( ) <EOL> self . start_servers ( ** self . __dict__ . copy ( ) ) <EOL> api_port = self . api_port <EOL> registry_port = self . registry_port <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT:200> ) <EOL> self . assertEqual ( content , '<STR_LIT>' ) <EOL> path = "<STR_LIT>" % ( "<STR_LIT>" , self . api_port ) <EOL> http = httplib2 . Http ( ) <EOL> response , content = http . request ( path , '<STR_LIT>' ) <EOL> self . assertEqual ( response . status , <NUM_LIT> ) <EOL> self . stop_servers ( ) <EOL> @ skip_if_disabled <EOL> def test_unsupported_default_store ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cleanup ( ) <EOL> self . api_server . default_store = '<STR_LIT>' <EOL> self . start_server ( self . api_server , <EOL> expect_launch = False , <EOL> ** self . __dict__ . copy ( ) ) </s>
