Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_modification_status():
gr = GitRepository('test-repos/git-1/')
commit = gr.get_commit('866e997a9e44cb4ddd9e00efe49361420aff2559')
assert commit.modifications[0].change_type == ModificationType.ADD
assert commit.modifications[0].old_path is None
commit = gr.get_commit('57dbd017d1a744b949e7ca0b1c1a3b3dd4c1cbc1')
assert commit.modifications[0].change_type == ModificationType.MODIFY
assert commit.modifications[0].new_path == commit.modifications[0].old_path
commit = gr.get_commit('ffccf1e7497eb8136fd66ed5e42bef29677c4b71')
assert commit.modifications[0].change_type == ModificationType.DELETE
assert commit.modifications[0].new_path is None
def test_metrics_not_supported_file():
sc = 'asd !&%@*&^@\n jjdkj'
diff_and_sc = {
'diff': '',
'source_code': sc,
'source_code_before': sc
}
m1 = Modification('test-repos/test6/NotSupported.pdf',
"test-repos/test6/NotSupported.pdf",
ModificationType.MODIFY, diff_and_sc)
assert m1.nloc == 2
assert len(m1.methods) == 0
def _from_change_to_modification_type(diff: Diff):
if diff.new_file:
return ModificationType.ADD
if diff.deleted_file:
return ModificationType.DELETE
if diff.renamed_file:
return ModificationType.RENAME
if diff.a_blob and diff.b_blob and diff.a_blob != diff.b_blob:
return ModificationType.MODIFY
return ModificationType.UNKNOWN