2011-08-09 20:40:56 +00:00
|
|
|
import argparse
|
2011-09-13 21:53:02 +00:00
|
|
|
from ..orchestra import cluster
|
2011-08-09 20:40:56 +00:00
|
|
|
|
|
|
|
from nose.tools import (
|
|
|
|
eq_ as eq,
|
2013-09-11 19:49:15 +00:00
|
|
|
assert_equal,
|
2011-08-09 20:40:56 +00:00
|
|
|
assert_raises,
|
2013-09-11 19:49:15 +00:00
|
|
|
)
|
2011-08-09 20:40:56 +00:00
|
|
|
|
|
|
|
from .. import misc
|
2013-09-11 19:49:15 +00:00
|
|
|
from ..config import config
|
2011-08-09 20:40:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FakeRemote(object):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_clients_simple():
|
|
|
|
ctx = argparse.Namespace()
|
|
|
|
remote = FakeRemote()
|
|
|
|
ctx.cluster = cluster.Cluster(
|
|
|
|
remotes=[
|
|
|
|
(remote, ['client.0', 'client.1'])
|
|
|
|
],
|
|
|
|
)
|
|
|
|
g = misc.get_clients(ctx=ctx, roles=['client.1'])
|
|
|
|
got = next(g)
|
|
|
|
eq(len(got), 2)
|
|
|
|
eq(got[0], ('1'))
|
|
|
|
assert got[1] is remote
|
|
|
|
assert_raises(StopIteration, next, g)
|
2013-09-11 19:49:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_get_http_log_path():
|
|
|
|
archive_server = "http://example.com/server_root"
|
|
|
|
config.archive_server = archive_server
|
|
|
|
archive_dir = "/var/www/archives"
|
|
|
|
|
|
|
|
path = misc.get_http_log_path(archive_dir)
|
|
|
|
assert_equal(path, "http://example.com/server_root/archives/")
|
|
|
|
|
|
|
|
job_id = '12345'
|
|
|
|
path = misc.get_http_log_path(archive_dir, job_id)
|
|
|
|
assert_equal(path, "http://example.com/server_root/archives/12345/")
|