def test_configure_nginx_simple(): with temp_dir() as temp: conf_path = join(temp, "nginx.conf") ud = {"nginx_conf_contents": encodestring(TEST_NGINX_CONF), "nginx_conf_path": conf_path} _configure_nginx(test_logger(), ud) assert open(conf_path, "r").read() == TEST_NGINX_CONF
def test_install_authorized_keys_append(): with temp_dir() as temp: ssh_dir = join(temp, ".ssh") makedirs(ssh_dir, mode=0700) authorized_keys_file = join(ssh_dir, "authorized_keys") key2 = "ssh-rss ABCD [email protected]" open(authorized_keys_file, "w").write("%s\n" % key2) _install_authorized_keys(test_logger(), KEYS_USERDATA, manager=TestAuthorizedKeysManager(temp)) _check_key_installed(temp, KEY1) _check_key_installed(temp, key2)
def test_reconfigure_nginx_disabled(): with temp_dir() as temp: conf_path = join(temp, "nginx.conf") ud = {"nginx_conf_contents": encodestring(TEST_NGINX_CONF), "nginx_conf_path": conf_path, "configure_multiple_galaxy_processes": True, "reconfigure_nginx": False, "web_thread_count": 2} _configure_nginx(test_logger(), ud) rewritten_contents = open(conf_path, "r").read() assert rewritten_contents == TEST_NGINX_CONF
def test_get_file_from_bucket(): mock_s3_conn = S3ConnMock() mock_s3_conn.responses.append(MockResponse("Test Contents")) mock_bucket = BucketMock("bucket_test", mock_s3_conn) mock_bucket.files["remote_file"] = "moocow" temp = NamedTemporaryFile().name assert not exists(temp) _get_file_from_bucket(test_logger(), mock_s3_conn, "bucket_test", "remote_file", temp) assert exists(temp) assert open(temp, "r").read() == "Test Contents"
def test_configure_nginx_simple_multi_web_threads(): with temp_dir() as temp: conf_path = join(temp, "nginx.conf") ud = {"nginx_conf_contents": encodestring(TEST_NGINX_CONF), "nginx_conf_path": conf_path, "configure_multiple_galaxy_processes": True, "web_thread_count": 2} _configure_nginx(test_logger(), ud) rewritten_contents = open(conf_path, "r").read() # Check exactly two web threads configured in nginx.conf. assert rewritten_contents.find("server localhost:8080;") >= 0 assert rewritten_contents.find("server localhost:8081;") >= 0 assert rewritten_contents.find("server localhost:8082;") == -1
def test_install_conf_files(): with temp_dir() as temp: ud = {"conf_files": [{"path": join(temp, "test1"), "content": encodestring("Hello World!")}]} _install_conf_files(test_logger(), ud) assert open(join(temp, "test1"), "r").read() == "Hello World!"
def test_install_authorized_keys_fresh(): with temp_dir() as temp: _install_authorized_keys(test_logger(), KEYS_USERDATA, manager=TestAuthorizedKeysManager(temp)) _check_key_installed(temp, KEY1)
def test_is_running(): # If this test is executing, there must be a python process. assert _is_running(test_logger(), "python") # Highly unlikely there is a process called flork78 on this system. assert not _is_running(test_logger(), "flork78")
def test_make_dir(): temp = NamedTemporaryFile().name assert not exists(temp) _make_dir(test_logger(), temp) assert exists(temp)