<s> from flask import session <EOL> from labmanager . tests . util import G4lTestCase , BaseTestLogin <EOL> from flask . ext . testing import TestCase <EOL> from labmanager . models import LtUser , LearningTool <EOL> from labmanager . db import db <EOL> class testRegisterGraasp ( BaseTestLogin , G4lTestCase ) : <EOL> path = '<STR_LIT>' <EOL> login_path = '<STR_LIT>' <EOL> logout_path = '<STR_LIT>' <EOL> lt_name = '<STR_LIT>' <EOL> """<STR_LIT>""" <EOL> lt_value = <NUM_LIT:6> <EOL> def register_in_graasp ( self ) : <EOL> rv = self . client . post ( self . path , data = dict <EOL> ( <EOL> full_name = '<STR_LIT>' , <EOL> short_name = '<STR_LIT>' , <EOL> url = '<STR_LIT>' , <EOL> user_full_name = '<STR_LIT>' , <EOL> user_login = '<STR_LIT>' , <EOL> user_password = '<STR_LIT:password>' <EOL> ) , <EOL> follow_redirects = True ) <EOL> self . assert_200 ( rv ) <EOL> lt = db . session . query ( LearningTool ) . filter_by ( full_name = '<STR_LIT>' ) . first ( ) <EOL> query = db . session . query ( LtUser ) . filter_by ( login = '<STR_LIT>' , lt = lt ) . first ( ) <EOL> self . assertTrue ( query is not None , <EOL> "<STR_LIT>" ) <EOL> rv = self . login ( username = '<STR_LIT>' , password = '<STR_LIT:password>' ) <EOL> self . assert_200 ( rv ) <EOL> self . assertEquals ( '<STR_LIT>' , session [ '<STR_LIT>' ] ) <EOL> self . assertEquals ( '<STR_LIT>' , session [ '<STR_LIT>' ] ) <EOL> def test_route_register_graasp_work ( self ) : <EOL> rv = self . client . get ( self . path ) <EOL> self . assert_200 ( rv ) <EOL> def test_register_work ( self ) : <EOL> self . register_in_graasp ( ) <EOL> def test_register_name_duplicate ( self ) : <EOL> self . register_in_graasp ( ) <EOL> rv = self . client . post ( self . path , data = dict <EOL> ( <EOL> full_name = '<STR_LIT>' , <EOL> short_name = '<STR_LIT>' , <EOL> url = '<STR_LIT>' , <EOL> user_full_name = '<STR_LIT>' , <EOL> user_login = '<STR_LIT>' , <EOL> user_password = '<STR_LIT:password>' <EOL> ) , <EOL> follow_redirects = True ) <EOL> lt = db . session . query ( LearningTool ) . filter_by ( full_name = '<STR_LIT>' , name = '<STR_LIT>' ) . first ( ) <EOL> query = db . session . query ( LtUser ) . filter_by ( login = '<STR_LIT>' , lt = lt ) . first ( ) <EOL> self . assertTrue ( query is None , "<STR_LIT>" ) <EOL> self . assert_200 ( rv ) <EOL> self . assertNotEqual ( rv . location , "<STR_LIT>" + self . path ) <EOL> def test_register_full_name_duplicate ( self ) : <EOL> self . register_in_graasp ( ) <EOL> rv = self . client . post ( self . path , data = dict <EOL> ( <EOL> full_name = '<STR_LIT>' , <EOL> short_name = '<STR_LIT>' , <EOL> url = '<STR_LIT>' , <EOL> user_full_name = '<STR_LIT>' , <EOL> user_login = '<STR_LIT>' , <EOL> user_password = '<STR_LIT:password>' <EOL> ) , <EOL> follow_redirects = True ) <EOL> lt = db . session . query ( LearningTool ) . filter_by ( full_name = '<STR_LIT>' , name = '<STR_LIT>' ) . first ( ) <EOL> query = db . session . query ( LtUser ) . filter_by ( login = '<STR_LIT>' , lt = lt ) . first ( ) <EOL> self . assertTrue ( query is None , "<STR_LIT>" ) <EOL> self . assert_200 ( rv ) <EOL> self . assertNotEqual ( rv . location , "<STR_LIT>" + self . path ) </s>
