def test_logdir(funcname): """Verify that a default logdir is set and filenames are based on the agent's name. """ func = getattr(agent, funcname) # enables SIPp logging by default ua = agent.Scenario([func()]).prepare()[0] check_log_files(ua, tempfile.gettempdir())
def test_scenario(): uas, uac = agent.server(), agent.client() agents = [uas, uac] scen = agent.Scenario(agents) scen2 = agent.Scenario(agents) # verify contained agents assert list(scen.agents.values()) == agents == scen._agents assert scen.prepare() != agents # new copies # verify order agents = list(scen.agents.values()) assert uas is agents[0] assert uac is agents[1] # verify servers assert uas is list(scen.servers.values())[0] # verify clients assert uac is list(scen.clients.values())[0] # ensure defaults attr setting works doggy = "doggy" scen.local_host = doggy uas, uac = scen.prepare() assert uac.local_host == uas.local_host == doggy # should be no shared state between instances assert scen2.local_host != doggy scen2.local_host = 10 assert scen.local_host == doggy # same error for any non-spec defined agent attr with pytest.raises(AttributeError): scen.agentdefaults.local_man = "flasher" scen.prepare() # defaults on servers only scen.serverdefaults.uri_username = doggy uas, uac = scen.prepare() assert uas.uri_username == doggy assert uac.uri_username != doggy assert scen.name == "uas_uac"
def ua(): return agent.Scenario([agent.ua()]).prepare()[0]