Untitled
unknown
plain_text
a year ago
1.3 kB
3
Indexable
import os from pro_filer.actions.main_actions import show_details # NOQA from datetime import date def test_show_details_file_exists(tmp_path, capsys): file = tmp_path / "test.txt" with open(file, "w") as f: f.write("Hello World!") ## 12 bytes file_created = date.fromtimestamp(os.path.getctime(file)) context = {"base_path": str(file)} show_details(context) captured = capsys.readouterr().out output = f"File name: test.txt\nFile size in bytes: 12\nFile type: file\nFile extension: .txt\nLast modified date: {file_created}\n" assert captured == output def test_show_details_non_existent_extension(tmp_path, capsys): file = tmp_path / "test" with open(file, "w") as f: f.write("Hello World!") ## 12 bytes file_created = date.fromtimestamp(os.path.getctime(file)) context = {"base_path": str(file)} show_details(context) captured = capsys.readouterr().out output = f"File name: test\nFile size in bytes: 12\nFile type: file\nFile extension: [no extension]\nLast modified date: {file_created}\n" assert captured == output def test_show_details_non_existent_file(capsys): context = {"base_path": "/home/trybe/???"} show_details(context) captured = capsys.readouterr().out assert "File '???' does not exist" in captured
Editor is loading...
Leave a Comment