def test_show_basic_with_not_installed_packages_decorated( tester, poetry, installed): poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0")) poetry.package.add_dependency( Factory.create_dependency("pendulum", "^2.0.0")) cachy_010 = get_package("cachy", "0.1.0") cachy_010.description = "Cachy package" pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200.description = "Pendulum package" installed.add_package(cachy_010) poetry.locker.mock_lock_data({ "package": [ { "name": "cachy", "version": "0.1.0", "description": "Cachy package", "category": "main", "optional": False, "platform": "*", "python-versions": "*", "checksum": [], }, { "name": "pendulum", "version": "2.0.0", "description": "Pendulum package", "category": "main", "optional": False, "platform": "*", "python-versions": "*", "checksum": [], }, ], "metadata": { "python-versions": "*", "platform": "*", "content-hash": "123456789", "hashes": { "cachy": [], "pendulum": [] }, }, }) tester.io.set_formatter(AnsiFormatter(forced=True)) tester.execute() expected = """\ \033[36mcachy \033[0m \033[1m0.1.0\033[0m Cachy package \033[31mpendulum\033[0m \033[1m2.0.0\033[0m Pendulum package """ assert expected == tester.io.fetch_output()
def test_show_latest_decorated(app, poetry, installed, repo): command = app.find("show") tester = CommandTester(command) cachy_010 = get_package("cachy", "0.1.0") cachy_010.description = "Cachy package" cachy_020 = get_package("cachy", "0.2.0") cachy_020.description = "Cachy package" pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200.description = "Pendulum package" pendulum_201 = get_package("pendulum", "2.0.1") pendulum_201.description = "Pendulum package" installed.add_package(cachy_010) installed.add_package(pendulum_200) repo.add_package(cachy_010) repo.add_package(cachy_020) repo.add_package(pendulum_200) repo.add_package(pendulum_201) poetry.locker.mock_lock_data({ "package": [ { "name": "cachy", "version": "0.1.0", "description": "Cachy package", "category": "main", "optional": False, "platform": "*", "python-versions": "*", "checksum": [], }, { "name": "pendulum", "version": "2.0.0", "description": "Pendulum package", "category": "main", "optional": False, "platform": "*", "python-versions": "*", "checksum": [], }, ], "metadata": { "python-versions": "*", "platform": "*", "content-hash": "123456789", "hashes": { "cachy": [], "pendulum": [] }, }, }) tester.io.set_formatter(AnsiFormatter(forced=True)) tester.execute("--latest") expected = """\ \033[36mcachy \033[0m \033[1m0.1.0\033[0m \033[33m0.2.0\033[0m Cachy package \033[36mpendulum\033[0m \033[1m2.0.0\033[0m \033[31m2.0.1\033[0m Pendulum package """ assert expected == tester.io.fetch_output()
def output2(stream, sections): return SectionOutput(stream, sections, AnsiFormatter(forced=True))