Coverage for tests/test_angular_style.py: 100.00%

36 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-02 00:26 +0200

1"""Tests for the Angular conventionntion.""" 

2 

3from __future__ import annotations 

4 

5from git_changelog.commit import AngularConvention, Commit 

6 

7 

8def test_angular_convention_breaking_change() -> None: 

9 """Breaking change (singular) is correctly identified.""" 

10 subject = "feat: this is a new breaking feature" 

11 body = ["BREAKING CHANGE: there is a breaking feature in this code"] 

12 commit = Commit( 

13 commit_hash="aaaaaaa", 

14 subject=subject, 

15 body=body, 

16 author_date="1574340645", 

17 committer_date="1574340645", 

18 ) 

19 convention = AngularConvention() 

20 commit_dict = convention.parse_commit(commit) 

21 assert commit_dict["is_major"] 

22 assert not commit_dict["is_minor"] 

23 assert not commit_dict["is_patch"] 

24 

25 

26def test_angular_convention_breaking_changes() -> None: 

27 """Breaking changes (plural) are correctly identified.""" 

28 subject = "feat: this is a new breaking feature" 

29 body = ["BREAKING CHANGES: there is a breaking feature in this code"] 

30 commit = Commit( 

31 commit_hash="aaaaaaa", 

32 subject=subject, 

33 body=body, 

34 author_date="1574340645", 

35 committer_date="1574340645", 

36 ) 

37 convention = AngularConvention() 

38 commit_dict = convention.parse_commit(commit) 

39 assert commit_dict["is_major"] 

40 assert not commit_dict["is_minor"] 

41 assert not commit_dict["is_patch"] 

42 

43 

44def test_angular_convention_feat() -> None: 

45 """Feature commit is correctly identified.""" 

46 subject = "feat: this is a new feature" 

47 commit = Commit( 

48 commit_hash="aaaaaaa", 

49 subject=subject, 

50 author_date="1574340645", 

51 committer_date="1574340645", 

52 ) 

53 convention = AngularConvention() 

54 commit_dict = convention.parse_commit(commit) 

55 assert not commit_dict["is_major"] 

56 assert commit_dict["is_minor"] 

57 assert not commit_dict["is_patch"] 

58 

59 

60def test_angular_convention_fix() -> None: 

61 """Bug fix commit is correctly identified.""" 

62 subject = "fix: this is a bug fix" 

63 commit = Commit( 

64 commit_hash="aaaaaaa", 

65 subject=subject, 

66 author_date="1574340645", 

67 committer_date="1574340645", 

68 ) 

69 convention = AngularConvention() 

70 commit_dict = convention.parse_commit(commit) 

71 assert not commit_dict["is_major"] 

72 assert not commit_dict["is_minor"] 

73 assert commit_dict["is_patch"]