def test_agent(): """Tests for method agent""" client = CBWApi(API_URL, API_KEY, SECRET_KEY) with vcr.use_cassette('spec/fixtures/vcr_cassettes/agent.yaml'): response = client.agent('4') assert isinstance(response, CBWAgent) is True with vcr.use_cassette( 'spec/fixtures/vcr_cassettes/agent_wrong_id.yaml'): response = client.agent('wrong_id') assert isinstance(response, CBWAgent) is False
def test_agent(): """Tests for method agent""" client = CBWApi(API_URL, API_KEY, SECRET_KEY) with vcr.use_cassette('spec/fixtures/vcr_cassettes/agent.yaml'): response = client.agent('4') assert str(response) == "cbw_object(id=4, server_id=3, node_id=1, \ version=None, remote_ip=None, last_communication=None)" with vcr.use_cassette( 'spec/fixtures/vcr_cassettes/agent_wrong_id.yaml'): response = client.agent('wrong_id') assert response is None
def test_agent(): """Tests for method agent""" client = CBWApi(API_URL, API_KEY, SECRET_KEY) with vcr.use_cassette('spec/fixtures/vcr_cassettes/agent.yaml'): response = client.agent('2') assert str( response ) == "cbw_object(id=2, server_id=15, node_id=1, version='4.2', remote_ip='10.10.1.103', \ last_communication='2021-02-22T10:41:01.000+01:00')" with vcr.use_cassette( 'spec/fixtures/vcr_cassettes/agent_wrong_id.yaml'): response = client.agent('wrong_id') assert response is None
"""Get agent by agent_id""" import os from configparser import ConfigParser from cbw_api_toolbox.cbw_api import CBWApi CONF = ConfigParser() CONF.read( os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', 'api.conf')) CLIENT = CBWApi(CONF.get('cyberwatch', 'url'), CONF.get('cyberwatch', 'api_key'), CONF.get('cyberwatch', 'secret_key')) AGENT_ID = '7' CLIENT.agent(AGENT_ID)