示例#1
0
 def test_asset_credits_with(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "2f1f4fb")
     assert len(pc.assets_credits) == 1
     credit = pc.assets_credits[0]
     assert credit.asset_basenames == ["bell-ping.mp3"]
     assert credit.asset_usage == "the project"
     assert "candle damper" in credit.credit_markdown
示例#2
0
 def test_identifier_slug_without(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "ae1fea2c9f21")
     assert not pc.has_identifier_slug
     assert pc.maybe_identifier_slug is None
     with pytest.raises(TCE.InternalError,
                        match="commit .* has no identifier"):
         pc.identifier_slug
示例#3
0
 def test_whether_adds_tutorial_assets_root_commit(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "156e4b616fce")
     assert not pc.adds_tutorial_assets
示例#4
0
 def test_asset_credits_without(self, this_raw_repo, caplog):
     with caplog.at_level(logging.WARNING):
         pc = TH.ProjectCommit(this_raw_repo, "9b40818")
         assert len(pc.assets_credits) == 0
         assert "has no body" in caplog.text
示例#5
0
 def test_message_body_rejects(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "d5f7ae0")
     with pytest.raises(TCE.TutorialStructureError,
                        match="malformed commit message"):
         pc.message_body
示例#6
0
 def test_message_body(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "2f1f4fb")
     assert pc.message_body.startswith("This sound")
示例#7
0
 def test_str(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "ae1fea2")
     assert str(pc) == "<ProjectCommit: ae1fea2c9f21 BASE>"
示例#8
0
 def test_short_oid(self, this_raw_repo):
     # Construct commit from shorter-than-short oid:
     pc = TH.ProjectCommit(this_raw_repo, "ae1fea2")
     assert pc.short_oid == "ae1fea2c9f21"
示例#9
0
 def test_diff_against_parent_or_empty_root_commit(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "156e4b616fce")
     assert len(pc.diff_against_parent_or_empty) == 0
示例#10
0
 def test_diff_against_parent_or_empty(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "fd166346")
     diff = pc.diff_against_parent_or_empty
     assert len(diff) == 1
     delta = list(diff.deltas)[0]
     assert delta.status == pygit2.GIT_DELTA_MODIFIED
示例#11
0
 def test_modifies_python_code_no(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "9b4081817626")
     assert not pc.modifies_python_code
示例#12
0
 def test_modifies_python_code_yes(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "e41e02c9be03")
     assert pc.modifies_python_code
示例#13
0
 def test_modifies_tutorial_text_no(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "e41e02c9be03")
     assert not pc.modifies_tutorial_text
示例#14
0
 def test_modifies_tutorial_text_yes(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "e1655214c662")
     assert pc.modifies_tutorial_text
示例#15
0
 def test_whether_adds_tutorial_assets_error(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "6b71bac9f1c1")
     with pytest.raises(TCE.TutorialStructureError,
                        match="tutorial assets but also has"):
         pc.adds_tutorial_assets
示例#16
0
 def test_text_file_contents(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "fd16634610de")
     assert pc.text_file_contents("boing/code.py") == "import pytch\n"
示例#17
0
 def test_text_file_contents_missing(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "fd16634610de")
     with pytest.raises(TCE.TutorialStructureError,
                        match="file .* not found"):
         assert pc.text_file_contents("boing/no-such-file.txt")
示例#18
0
 def test_sole_modify_against_parent(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "e41e02c9be03")
     assert pc.sole_modify_against_parent.old_file.path == "boing/code.py"
示例#19
0
 def test_summary_label(self, this_raw_repo, oid, exp_summary):
     pc = TH.ProjectCommit(this_raw_repo, oid)
     assert pc.summary_label == exp_summary
示例#20
0
 def test_sole_modify_against_parent_not_sole(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "c2642880a6fc")
     with pytest.raises(TCE.TutorialStructureError,
                        match="not have exactly one"):
         pc.sole_modify_against_parent
示例#21
0
 def test_message_subject(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "ae1fea2c9f21")
     assert pc.message_subject == "{base} Add empty code file"
示例#22
0
 def test_sole_modify_against_parent_not_modified(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "ae1fea2")
     with pytest.raises(TCE.TutorialStructureError,
                        match="not of type MODIFIED"):
         pc.sole_modify_against_parent
示例#23
0
 def test_message_body_empty(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "9b40818")
     assert pc.message_body == ""
示例#24
0
 def test_added_assets_one_asset(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "9b40818176")
     got_assets = pc.added_assets
     assert len(got_assets) == 1
     assert got_assets[0].path == "boing/project-assets/graphics/alien.png"
     assert got_assets[0].data == b"This is not a real PNG file!"
示例#25
0
 def test_added_assets_no_assets(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "fd166346")
     assert pc.added_assets == []
示例#26
0
 def test_code_patch(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "e41e02c9be")
     patch = pc.code_patch_against_parent
     context, n_adds, n_dels = patch.line_stats
     assert n_adds == 4
     assert n_dels == 0
示例#27
0
 def test_identifier_slug_with(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "e41e02c9be")
     assert pc.has_identifier_slug
     assert pc.maybe_identifier_slug == "add-Alien-skeleton"
     assert pc.identifier_slug == "add-Alien-skeleton"
示例#28
0
 def test_code_patch_error(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "9b40818176")
     with pytest.raises(TCE.TutorialStructureError,
                        match="does not modify the Python code"):
         pc.code_patch_against_parent
示例#29
0
 def test_base_detection_yes(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "ae1fea2c9f21")
     assert pc.is_base
示例#30
0
 def test_whether_adds_tutorial_assets_no(self, this_raw_repo):
     pc = TH.ProjectCommit(this_raw_repo, "e41e02c9be03")
     assert not pc.adds_tutorial_assets