Coverage for suhteita / source_server_actions.py: 0.00%

22 statements  

« prev     ^ index     » next       coverage.py v7.13.2, created at 2026-02-03 22:42:42 +00:00

1"""Actions on source server instances.""" 

2 

3import copy 

4import datetime as dti 

5 

6from atlassian import Bitbucket 

7 

8from suhteita import IS_CLOUD, TOKEN, TS_FORMAT_PAYLOADS, Clocking 

9 

10 

11def login(target_url: str, user: str, password: str = TOKEN, is_cloud: bool = IS_CLOUD) -> tuple[Clocking, Bitbucket]: 

12 """DRY.""" 

13 start_time = dti.datetime.now(tz=dti.timezone.utc) 

14 service = Bitbucket(url=target_url, username=user, password=password, cloud=is_cloud) # type: ignore 

15 end_time = dti.datetime.now(tz=dti.timezone.utc) 

16 clocking: Clocking = ( 

17 start_time.strftime(TS_FORMAT_PAYLOADS), 

18 (end_time - start_time).microseconds, 

19 end_time.strftime(TS_FORMAT_PAYLOADS), 

20 ) 

21 return clocking, service 

22 

23 

24def get_server_info(service: Bitbucket) -> tuple[Clocking, object]: 

25 """DRY.""" 

26 start_time = dti.datetime.now(tz=dti.timezone.utc) 

27 data = copy.deepcopy(service.get_server_info(True)) # type: ignore 

28 end_time = dti.datetime.now(tz=dti.timezone.utc) 

29 clocking: Clocking = ( 

30 start_time.strftime(TS_FORMAT_PAYLOADS), 

31 (end_time - start_time).microseconds, 

32 end_time.strftime(TS_FORMAT_PAYLOADS), 

33 ) 

34 return clocking, data 

35 

36 

37def get_all_projects(service: Bitbucket) -> tuple[Clocking, list[dict[str, str]]]: 

38 """DRY.""" 

39 start_time = dti.datetime.now(tz=dti.timezone.utc) 

40 projects = copy.deepcopy(service.get_all_projects(included_archived=None)) # type: ignore 

41 end_time = dti.datetime.now(tz=dti.timezone.utc) 

42 clocking: Clocking = ( 

43 start_time.strftime(TS_FORMAT_PAYLOADS), 

44 (end_time - start_time).microseconds, 

45 end_time.strftime(TS_FORMAT_PAYLOADS), 

46 ) 

47 return clocking, projects