project-spec 0.8.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -612,6 +612,48 @@ class GapLayerTests(Fixture):
612
612
  self.assertEqual((status, data['files']['source.txt']['text']), (0, 'evidence'))
613
613
  self.assertIn('the text of 1 cited source files is inside the file', printed)
614
614
 
615
+ def test_build_can_run_where_part_of_the_repository_is_missing(self):
616
+ self.note('notes/m.md', 'm', sources=['source.txt', 'Dockerfile'])
617
+ status, _, err, data = self.built()
618
+ self.assertEqual((status, data), (1, None))
619
+ self.assertIn('source is missing or not a file', err)
620
+ status, printed, err, data = self.built('--allow-missing-sources')
621
+ self.assertEqual(status, 0)
622
+ self.assertIn('build: 1 cited files are not in this folder, so nobody compared them with the pages: Dockerfile', printed)
623
+ self.assertNotIn('Dockerfile', err)
624
+ self.note('notes/o.md', 'o', sources=['Dockerfile'])
625
+ data = self.built('--allow-missing-sources')[3]
626
+ pages = {n['id']: (n['sources'], n['stale']) for n in data['nodes']}
627
+ self.assertEqual(pages['o'], (['Dockerfile'], False), 'a file nobody could read does not mark its page as changed')
628
+ self.assertEqual(pages['m'], (['source.txt', 'Dockerfile'], True), 'source.txt has no accepted fingerprint')
629
+ (self.vault / 'notes/o.md').unlink()
630
+ # a folder where a file should be is still an error, and so is the same vault for check
631
+ (self.repo / 'Dockerfile').mkdir()
632
+ self.assertEqual(self.built('--allow-missing-sources')[0], 1)
633
+ (self.repo / 'Dockerfile').rmdir()
634
+ self.assertEqual(self.run_cli('check')[0], 1)
635
+ self.assertIn('only for build', self.refused('check', '--allow-missing-sources'))
636
+
637
+ def test_build_and_serve_work_where_git_is_not_installed(self):
638
+ import os
639
+ from unittest import mock
640
+ k._history_cache.clear()
641
+ self.vault.rename(self.repo / 'vault')
642
+ self.vault = self.repo / 'vault'
643
+ self.git('init', '-q')
644
+ self.git('add', '-A')
645
+ self.git('commit', '-q', '-m', 'First')
646
+ empty = self.root / 'no-tools'
647
+ empty.mkdir()
648
+ with mock.patch.dict(os.environ, {'PATH': str(empty)}):
649
+ status, printed, err, data = self.built()
650
+ self.assertEqual((status, data['commit'], data['history'], data['pending']), (0, '', [], []), err)
651
+ self.assertNotIn('commit ', printed)
652
+ self.assertIn('knowledge-data', k.live_page(self.repo.resolve(), self.vault.resolve()))
653
+ self.assertIn('--ignore-dirty needs --repo to be a Git work tree', self.refused('check', '--ignore-dirty'))
654
+ k._history_cache.clear()
655
+ self.assertEqual([c['subject'] for c in self.built()[3]['history']], ['First'], 'with Git back, the history is too')
656
+
615
657
  def test_build_links_cited_files_to_the_commit_it_was_built_from(self):
616
658
  k._history_cache.clear()
617
659
  self.vault.rename(self.repo / 'vault')
@@ -683,6 +725,39 @@ class GapLayerTests(Fixture):
683
725
  self.assertEqual(k.main(['check', '--repo', str(self.repo)]), 0)
684
726
  self.assertIn('check: 1 notes', out.getvalue())
685
727
 
