<s> import sys <EOL> from os . path import dirname , join <EOL> SRC_DIR = join ( dirname ( __file__ ) , '<STR_LIT>' ) <EOL> sys . path . append ( SRC_DIR ) <EOL> from unittest import TestCase <EOL> from expedient . common . tests . commands import call_env_command , Env <EOL> from openflow . tests import test_settings <EOL> from expedient . common . tests . utils import wrap_xmlrpc_call <EOL> import xmlrpclib <EOL> import random <EOL> from pprint import pprint <EOL> import logging <EOL> logger = logging . getLogger ( "<STR_LIT>" ) <EOL> SCHEME = "<STR_LIT>" if test_settings . USE_HTTPS else "<STR_LIT:http>" <EOL> class ManualTests ( TestCase ) : <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> call_env_command ( test_settings . OM_PROJECT_DIR , "<STR_LIT>" , <EOL> interactive = False ) <EOL> self . om_env = Env ( test_settings . OM_PROJECT_DIR ) <EOL> self . om_env . switch_to ( ) <EOL> from openflow . optin_manager . dummyfv . models import DummyFV <EOL> from openflow . optin_manager . xmlrpc_server . models import FVServerProxy <EOL> from openflow . optin_manager . users . models import UserProfile <EOL> from django . contrib . auth . models import User <EOL> username = "<STR_LIT>" <EOL> password = "<STR_LIT:password>" <EOL> u = User . objects . create ( username = username ) <EOL> u . set_password ( password ) <EOL> u . save ( ) <EOL> profile = UserProfile . get_or_create_profile ( u ) <EOL> profile . is_clearinghouse_user = True <EOL> profile . save ( ) <EOL> self . om_client = xmlrpclib . ServerProxy ( <EOL> SCHEME + "<STR_LIT>" % ( <EOL> username , password , test_settings . HOST , test_settings . OM_PORT <EOL> ) <EOL> ) <EOL> username = "<STR_LIT>" <EOL> password = "<STR_LIT:password>" <EOL> u = User . objects . create ( username = username , is_superuser = True , <EOL> is_staff = True , is_active = True ) <EOL> u . set_password ( password ) <EOL> u . save ( ) <EOL> profile = UserProfile . get_or_create_profile ( u ) <EOL> profile . is_net_admin = True <EOL> profile . supervisor = u <EOL> profile . max_priority_level = <NUM_LIT> <EOL> profile . save ( ) <EOL> for i in range ( test_settings . NUM_DUMMY_FVS ) : <EOL> fv = DummyFV . objects . create ( ) <EOL> fv . populateTopology ( <NUM_LIT:10> , <NUM_LIT:20> , use_random = test_settings . USE_RANDOM ) <EOL> username = "<STR_LIT>" % i <EOL> password = "<STR_LIT:password>" <EOL> u = User . objects . create ( username = username ) <EOL> u . set_password ( password ) <EOL> u . save ( ) <EOL> FVServerProxy . objects . create ( <EOL> name = "<STR_LIT>" % i , <EOL> username = username , <EOL> password = password , <EOL> url = SCHEME + "<STR_LIT>" % ( <EOL> test_settings . HOST , test_settings . OM_PORT , fv . id , <EOL> ) , <EOL> ) <EOL> def test_case1 ( self ) : <EOL> from django . contrib . auth . models import User <EOL> from openflow . optin_manager . opts . models import UserFlowSpace , Experiment , ExperimentFLowSpace <EOL> username = "<STR_LIT:user>" <EOL> password = "<STR_LIT:password>" <EOL> u = User . objects . create ( username = username , is_active = True ) <EOL> u . set_password ( password ) <EOL> u . save ( ) <EOL> self . user_ip_src_s = random . randint ( <NUM_LIT:0> , <NUM_LIT> ) & <NUM_LIT> <EOL> self . user_ip_src_e = random . randint ( <NUM_LIT> , <NUM_LIT> ) & <NUM_LIT> <EOL> adm = User . objects . get ( username = "<STR_LIT>" ) <EOL> ufs = UserFlowSpace ( user = u , ip_src_s = self . user_ip_src_s , <EOL> ip_src_e = self . user_ip_src_e , approver = adm ) <EOL> ufs . save ( ) <EOL> Experiment . objects . all ( ) . delete ( ) <EOL> ExperimentFLowSpace . objects . all ( ) . delete ( ) <EOL> exp = Experiment . objects . create ( slice_id = "<STR_LIT>" , project_name = "<STR_LIT>" , <EOL> project_desc = "<STR_LIT>" , slice_name = "<STR_LIT>" , <EOL> slice_desc = "<STR_LIT>" , controller_url = "<STR_LIT>" , <EOL> owner_email = "<STR_LIT>" , owner_password = "<STR_LIT>" ) <EOL> expfs = ExperimentFLowSpace . objects . create ( exp = exp , dpid = "<STR_LIT>" , <EOL> ip_src_s = <NUM_LIT> , <EOL> ip_src_e = <NUM_LIT> , <EOL> ) <EOL> exp = Experiment . objects . create ( slice_id = "<STR_LIT>" , project_name = "<STR_LIT>" , <EOL> project_desc = "<STR_LIT>" , slice_name = "<STR_LIT>" , <EOL> slice_desc = "<STR_LIT>" , controller_url = "<STR_LIT>" , <EOL> owner_email = "<STR_LIT>" , owner_password = "<STR_LIT>" ) <EOL> expfs = ExperimentFLowSpace . objects . create ( exp = exp , dpid = "<STR_LIT>" , <EOL> ip_src_s = <NUM_LIT> , <EOL> ip_src_e = <NUM_LIT> , <EOL> ) <EOL> exp = Experiment . objects . create ( slice_id = "<STR_LIT>" , project_name = "<STR_LIT>" , <EOL> project_desc = "<STR_LIT>" , slice_name = "<STR_LIT>" , <EOL> slice_desc = "<STR_LIT>" , controller_url = "<STR_LIT>" , <EOL> owner_email = "<STR_LIT>" , owner_password = "<STR_LIT>" ) <EOL> expfs = ExperimentFLowSpace . objects . create ( exp = exp , dpid = "<STR_LIT>" , <EOL> ip_src_s = <NUM_LIT> , <EOL> ip_src_e = <NUM_LIT> , <EOL> ) <EOL> def test_case2 ( self ) : <EOL> from django . contrib . auth . models import User <EOL> from openflow . optin_manager . opts . models import UserFlowSpace , Experiment , ExperimentFLowSpace <EOL> username = "<STR_LIT:user>" <EOL> password = "<STR_LIT:password>" <EOL> u = User . objects . create ( username = username , is_active = True ) <EOL> u . set_password ( password ) <EOL> u . save ( ) <EOL> adm = User . objects . get ( username = "<STR_LIT>" ) <EOL> username = "<STR_LIT>" <EOL> password = "<STR_LIT:password>" <EOL> u = User . objects . create ( username = username , is_active = True ) <EOL> u . set_password ( password ) <EOL> u . save ( ) <EOL> Experiment . objects . all ( ) . delete ( ) <EOL> ExperimentFLowSpace . objects . all ( ) . delete ( ) <EOL> exp = Experiment . objects . create ( slice_id = "<STR_LIT>" , project_name = "<STR_LIT>" , <EOL> project_desc = "<STR_LIT>" , slice_name = "<STR_LIT>" , <EOL> slice_desc = "<STR_LIT>" , controller_url = "<STR_LIT>" , <EOL> owner_email = "<STR_LIT>" , owner_password = "<STR_LIT>" ) <EOL> expfs = ExperimentFLowSpace . objects . create ( exp = exp , dpid = "<STR_LIT>" , <EOL> ip_src_s = <NUM_LIT> , <EOL> ip_src_e = <NUM_LIT> , <EOL> ) <EOL> exp = Experiment . objects . create ( slice_id = "<STR_LIT>" , project_name = "<STR_LIT>" , <EOL> project_desc = "<STR_LIT>" , slice_name = "<STR_LIT>" , <EOL> slice_desc = "<STR_LIT>" , controller_url = "<STR_LIT>" , <EOL> owner_email = "<STR_LIT>" , owner_password = "<STR_LIT>" ) <EOL> expfs = ExperimentFLowSpace . objects . create ( exp = exp , dpid = "<STR_LIT>" , <EOL> ip_src_s = <NUM_LIT> , <EOL> ip_src_e = <NUM_LIT> , <EOL> ) <EOL> exp = Experiment . objects . create ( slice_id = "<STR_LIT>" , project_name = "<STR_LIT>" , <EOL> project_desc = "<STR_LIT>" , slice_name = "<STR_LIT>" , <EOL> slice_desc = "<STR_LIT>" , controller_url = "<STR_LIT>" , <EOL> owner_email = "<STR_LIT>" , owner_password = "<STR_LIT>" ) <EOL> expfs = ExperimentFLowSpace . objects . create ( exp = exp , dpid = "<STR_LIT>" , <EOL> ip_src_s = <NUM_LIT> , <EOL> ip_src_e = <NUM_LIT> , <EOL> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import unittest <EOL> unittest . main ( ) </s>
