Coverage for jaypore_ci/remotes/mock.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.2.2, created at 2023-03-30 09:04 +0000

1""" 

2A mock remote. 

3 

4This is used to test pipelines. 

5""" 

6from jaypore_ci.interfaces import Remote, Repo 

7from jaypore_ci.logging import logger 

8 

9 

10class Mock(Remote): # pylint: disable=too-many-instance-attributes 

11 """ 

12 A mock remote implementation. 

13 """ 

14 

15 @classmethod 

16 def from_env(cls, *, repo: Repo): 

17 return cls(branch=repo.branch, sha=repo.sha) 

18 

19 def logging(self): 

20 """ 

21 Return's a logging instance with information about gitea bound to it. 

22 """ 

23 return logger.bind(branch=self.branch) 

24 

25 def get_pr_id(self): 

26 """ 

27 Returns the pull request ID for the current branch. 

28 """ 

29 return self.branch 

30 

31 def publish(self, report: str, status: str): 

32 """ 

33 Will publish the report to the remote. 

34 """ 

35 pr_id = self.get_pr_id() 

36 self.logging().debug( 

37 "Published report", report=report, status=status, pr_id=pr_id 

38 )