def test_loading(self): today = datetime.date.today() m = Metadata(today.year, today.month) m.write() self._check_entries(today.year, today.month, m) date = datetime.date(today.year, today.month, random.randint(1, lastday(today))) month_dir = os.path.join(conf['entries_dir'], date.strftime('%Y-%m')) path = os.path.join(month_dir, date.strftime('%d')) with open(path) as f: lines = f.read().split('\n') lines.pop(random.randint(0, len(lines) - 1)) with open(path, 'w') as f: f.write('\n'.join(lines)) self._check_entries(today.year, today.month, m, [date.day]) m.load_day(date.day) self._check_entries(today.year, today.month, m) m1 = Metadata(today.year, today.month) self._check_entries(today.year, today.month, m1, [date.day]) m.write() m2 = Metadata(today.year, today.month) self._check_entries(today.year, today.month, m2)
def edit_single_date(date): """Edit a single entry in external editor without initializing screen.""" date = parse_date(date) if not date: raise WLError('Unrecognised date format\n') edit_date(date) metadata = Metadata(date.year, date.month) metadata.load_day(date.day) metadata.write()