def test_bob_can_update_from_scratch(tmpdir): # Bob wants to setup the weekly update script but gets confused by all # of the test helper magic. He wants to update from scratch current_dir = getcwd() source_dir = join(current_dir, "tests", "fixtures") source = "basic_list.md" checked_out = tmpdir.join("target_checked.md") unchecked_out = tmpdir.join("target_unchecked.md") assert isinstance(checked_out, py.path.local) wu = WeeklyUpdate(source_dir, source, checked_out, unchecked_out) # now he check his output assert not wu.checked_target.check(exists=1) assert not wu.unchecked_target.check(exists=1) wu.wrap_up_week() # and checks for the new file assert wu.checked_target.check(exists=1) assert wu.unchecked_target.check(exists=1) # and that it contains 3 lines text = wu.checked_target.read() lines = text.split("\n") assert len(lines) == 3 # and that the lines contain the correct text for line in lines: assert line[:5].upper() == "- [X]" assert line[6:].upper().strip() == "CHECKED" # and that the checked items are removed from the original file text = wu.unchecked_target.read() assert "Checked" not in text
from os import getcwd from py import path from datetime import date import py from pg_tools.weekly_update import WeeklyUpdate from pg_tools.goals import Goals # Charlie wants an eaiser way that makes some assumptions. current_dir = getcwd() source = "README.md" local = py.path.local(current_dir) checked_out = local.join("README.md.checked") unchecked_out = local.join("README.md.new") day = date.today() accom_file = day.strftime("%Y-%m-%d") accom_file = "{0}.md".format(accom_file) accom_out = local.join("accomplishments", accom_file) wu = WeeklyUpdate(current_dir, source, accom_out, unchecked_out) wu.wrap_up_week() # Now let's move stuff to where it goes unchecked_out.move(local.join(source))