< Summary

Class:minesweeper.py
Assembly:src.service
File(s):/home/runner/work/kata-python-minesweeper5/kata-python-minesweeper5/src/service/minesweeper.py
Covered lines:0
Uncovered lines:24
Coverable lines:24
Total lines:36
Line coverage:0% (0 of 24)
Covered branches:0
Total branches:6
Branch coverage:0% (0 of 6)
Tag:20_659826003

File(s)

/home/runner/work/kata-python-minesweeper5/kata-python-minesweeper5/src/service/minesweeper.py

#LineLine coverage
 01from typing import Any, NewType
 2
 03from injector import inject
 04from minesweeper.minemap import MineMap
 05import uuid
 6
 07Session = NewType("SessionFactory", Any)
 8
 09mine_maps = {}
 10
 11
 012def check_available_mine_map(session):
 013    if "mine_map" in session:
 014        if session["mine_map"] in mine_maps.keys():
 015            return True
 16
 017    return False
 18
 19
 020class MineSweeperService:
 021    @inject
 022    def __init__(self, session: Session):
 023        self._session = session
 24
 025        if check_available_mine_map(session) is False:
 026            session["mine_map"] = uuid.uuid1()
 027            mine_maps[session["mine_map"]] = MineMap(3, 3, random_bombs=3)
 28
 029        self.mine_map = mine_maps[session["mine_map"]]
 30
 031    def __str__(self):
 032        l = str(self.mine_map)
 033        return l
 34
 035    def click(self, x: int, y: int):
 036        self.mine_map.click(x, y)

Methods/Properties