<s> from totalimpact import collection , tiredis <EOL> from totalimpact import item as item_module <EOL> from totalimpact import db , app <EOL> from collections import OrderedDict <EOL> from totalimpact import REDIS_UNITTEST_DATABASE_NUMBER <EOL> import os , json <EOL> from nose . tools import raises , assert_equals , assert_true , nottest <EOL> import unittest <EOL> from test . utils import setup_postgres_for_unittests , teardown_postgres_for_unittests <EOL> api_items_loc = os . path . join ( <EOL> os . path . split ( __file__ ) [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' ) <EOL> API_ITEMS_JSON = json . loads ( open ( api_items_loc , "<STR_LIT:r>" ) . read ( ) ) <EOL> class TestCollection ( ) : <EOL> def setUp ( self ) : <EOL> self . d = None <EOL> self . r = tiredis . from_url ( "<STR_LIT>" , db = REDIS_UNITTEST_DATABASE_NUMBER ) <EOL> self . r . flushdb ( ) <EOL> self . db = setup_postgres_for_unittests ( db , app ) <EOL> self . aliases = [ <EOL> [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> ] <EOL> def tearDown ( self ) : <EOL> teardown_postgres_for_unittests ( self . db ) <EOL> def test_init_collection ( self ) : <EOL> response = collection . Collection . query . filter_by ( cid = "<STR_LIT>" ) . first ( ) <EOL> assert_equals ( response , None ) <EOL> new_collection = collection . Collection ( "<STR_LIT>" ) <EOL> new_cid = new_collection . cid <EOL> print new_collection <EOL> response = collection . Collection . query . filter_by ( cid = "<STR_LIT>" ) . first ( ) <EOL> assert_equals ( response , None ) <EOL> self . db . session . add ( new_collection ) <EOL> self . db . session . commit ( ) <EOL> response = collection . Collection . query . filter_by ( cid = "<STR_LIT>" ) . first ( ) <EOL> assert_equals ( response . cid , "<STR_LIT>" ) <EOL> def test_collection_with_tiids ( self ) : <EOL> test_tiid = "<STR_LIT>" <EOL> new_collection_tiid = collection . CollectionTiid ( tiid = test_tiid ) <EOL> new_collection = collection . Collection ( "<STR_LIT>" ) <EOL> new_cid = new_collection . cid <EOL> print new_collection <EOL> new_collection . tiid_links = [ new_collection_tiid ] <EOL> print new_collection . tiids <EOL> assert_equals ( new_collection . tiid_links , [ new_collection_tiid ] ) <EOL> self . db . session . add ( new_collection_tiid ) <EOL> self . db . session . add ( new_collection ) <EOL> self . db . session . commit ( ) <EOL> response = collection . Collection . query . filter_by ( cid = "<STR_LIT>" ) . first ( ) <EOL> assert_equals ( response . cid , "<STR_LIT>" ) <EOL> assert_equals ( response . tiid_links , [ new_collection_tiid ] ) <EOL> assert_equals ( new_collection_tiid . collection . query . all ( ) , [ new_collection ] ) <EOL> def test_create_new_collection ( self ) : <EOL> ( coll_doc , collection_object ) = collection . create_new_collection ( <EOL> cid = None , <EOL> title = "<STR_LIT>" , <EOL> aliases = self . aliases , <EOL> ip_address = None , <EOL> refset_metadata = None , <EOL> myredis = self . r , <EOL> mydao = self . d ) <EOL> assert_equals ( coll_doc [ "<STR_LIT:title>" ] , "<STR_LIT>" ) <EOL> expected = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert_equals ( coll_doc [ "<STR_LIT>" ] . keys ( ) , expected ) <EOL> assert_equals ( collection_object . title , "<STR_LIT>" ) <EOL> expected = [ ( u'<STR_LIT>' , u'<STR_LIT>' ) , ( u'<STR_LIT>' , u'<STR_LIT>' ) , ( u'<STR_LIT>' , u'<STR_LIT>' ) ] <EOL> assert_equals ( [ added_item . alias_tuple for added_item in collection_object . added_items ] , expected ) <EOL> assert_equals ( len ( collection_object . tiids ) , <NUM_LIT:3> ) <EOL> found_collection_object = collection . Collection . query . filter_by ( cid = collection_object . cid ) . first ( ) <EOL> assert_equals ( found_collection_object . tiids , collection_object . tiids ) <EOL> def test_create_new_collection_from_tiids ( self ) : <EOL> tiids = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> ( coll_doc , collection_object ) = collection . create_new_collection_from_tiids ( <EOL> cid = None , <EOL> title = "<STR_LIT>" , <EOL> tiids = tiids , <EOL> ip_address = None , <EOL> refset_metadata = None ) <EOL> assert_equals ( coll_doc [ "<STR_LIT:title>" ] , "<STR_LIT>" ) <EOL> assert_equals ( coll_doc [ "<STR_LIT>" ] . keys ( ) , tiids ) <EOL> assert_equals ( collection_object . title , "<STR_LIT>" ) <EOL> assert_equals ( collection_object . added_items , [ ] ) <EOL> assert_equals ( collection_object . tiids , tiids ) <EOL> found_collection_object = collection . Collection . query . filter_by ( cid = collection_object . cid ) . first ( ) <EOL> assert_equals ( found_collection_object . tiids , collection_object . tiids ) <EOL> def test_make_creates_identifier ( self ) : <EOL> coll = collection . Collection ( ) <EOL> assert_equals ( len ( coll . cid ) , <NUM_LIT:6> ) <EOL> coll = collection . Collection ( cid = "<STR_LIT>" ) <EOL> assert_equals ( coll . cid , "<STR_LIT>" ) <EOL> def test_get_titles ( self ) : <EOL> colls = [ <EOL> { "<STR_LIT>" : "<STR_LIT:1>" , "<STR_LIT:title>" : "<STR_LIT>" } , <EOL> { "<STR_LIT>" : "<STR_LIT:2>" , "<STR_LIT:title>" : "<STR_LIT>" } , <EOL> { "<STR_LIT>" : "<STR_LIT:3>" , "<STR_LIT:title>" : "<STR_LIT>" } <EOL> ] <EOL> for collection_params in colls : <EOL> new_collection = collection . Collection ( ** collection_params ) <EOL> self . db . session . add ( new_collection ) <EOL> self . db . session . commit ( ) <EOL> titlesDict = collection . get_titles ( [ "<STR_LIT:1>" , "<STR_LIT:2>" , "<STR_LIT:3>" ] ) <EOL> assert_equals ( titlesDict [ "<STR_LIT:1>" ] , "<STR_LIT>" ) <EOL> assert_equals ( titlesDict [ "<STR_LIT:3>" ] , "<STR_LIT>" ) <EOL> def test_get_metric_value_lists ( self ) : <EOL> response = collection . get_metric_value_lists ( API_ITEMS_JSON ) <EOL> print response <EOL> assert_equals ( response [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] ) <EOL> def create_test_collection ( self ) : <EOL> test_collection = { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:title>" : "<STR_LIT>" , <EOL> "<STR_LIT:type>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" } } <EOL> test_object = collection . create_objects_from_collection_doc ( test_collection ) <EOL> db . session . add ( test_object ) <EOL> biblio1 = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:title>" : "<STR_LIT>" <EOL> } <EOL> biblio2 = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:title>" : "<STR_LIT>" <EOL> } <EOL> metrics1 = { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : <NUM_LIT:4> , <EOL> "<STR_LIT>" : <NUM_LIT:3> , <EOL> "<STR_LIT>" : <NUM_LIT:4> , <EOL> "<STR_LIT>" : <NUM_LIT:9> , <EOL> } , <EOL> "<STR_LIT>" : <NUM_LIT:9> <EOL> } <EOL> } , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT:value>" : <NUM_LIT:100> , <EOL> "<STR_LIT:id>" : <NUM_LIT:2> <EOL> } <EOL> ] <EOL> } <EOL> } <EOL> } <EOL> } <EOL> metrics2 = { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } <EOL> } <EOL> } <EOL> test_item_docs = [ <EOL> { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:type>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : biblio1 , "<STR_LIT>" : metrics1 , "<STR_LIT>" : { "<STR_LIT>" : [ "<STR_LIT>" ] } } , <EOL> { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:type>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : biblio2 , "<STR_LIT>" : metrics2 , "<STR_LIT>" : { "<STR_LIT>" : [ "<STR_LIT>" ] } } <EOL> ] <EOL> for item_doc in test_item_docs : <EOL> test_object = item_module . create_objects_from_item_doc ( item_doc ) <EOL> db . session . add ( test_object ) <EOL> db . session . commit ( ) <EOL> def test_get_collection_with_items_for_client_no_history ( self ) : <EOL> self . create_test_collection ( ) <EOL> ( returned_doc , still_updating ) = collection . get_collection_with_items_for_client ( "<STR_LIT>" , None , self . r , self . d ) <EOL> assert_equals ( still_updating , False ) <EOL> print returned_doc <EOL> print json . dumps ( returned_doc , sort_keys = True , indent = <NUM_LIT:4> ) <EOL> expected = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : False , '<STR_LIT>' : { u'<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' } , '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:description>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } } , u'<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' } , '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:description>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } } } , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } , '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT>' : { u'<STR_LIT>' : [ u'<STR_LIT>' ] } } , { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : False , '<STR_LIT>' : { u'<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' } , '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:description>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } } } , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } , '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT>' : { u'<STR_LIT>' : [ u'<STR_LIT>' ] } } ] , '<STR_LIT:title>' : u'<STR_LIT>' , '<STR_LIT>' : { u'<STR_LIT>' : u'<STR_LIT>' , u'<STR_LIT>' : u'<STR_LIT>' } , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT>' } <EOL> print "<STR_LIT>" <EOL> print json . dumps ( expected , sort_keys = True , indent = <NUM_LIT:4> ) <EOL> assert_equals ( returned_doc , expected ) <EOL> def test_get_collection_with_items_for_client_include_history ( self ) : <EOL> self . create_test_collection ( ) <EOL> ( returned_doc , still_updating ) = collection . get_collection_with_items_for_client ( "<STR_LIT>" , None , self . r , self . d , include_history = True ) <EOL> assert_equals ( still_updating , False ) <EOL> print returned_doc <EOL> print json . dumps ( returned_doc , sort_keys = True , indent = <NUM_LIT:4> ) <EOL> expected = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : False , '<STR_LIT>' : { u'<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' } } , '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:description>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } } , u'<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' } } , '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:description>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } } } , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } , '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT>' : { u'<STR_LIT>' : [ u'<STR_LIT>' ] } } , { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : False , '<STR_LIT>' : { u'<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : u'<STR_LIT>' } } , '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:description>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } } } , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } , '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT>' : { u'<STR_LIT>' : [ u'<STR_LIT>' ] } } ] , '<STR_LIT:title>' : u'<STR_LIT>' , '<STR_LIT>' : { u'<STR_LIT>' : u'<STR_LIT>' , u'<STR_LIT>' : u'<STR_LIT>' } , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT>' } <EOL> assert_equals ( returned_doc , expected ) <EOL> def test_add_items_to_collection ( self ) : <EOL> self . create_test_collection ( ) <EOL> cid = "<STR_LIT>" <EOL> assert_equals ( len ( collection . Collection . query . get ( cid ) . tiids ) , <NUM_LIT:2> ) <EOL> collection_object = collection . add_items_to_collection ( <EOL> cid = cid , <EOL> aliases = [ ( "<STR_LIT>" , "<STR_LIT>" ) ] , <EOL> myredis = self . r ) <EOL> assert_equals ( len ( collection_object . tiids ) , <NUM_LIT:3> ) <EOL> assert_equals ( len ( collection . Collection . query . get ( cid ) . tiids ) , <NUM_LIT:3> ) <EOL> test_biblio = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:1>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:1>" , <EOL> "<STR_LIT:title>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> collection_object = collection . add_items_to_collection ( <EOL> cid = cid , <EOL> aliases = [ ( "<STR_LIT>" , test_biblio ) ] , <EOL> myredis = self . r ) <EOL> assert_equals ( len ( collection_object . tiids ) , <NUM_LIT:4> ) <EOL> assert_equals ( len ( collection . Collection . query . get ( cid ) . tiids ) , <NUM_LIT:4> ) <EOL> collection_object = collection . add_items_to_collection ( <EOL> cid = cid , <EOL> aliases = [ ( "<STR_LIT>" , test_biblio ) ] , <EOL> myredis = self . r ) <EOL> assert_equals ( len ( collection_object . tiids ) , <NUM_LIT:5> ) <EOL> assert_equals ( len ( collection . Collection . query . get ( cid ) . tiids ) , <NUM_LIT:5> ) <EOL> def test_make_csv_rows ( self ) : <EOL> csv = collection . make_csv_rows ( API_ITEMS_JSON ) <EOL> expected = ( OrderedDict ( [ ( '<STR_LIT>' , u'<STR_LIT>' ) , ( '<STR_LIT:title>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , <NUM_LIT:4> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT:16> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT:9> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , '<STR_LIT>' ) ] ) , [ OrderedDict ( [ ( '<STR_LIT>' , u'<STR_LIT>' ) , ( '<STR_LIT:title>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , <NUM_LIT:1> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT:7> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT:0> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT:2> ) , ( u'<STR_LIT>' , <NUM_LIT:11> ) , ( u'<STR_LIT>' , '<STR_LIT>' ) ] ) , OrderedDict ( [ ( '<STR_LIT>' , u'<STR_LIT>' ) , ( '<STR_LIT:title>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) ] ) , OrderedDict ( [ ( '<STR_LIT>' , u'<STR_LIT>' ) , ( '<STR_LIT:title>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , <NUM_LIT:4> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT:6> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT:12> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT:1> ) ] ) , OrderedDict ( [ ( '<STR_LIT>' , u'<STR_LIT>' ) , ( '<STR_LIT:title>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , '<STR_LIT>' ) , ( u'<STR_LIT>' , <NUM_LIT:4> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT:16> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , <NUM_LIT:9> ) , ( u'<STR_LIT>' , <NUM_LIT> ) , ( u'<STR_LIT>' , '<STR_LIT>' ) ] ) ] ) <EOL> assert_equals ( csv , expected ) <EOL> def test_make_csv_stream ( self ) : <EOL> csv = collection . make_csv_stream ( API_ITEMS_JSON ) <EOL> expected = '<STR_LIT>' <EOL> assert_equals ( csv , expected ) <EOL> def test_get_metric_values_of_reference_sets ( self ) : <EOL> response = collection . get_metric_values_of_reference_sets ( API_ITEMS_JSON ) <EOL> print response <EOL> assert_equals ( response [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] ) <EOL> def test_get_normalization_confidence_interval_ranges ( self ) : <EOL> input = { "<STR_LIT>" : [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , <EOL> "<STR_LIT>" : [ <NUM_LIT:10> , <NUM_LIT:9> , <NUM_LIT:8> , <NUM_LIT:7> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> } <EOL> table = [ ( <NUM_LIT:0> , <NUM_LIT:30> ) , ( <NUM_LIT:10> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:50> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) ] <EOL> response = collection . get_normalization_confidence_interval_ranges ( input , table ) <EOL> print response <EOL> expected = { '<STR_LIT>' : { <NUM_LIT:0> : { '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT:50> } , <EOL> <NUM_LIT:1> : { '<STR_LIT>' : <NUM_LIT:50> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> } , <EOL> <NUM_LIT:2> : { '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:100> , <EOL> '<STR_LIT>' : <NUM_LIT:100> , <EOL> '<STR_LIT>' : <NUM_LIT:100> } } , <EOL> '<STR_LIT>' : { <NUM_LIT:0> : { '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT> } , <EOL> <NUM_LIT:1> : { '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:100> , <EOL> '<STR_LIT>' : <NUM_LIT:100> , <EOL> '<STR_LIT>' : <NUM_LIT:100> } } , <EOL> '<STR_LIT>' : { <NUM_LIT:7> : { '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT:30> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT:0> } , <EOL> <NUM_LIT:8> : { '<STR_LIT>' : <NUM_LIT:10> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> } , <EOL> <NUM_LIT:9> : { '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:50> , <EOL> '<STR_LIT>' : <NUM_LIT:50> } , <EOL> <NUM_LIT:10> : { '<STR_LIT>' : <NUM_LIT:50> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> } , <EOL> <NUM_LIT:11> : { '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:100> , <EOL> '<STR_LIT>' : <NUM_LIT:100> , <EOL> '<STR_LIT>' : <NUM_LIT:100> } } } <EOL> assert_equals ( response , expected ) <EOL> def test_calc_table_internals ( self ) : <EOL> response = collection . calc_confidence_interval_table ( <NUM_LIT:9> , <NUM_LIT> , [ <NUM_LIT:50> ] ) <EOL> assert_equals ( response [ "<STR_LIT>" ] [ <NUM_LIT:50> ] , <NUM_LIT> ) <EOL> assert_equals ( response [ "<STR_LIT>" ] [ <NUM_LIT:50> ] , ( <NUM_LIT:3> , <NUM_LIT:7> ) ) <EOL> response = collection . calc_confidence_interval_table ( <NUM_LIT:9> , <NUM_LIT> , [ <NUM_LIT:50> ] ) <EOL> assert_equals ( response [ "<STR_LIT>" ] [ <NUM_LIT:50> ] , <NUM_LIT> ) <EOL> assert_equals ( response [ "<STR_LIT>" ] [ <NUM_LIT:50> ] , ( <NUM_LIT:2> , <NUM_LIT:8> ) ) <EOL> response = collection . calc_confidence_interval_table ( <NUM_LIT> , <NUM_LIT> , [ <NUM_LIT:50> ] ) <EOL> assert_equals ( response [ "<STR_LIT>" ] [ <NUM_LIT:50> ] , <NUM_LIT> ) <EOL> assert_equals ( response [ "<STR_LIT>" ] [ <NUM_LIT:50> ] , ( <NUM_LIT:4> , <NUM_LIT:11> ) ) <EOL> def test_calc_table_extremes ( self ) : <EOL> response = collection . calc_confidence_interval_table ( <NUM_LIT:9> , <NUM_LIT> , [ <NUM_LIT> ] ) <EOL> assert_equals ( response [ "<STR_LIT>" ] [ <NUM_LIT> ] , <NUM_LIT> ) <EOL> assert_equals ( response [ "<STR_LIT>" ] [ <NUM_LIT> ] , ( <NUM_LIT:6> , <NUM_LIT:10> ) ) <EOL> response = collection . calc_confidence_interval_table ( <NUM_LIT:9> , <NUM_LIT> , [ <NUM_LIT:10> ] ) <EOL> assert_equals ( response [ "<STR_LIT>" ] [ <NUM_LIT:10> ] , <NUM_LIT> ) <EOL> assert_equals ( response [ "<STR_LIT>" ] [ <NUM_LIT:10> ] , ( <NUM_LIT:0> , <NUM_LIT:4> ) ) <EOL> def test_calc_table ( self ) : <EOL> response = collection . calc_confidence_interval_table ( <NUM_LIT:9> , <NUM_LIT> , [ i * <NUM_LIT:10> for i in range ( <NUM_LIT:10> ) ] ) <EOL> print response [ "<STR_LIT>" ] <EOL> expected = [ ( <NUM_LIT:10> , <NUM_LIT:30> ) , ( <NUM_LIT:10> , <NUM_LIT> ) , ( <NUM_LIT:10> , <NUM_LIT> ) , ( <NUM_LIT:20> , <NUM_LIT> ) , ( <NUM_LIT:30> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:50> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) ] <EOL> assert_equals ( response [ "<STR_LIT>" ] , expected ) <EOL> response = collection . calc_confidence_interval_table ( <NUM_LIT:50> , <NUM_LIT> , range ( <NUM_LIT:100> ) ) <EOL> print response [ "<STR_LIT>" ] <EOL> expected = [ ( <NUM_LIT:1> , <NUM_LIT:9> ) , ( <NUM_LIT:1> , <NUM_LIT> ) , ( <NUM_LIT:2> , <NUM_LIT:15> ) , ( <NUM_LIT:3> , <NUM_LIT> ) , ( <NUM_LIT:5> , <NUM_LIT> ) , ( <NUM_LIT:6> , <NUM_LIT> ) , ( <NUM_LIT:7> , <NUM_LIT> ) , ( <NUM_LIT:8> , <NUM_LIT> ) , ( <NUM_LIT:10> , <NUM_LIT> ) , ( <NUM_LIT:12> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:16> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:20> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT:50> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:30> , <NUM_LIT> ) , ( <NUM_LIT:32> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT:64> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:50> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) ] <EOL> assert_equals ( response [ "<STR_LIT>" ] , expected ) </s>
