def test_list_versions_from_fallback(self, mock_config_with_repo): """Test list_versions command""" username = "******" im = InventoryManager(mock_config_with_repo[0]) lb = im.create_labbook( 'unittest', 'unittest', 'labbook-unittest-01', description="From mock_config_from_repo fixture") # Create Component Manager cm = ComponentManager(lb) # Add a component cm.add_base(ENV_UNIT_TEST_REPO, ENV_UNIT_TEST_BASE, ENV_UNIT_TEST_REV) ib = ImageBuilder(lb) ib.assemble_dockerfile(write=True) client = get_docker_client() try: lb, docker_image_id = ContainerOperations.build_image( labbook=lb, username=username) # Test lookup mrg = PipPackageManager() result = mrg.search("peppercorn", lb, username) assert len(result) == 2 result = mrg.search("gigantum", lb, username) assert len(result) == 4 assert result[0] == "gigantum" # Delete image client.images.remove(docker_image_id, force=True, noprune=False) # Test lookup still works mrg = PipPackageManager() result = mrg.search("peppercorn", lb, username) assert len(result) == 2 result = mrg.search("gigantum", lb, username) assert len(result) == 4 assert result[0] == "gigantum" finally: shutil.rmtree(lb.root_dir) # Remove image if it's still there try: client.images.remove(docker_image_id, force=True, noprune=False) except: pass
def test_search(self, mock_config_with_repo, build_lb_image_for_env): """Test search command""" mrg = PipPackageManager() lb = build_lb_image_for_env[0] username = build_lb_image_for_env[1] result = mrg.search("peppercorn", lb, username) assert len(result) == 2 result = mrg.search("gigantum", lb, username) assert len(result) == 4 assert result[0] == "gigantum" assert result[3] == "gtmunit3"