def test_documentation(): failed_count, tests = doctest.testmod( docker_list, globs={'images': docker_list.DockerListImages(context_wrap(DOCKER_LIST_IMAGES)), 'containers': docker_list.DockerListContainers(context_wrap(DOCKER_LIST_CONTAINERS))} ) assert failed_count == 0
def test_docker_list_images_help_output(): with pytest.raises(SkipException) as ex: docker_list.DockerListImages(context_wrap(DOCKER_HELP_OUTPUT)) assert 'No data only help output.' in str(ex) with pytest.raises(SkipException) as ex: docker_list.DockerListContainers(context_wrap(DOCKER_HELP_OUTPUT)) assert 'No data only help output.' in str(ex)
def test_docker_list_containers(): result = docker_list.DockerListContainers(context_wrap(DOCKER_LIST_CONTAINERS)) assert len(result.rows) == 2 assert result.rows[0].get("CONTAINER ID") == "03e2861336a76e29155836113ff6560cb70780c32f95062642993b2b3d0fc216" assert result.rows[0].get("COMMAND") == '"/usr/sbin/httpd -DFOREGROUND"' assert result.rows[0].get("SIZE") == "796 B (virtual 669.2 MB)" assert result.rows[0].get("CREATED") == "45 seconds ago" assert result.rows[0].get("PORTS") == "0.0.0.0:8080->80/tcp" assert result.rows[1].get("CONTAINER ID") == "95516ea08b565e37e2a4bca3333af40a240c368131b77276da8dec629b7fe102" assert result.rows[1].get("COMMAND") == '"/bin/sh -c \'yum install -y vsftpd-2.2.2-6.el6\'"' assert result.rows[1]['STATUS'] == 'Exited (137) 18 hours ago' assert result.rows[1].get("PORTS") == '' assert sorted(result.data.keys()) == sorted(['angry_saha', 'tender_rosalind']) assert result.data['angry_saha'] == result.rows[0] assert result.data['tender_rosalind'] == result.rows[1]