#NEWLINE# def test_choose_vhost( self ) : #NEWLINE# #INDENT# localhost_conf = set ( [ 'localhost' , '~^(www\\.)?(example|bar)\\.' ] ) #NEWLINE# server_conf = set ( [ 'somename' , 'another.alias' , 'alias' ] ) #NEWLINE# example_conf = set ( [ '.example.com' , 'example.*' ] ) #NEWLINE# foo_conf = set ( [ '*.www.foo.com' , '*.www.example.com' ] ) #NEWLINE# results = { #NEWLINE# #INDENT# 'localhost' : localhost_conf , #NEWLINE# 'alias' : server_conf , #NEWLINE# 'example.com' : example_conf , #NEWLINE# 'example.com.uk.test' : example_conf , #NEWLINE# 'www.example.com' : server_conf , #NEWLINE# 'test.www.example.com' : foo_conf , #NEWLINE# 'abc.www.foo.com' : foo_conf , #NEWLINE# 'www.bar.co.uk' : localhost_conf , #NEWLINE# #UNINDENT# } #NEWLINE# conf_path = { #NEWLINE# #INDENT# 'localhost' : 'etc_nginx/nginx.conf' , #NEWLINE# 'alias' : 'etc_nginx/nginx.conf' , #NEWLINE# 'example.com' : 'etc_nginx/sites-enabled/example.com' , #NEWLINE# 'example.com.uk.test' : 'etc_nginx/sites-enabled/example.com' , #NEWLINE# 'www.example.com' : 'etc_nginx/sites-enabled/example.com' , #NEWLINE# 'test.www.example.com' : 'etc_nginx/foo.conf' , #NEWLINE# 'abc.www.foo.com' : 'etc_nginx/foo.conf' , #NEWLINE# 'www.bar.co.uk' : 'etc_nginx/nginx.conf' , #NEWLINE# #UNINDENT# } #NEWLINE# bad_results = [ 'www.foo.com' , 'example' , 't.www.bar.co' , '69.255.225.155' ] #NEWLINE# for name in results : #NEWLINE# #INDENT# vhost = self . config . choose_vhost ( name ) #NEWLINE# path = os . path . relpath ( vhost . filep , self . temp_dir ) #NEWLINE# self . assertEqual ( results [ name ] , vhost . names ) #NEWLINE# self . assertEqual ( conf_path [ name ] , path ) #NEWLINE# #UNINDENT# for name in bad_results : #NEWLINE# #INDENT# self . assertEqual ( set ( [ name ] ) , self . config . choose_vhost ( name ) . names )