<s> from nose . tools import * <EOL> from website . util import permissions <EOL> from api . base . settings . defaults import API_BASE <EOL> from tests . base import ApiTestCase <EOL> from tests . factories import ( <EOL> ProjectFactory , <EOL> RegistrationFactory , <EOL> AuthUserFactory , <EOL> AlternativeCitationFactory <EOL> ) <EOL> def payload ( name = None , text = None ) : <EOL> data = { '<STR_LIT:data>' : { <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { } <EOL> } <EOL> } <EOL> if name is not None : <EOL> data [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] = name <EOL> if text is not None : <EOL> data [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] = text <EOL> return data <EOL> CITATION = payload ( name = '<STR_LIT:name>' , text = '<STR_LIT:text>' ) <EOL> REPEAT_NAME = payload ( name = '<STR_LIT:name>' , text = '<STR_LIT>' ) <EOL> REPEAT_TEXT = payload ( name = '<STR_LIT>' , text = '<STR_LIT:text>' ) <EOL> NO_NAME = payload ( text = '<STR_LIT:text>' ) <EOL> NO_TEXT = payload ( name = '<STR_LIT:name>' ) <EOL> EMPTY = payload ( ) <EOL> def create_project ( creator , public = True , contrib = None , citation = False , registration = False ) : <EOL> project = ProjectFactory ( creator = creator , is_public = public ) <EOL> if contrib : <EOL> project . add_contributor ( contrib , permissions = [ permissions . READ , permissions . WRITE ] , visible = True ) <EOL> if citation : <EOL> citation = AlternativeCitationFactory ( name = '<STR_LIT:name>' , text = '<STR_LIT:text>' ) <EOL> project . alternative_citations . append ( citation ) <EOL> project . save ( ) <EOL> if registration : <EOL> registration = RegistrationFactory ( project = project , is_public = public ) <EOL> return registration <EOL> return project <EOL> class TestCreateAlternativeCitations ( ApiTestCase ) : <EOL> def request ( self , data , errors = False , is_admin = False , is_contrib = True , logged_out = False , ** kwargs ) : <EOL> admin = AuthUserFactory ( ) <EOL> registration = kwargs . get ( '<STR_LIT>' , None ) <EOL> if is_admin : <EOL> user = admin <EOL> elif not logged_out : <EOL> user = AuthUserFactory ( ) <EOL> kwargs [ '<STR_LIT>' ] = user if is_contrib else None <EOL> project = create_project ( admin , ** kwargs ) <EOL> if registration : <EOL> project_url = '<STR_LIT>' . format ( API_BASE , project . _id ) <EOL> else : <EOL> project_url = '<STR_LIT>' . format ( API_BASE , project . _id ) <EOL> if not logged_out : <EOL> res = self . app . post_json_api ( project_url , data , auth = user . auth , expect_errors = errors ) <EOL> else : <EOL> res = self . app . post_json_api ( project_url , data , expect_errors = errors ) <EOL> return res , project <EOL> def test_add_citation_admin_public ( self ) : <EOL> res , project = self . request ( CITATION , is_admin = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( res . json [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , CITATION [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] ) <EOL> assert_equal ( res . json [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , CITATION [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_citation_admin_private ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> is_admin = True , <EOL> public = False ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( res . json [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , CITATION [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] ) <EOL> assert_equal ( res . json [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , CITATION [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_citation_non_admin_public ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_non_admin_private ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> public = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_non_contrib_public ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_non_contrib_private ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> public = False , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_logged_out_public ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_logged_out_private ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> public = False , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_repeat_name_admin_public ( self ) : <EOL> res , project = self . request ( REPEAT_NAME , <EOL> citation = True , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_admin_private ( self ) : <EOL> res , project = self . request ( REPEAT_NAME , <EOL> public = False , <EOL> citation = True , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_non_admin_public ( self ) : <EOL> res , project = self . request ( REPEAT_NAME , <EOL> citation = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_non_admin_private ( self ) : <EOL> res , project = self . request ( REPEAT_NAME , <EOL> public = False , <EOL> citation = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_non_contrib_public ( self ) : <EOL> res , project = self . request ( REPEAT_NAME , <EOL> citation = True , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_non_contrib_private ( self ) : <EOL> res , project = self . request ( REPEAT_NAME , <EOL> public = False , <EOL> is_contrib = False , <EOL> citation = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_logged_out_public ( self ) : <EOL> res , project = self . request ( REPEAT_NAME , <EOL> citation = True , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_logged_out_private ( self ) : <EOL> res , project = self . request ( REPEAT_NAME , <EOL> public = False , <EOL> citation = True , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_text_admin_public ( self ) : <EOL> res , project = self . request ( REPEAT_TEXT , <EOL> citation = True , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_text_admin_private ( self ) : <EOL> res , project = self . request ( REPEAT_TEXT , <EOL> public = False , <EOL> citation = True , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_text_non_admin_public ( self ) : <EOL> res , project = self . request ( REPEAT_TEXT , <EOL> citation = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_text_non_admin_private ( self ) : <EOL> res , project = self . request ( REPEAT_TEXT , <EOL> public = False , <EOL> citation = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_text_non_contrib_public ( self ) : <EOL> res , project = self . request ( REPEAT_TEXT , <EOL> citation = True , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_text_non_contrib_private ( self ) : <EOL> res , project = self . request ( REPEAT_TEXT , <EOL> public = False , <EOL> citation = True , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_text_logged_out_public ( self ) : <EOL> res , project = self . request ( REPEAT_TEXT , <EOL> citation = True , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_text_logged_out_private ( self ) : <EOL> res , project = self . request ( REPEAT_TEXT , <EOL> public = False , <EOL> citation = True , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_and_text_admin_public ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> citation = True , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> errors = [ error [ '<STR_LIT>' ] for error in res . json [ '<STR_LIT>' ] ] <EOL> assert_in ( "<STR_LIT>" , errors ) <EOL> assert_in ( "<STR_LIT>" , errors ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_and_text_admin_private ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> public = False , <EOL> citation = True , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> errors = [ error [ '<STR_LIT>' ] for error in res . json [ '<STR_LIT>' ] ] <EOL> assert_in ( "<STR_LIT>" , errors ) <EOL> assert_in ( "<STR_LIT>" , errors ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_and_text_non_admin_public ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> citation = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_and_text_non_admin_private ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> public = False , <EOL> citation = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_and_text_non_contrib_public ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> citation = True , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_and_text_non_contrib_private ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> public = False , <EOL> citation = True , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_and_text_logged_out_public ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> citation = True , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_repeat_name_and_text_logged_out_private ( self ) : <EOL> res , project = self . request ( CITATION , <EOL> public = False , <EOL> citation = True , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:1> ) <EOL> def test_add_no_name_admin_public ( self ) : <EOL> res , project = self . request ( NO_NAME , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_name_admin_private ( self ) : <EOL> res , project = self . request ( NO_NAME , <EOL> public = False , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_name_non_admin_public ( self ) : <EOL> res , project = self . request ( NO_NAME , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_name_non_admin_private ( self ) : <EOL> res , project = self . request ( NO_NAME , <EOL> public = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_name_non_contrib_public ( self ) : <EOL> res , project = self . request ( NO_NAME , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_name_non_contrib_private ( self ) : <EOL> res , project = self . request ( NO_NAME , <EOL> public = False , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_name_logged_out_public ( self ) : <EOL> res , project = self . request ( NO_NAME , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_name_logged_out_private ( self ) : <EOL> res , project = self . request ( NO_NAME , <EOL> public = False , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_text_admin_public ( self ) : <EOL> res , project = self . request ( NO_TEXT , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_text_admin_private ( self ) : <EOL> res , project = self . request ( NO_TEXT , <EOL> public = False , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_text_non_admin_public ( self ) : <EOL> res , project = self . request ( NO_TEXT , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_text_non_admin_private ( self ) : <EOL> res , project = self . request ( NO_TEXT , <EOL> public = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_text_non_contrib_public ( self ) : <EOL> res , project = self . request ( NO_TEXT , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_text_non_contrib_private ( self ) : <EOL> res , project = self . request ( NO_TEXT , <EOL> public = False , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_text_logged_out_public ( self ) : <EOL> res , project = self . request ( NO_TEXT , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_no_text_logged_out_private ( self ) : <EOL> res , project = self . request ( NO_TEXT , <EOL> public = False , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_empty_admin_public ( self ) : <EOL> res , project = self . request ( EMPTY , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , res . json [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_empty_admin_private ( self ) : <EOL> res , project = self . request ( EMPTY , <EOL> public = False , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , res . json [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_empty_non_admin_public ( self ) : <EOL> res , project = self . request ( EMPTY , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , res . json [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_empty_non_admin_private ( self ) : <EOL> res , project = self . request ( EMPTY , <EOL> public = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , res . json [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_empty_non_contrib_public ( self ) : <EOL> res , project = self . request ( EMPTY , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , res . json [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_empty_non_contrib_private ( self ) : <EOL> res , project = self . request ( EMPTY , <EOL> public = False , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , res . json [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_empty_logged_out_public ( self ) : <EOL> res , project = self . request ( EMPTY , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_empty_logged_out_private ( self ) : <EOL> res , project = self . request ( EMPTY , <EOL> public = False , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> project . reload ( ) <EOL> assert_equal ( len ( project . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_admin_public_reg ( self ) : <EOL> res , registration = self . request ( CITATION , <EOL> registration = True , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> assert_equal ( len ( registration . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_admin_private_reg ( self ) : <EOL> res , registration = self . request ( CITATION , <EOL> public = False , <EOL> registration = True , <EOL> is_admin = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> assert_equal ( len ( registration . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_non_admin_public_reg ( self ) : <EOL> res , registration = self . request ( CITATION , <EOL> registration = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> assert_equal ( len ( registration . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_non_admin_private_reg ( self ) : <EOL> res , registration = self . request ( CITATION , <EOL> public = False , <EOL> registration = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> assert_equal ( len ( registration . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_non_contrib_public_reg ( self ) : <EOL> res , registration = self . request ( CITATION , <EOL> registration = True , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> assert_equal ( len ( registration . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_non_contrib_private_reg ( self ) : <EOL> res , registration = self . request ( CITATION , <EOL> public = False , <EOL> registration = True , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> assert_equal ( len ( registration . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_logged_out_public_reg ( self ) : <EOL> res , registration = self . request ( CITATION , <EOL> registration = True , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> assert_equal ( len ( registration . alternative_citations ) , <NUM_LIT:0> ) <EOL> def test_add_citation_logged_out_private_reg ( self ) : <EOL> res , registration = self . request ( CITATION , <EOL> public = False , <EOL> registration = True , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> assert_equal ( len ( registration . alternative_citations ) , <NUM_LIT:0> ) <EOL> class TestGetAlternativeCitations ( ApiTestCase ) : <EOL> def request ( self , errors = False , is_admin = False , is_contrib = True , logged_out = False , ** kwargs ) : <EOL> admin = AuthUserFactory ( ) <EOL> registration = kwargs . get ( '<STR_LIT>' , None ) <EOL> if is_admin : <EOL> user = admin <EOL> elif not logged_out : <EOL> user = AuthUserFactory ( ) <EOL> kwargs [ '<STR_LIT>' ] = user if is_contrib else None <EOL> project = create_project ( admin , citation = True , ** kwargs ) <EOL> if registration : <EOL> project_url = '<STR_LIT>' . format ( API_BASE , project . _id ) <EOL> else : <EOL> project_url = '<STR_LIT>' . format ( API_BASE , project . _id ) <EOL> if not logged_out : <EOL> res = self . app . get ( project_url , auth = user . auth , expect_errors = errors ) <EOL> else : <EOL> res = self . app . get ( project_url , expect_errors = errors ) <EOL> return res <EOL> def test_get_all_citations_admin_public ( self ) : <EOL> res = self . request ( is_admin = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> data = res . json [ '<STR_LIT:data>' ] <EOL> assert_equal ( len ( data ) , <NUM_LIT:1> ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , '<STR_LIT:text>' ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> def test_get_all_citations_admin_private ( self ) : <EOL> res = self . request ( is_admin = True , <EOL> public = False ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> data = res . json [ '<STR_LIT:data>' ] <EOL> assert_equal ( len ( data ) , <NUM_LIT:1> ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , '<STR_LIT:text>' ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> def test_get_all_citations_non_admin_public ( self ) : <EOL> res = self . request ( ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> data = res . json [ '<STR_LIT:data>' ] <EOL> assert_equal ( len ( data ) , <NUM_LIT:1> ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , '<STR_LIT:text>' ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> def test_get_all_citations_non_admin_private ( self ) : <EOL> res = self . request ( public = False ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> data = res . json [ '<STR_LIT:data>' ] <EOL> assert_equal ( len ( data ) , <NUM_LIT:1> ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , '<STR_LIT:text>' ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> def test_get_all_citations_non_contrib_public ( self ) : <EOL> res = self . request ( is_contrib = False ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> data = res . json [ '<STR_LIT:data>' ] <EOL> assert_equal ( len ( data ) , <NUM_LIT:1> ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , '<STR_LIT:text>' ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> def test_get_all_citations_non_contrib_private ( self ) : <EOL> res = self . request ( public = False , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_get_all_citations_logged_out_public ( self ) : <EOL> res = self . request ( logged_out = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> data = res . json [ '<STR_LIT:data>' ] <EOL> assert_equal ( len ( data ) , <NUM_LIT:1> ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , '<STR_LIT:text>' ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> def test_get_all_citations_logged_out_private ( self ) : <EOL> res = self . request ( public = False , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_get_all_citations_admin_public_reg ( self ) : <EOL> res = self . request ( registration = True , <EOL> is_admin = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> data = res . json [ '<STR_LIT:data>' ] <EOL> assert_equal ( len ( data ) , <NUM_LIT:1> ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , '<STR_LIT:text>' ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> def test_get_all_citations_admin_private_reg ( self ) : <EOL> res = self . request ( public = False , <EOL> registration = True , <EOL> is_admin = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> data = res . json [ '<STR_LIT:data>' ] <EOL> assert_equal ( len ( data ) , <NUM_LIT:1> ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , '<STR_LIT:text>' ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> def test_get_all_citations_non_admin_public_reg ( self ) : <EOL> res = self . request ( registration = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> data = res . json [ '<STR_LIT:data>' ] <EOL> assert_equal ( len ( data ) , <NUM_LIT:1> ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , '<STR_LIT:text>' ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> def test_get_all_citations_non_admin_private_reg ( self ) : <EOL> res = self . request ( public = False , <EOL> registration = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> data = res . json [ '<STR_LIT:data>' ] <EOL> assert_equal ( len ( data ) , <NUM_LIT:1> ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , '<STR_LIT:text>' ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> def test_get_all_citations_non_contrib_public_reg ( self ) : <EOL> res = self . request ( registration = True , <EOL> is_contrib = False ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> data = res . json [ '<STR_LIT:data>' ] <EOL> assert_equal ( len ( data ) , <NUM_LIT:1> ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , '<STR_LIT:text>' ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> def test_get_all_citations_non_contrib_private_reg ( self ) : <EOL> res = self . request ( public = False , <EOL> registration = True , <EOL> is_contrib = False , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_get_all_citations_logged_out_public_reg ( self ) : <EOL> res = self . request ( registration = True , <EOL> logged_out = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> data = res . json [ '<STR_LIT:data>' ] <EOL> assert_equal ( len ( data ) , <NUM_LIT:1> ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:text>' ] , '<STR_LIT:text>' ) <EOL> assert_equal ( data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , '<STR_LIT:name>' ) <EOL> def test_get_all_citations_logged_out_private_reg ( self ) : <EOL> res = self . request ( public = False , <EOL> registration = True , <EOL> logged_out = True , <EOL> errors = True ) <EOL> assert_equal ( res . status_code , <NUM_LIT> ) <EOL> assert_equal ( len ( res . json [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> assert_equal ( res . json [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) </s>
