Exemplo n.º 1
0
def test_list_hosts(monkeypatch, sample_host, output_fmt):
    evg_api_mock = _create_api_mock(monkeypatch)
    evg_api_mock.all_hosts.return_value = [Host(sample_host, None)]

    runner = CliRunner()
    cmd_list = [output_fmt, 'list-hosts'] if output_fmt else ['list-hosts']
    result = runner.invoke(under_test.cli, cmd_list)
    assert result.exit_code == 0
    assert sample_host['host_id'] in result.output
Exemplo n.º 2
0
    def all_hosts(self, status=None):
        """
        Get all hosts in evergreen.

        :param status: Only return hosts with specified status.
        :return: List of all hosts in evergreen.
        """
        params = {}
        if status:
            params['status'] = status

        url = self._create_url('/hosts')
        host_list = self._paginate(url, params)
        return [Host(host, self) for host in host_list]
Exemplo n.º 3
0
    def all_hosts(self, status: Optional[str] = None) -> List[Host]:
        """
        Get all hosts in evergreen.

        :param status: Only return hosts with specified status.
        :return: List of all hosts in evergreen.
        """
        params = {}
        if status:
            params["status"] = status

        url = self._create_url("/hosts")
        host_list = self._paginate(url, params)
        return [Host(host, self) for host in host_list]  # type: ignore[arg-type]
Exemplo n.º 4
0
 def test_missing_values(self, sample_host):
     del sample_host['status']
     host = Host(sample_host, None)
     assert not host.status
Exemplo n.º 5
0
 def test_get_version(self, sample_host):
     mock_api = MagicMock()
     host = Host(sample_host, mock_api)
     assert mock_api.version_by_id.return_value == host.get_version()
Exemplo n.º 6
0
 def test_get_build(self, sample_host):
     mock_api = MagicMock()
     host = Host(sample_host, mock_api)
     assert mock_api.build_by_id.return_value == host.get_build()
Exemplo n.º 7
0
 def test_running_task(self, sample_host):
     host = Host(sample_host, None)
     running_task = host.running_task
     assert running_task.task_id == sample_host['running_task']['task_id']
     assert isinstance(running_task.dispatch_time, datetime)
Exemplo n.º 8
0
 def test_get_attributes(self, sample_host):
     host = Host(sample_host, None)
     assert host.status == sample_host['status']
     assert host.host_id == sample_host['host_id']