728
+ def test_a_feature_too_big_for_one_page_has_parts(self):
729
+ self.note('notes/chats.md', 'chats', sources=['source.txt'], body='Parts: [[notes/group-chats|group chats]].')
730
+ self.note('notes/group-chats.md', 'group-chats', sources=['source.txt'], parent='chats')
731
+ status, out, err = self.run_cli('check')
732
+ self.assertEqual(status, 0, err)
733
+ notes, edges, errors, _, _ = k.load_vault(self.repo.resolve(), self.vault.resolve())
734
+ self.assertIn(('chats', 'group-chats'), edges)
735
+ self.assertEqual(k.node_of(next(n for n in notes if n['meta']['id'] == 'group-chats'))['parent'], 'chats')
736
+ cases = (
737
+ (dict(parent='chats'), 'Parts: none listed.', 'notes/group-chats.md: its feature notes/chats.md does not link to it'),
738
+ (dict(parent='nobody'), None, 'parent nobody is not the id of an existing note'),
739
+ (dict(parent='a'), None, 'parent a is not the id of an existing note'),
740
+ (dict(parent='group-chats'), None, 'parent must name a different note'),
741
+ (dict(parent=''), None, 'parent is only valid on note pages and names the feature note'),
742
+ )
743
+ for extra, parent_body, message in cases:
744
+ with self.subTest(message=message):
745
+ self.note('notes/chats.md', 'chats', sources=['source.txt'], body=parent_body or 'Parts: [[notes/group-chats|group chats]].')
746
+ self.note('notes/group-chats.md', 'group-chats', sources=['source.txt'], **extra)
747
+ status, _, err = self.run_cli('check')
748
+ self.assertEqual(status, 1)
749
+ self.assertIn(message, err)
750
+ # three levels and no more, and a part stays in its feature's area
751
+ self.note('notes/chats.md', 'chats', sources=['source.txt'], body='[[notes/group-chats|group chats]] [[notes/renaming|renaming]]')
752
+ self.note('notes/group-chats.md', 'group-chats', sources=['source.txt'], parent='chats', body='[[notes/renaming|renaming]]')
753
+ self.note('notes/renaming.md', 'renaming', sources=['source.txt'], parent='group-chats')
754
+ self.assertIn('parent group-chats is itself a part of chats; a part belongs to a feature, not to another part', self.run_cli('check')[2])
755
+ self.note('areas/b.md', 'b', 'area', areas=[])
756
+ self.note('notes/renaming.md', 'renaming', sources=['source.txt'], parent='chats', areas=['b'])
757
+ self.assertIn('parent chats is in another area', self.run_cli('check')[2])
758
+ self.note('areas/a.md', 'a', 'area', areas=[], parent='chats')
759
+ self.assertIn('parent is only valid on note pages', self.run_cli('check')[2])
760
+
686
761
  def test_area_pages_are_maps_without_tables_or_links_into_notes(self):
687
762
  table = '| Screen | What it does |\n| --- | --- |\n| Profile | Edits the name. [[notes/n|Profile]] |\n'
688
763
  for body in (table, '| a | b |\n|:-|-:|\n| 1 | 2 |', 'a | b\n--- | ---\n1 | 2', '| one column |\n| --- |\n| x |'):
@@ -27,7 +27,7 @@ A gap must not have `status`; its progress is carried by `recheck` and `decision
27
27
  | `decided_by` | when `decision` is `accepted`, `rejected` or `deferred` | a person's name; the value `agent` is an error |
28
28
  | `decided_on` | when `decision` is `accepted`, `rejected` or `deferred` | `YYYY-MM-DD` |
29
29
  | `duplicate_of` | when `decision` is `duplicate` | id of another existing gap (not itself) |
30
- | `priority`, `confidence` | optional, gap and plan pages only | short strings, e.g. `"high"` |
30
+ | `priority`, `confidence` | optional, gap and plan pages only | short strings, e.g. `"high"`. Use `high`, `medium` or `low` for `priority` (or `P0` to `P4`): the viewer lists the most urgent gap of each state first and can show one priority only. |
31
31
 
32
32
  `decided_by` and `decided_on` are also allowed on `done` and `duplicate` but not required. With `outdated`, `rechecked_by` and `rechecked_on` stay in place as the record of the last recheck actually done. A fresh recheck replaces all three fields and adds a new dated entry to the `Recheck` section; keep the older entries.
33
33