def bidBuilder(dictionary: dict) -> Bidding: if "__type__" in dictionary and dictionary["__type__"] == "Bidding": result = Bidding() result.current = dictionary["current"] result.whoStarts = dictionary["whoStarts"] result.nrOfPoints = dictionary["nrOfPoints"] result.nrOfCards = dictionary["nrOfCards"] return result else: return dictionary
def testIsDblAllowed(): bidding = Bidding() bidding.current = [ ] assert not bidding.isAllowed('X') bidding.current = [ '1♣', '2♦' ] assert bidding.isAllowed('X') bidding.current = [ '1♣', '2♦', 'pass' ] assert not bidding.isAllowed('X') bidding.current = [ '1♣', '2♦', 'X' ] assert not bidding.isAllowed('X') bidding.current = [ '1♣', '2♦', 'pass', 'pass' ] assert bidding.isAllowed('X') bidding.current = ['1♣', 'X'] assert not bidding.isAllowed('X')
def testSerializesBids(): a = Bidding() a.current = ['pass', 'X', '1♣'] result = bid2Json(a) assert result == '{"__type__": "Bidding", "current": ["pass", "X", "1♣"], "whoStarts": "N", "nrOfPoints": null, "nrOfCards": {}}'
def testNoDblOnPartner(): bidding = Bidding() bidding.current = ['X', 'X', 'pass'] assert not bidding.isAllowed('X')
def testRdblnoDbl(): bidding = Bidding() bidding.current = ['1♣'] assert not bidding.isAllowed('XX')
def testDoubleRdbl(): bidding = Bidding() bidding.current = ["1♣", 'XX'] assert not bidding.isAllowed('XX')
def testIsRdblAllowed(): bidding = Bidding() bidding.current = ["1♣", 'X'] assert bidding.isAllowed('XX')
def testLeaderN(): bidding = Bidding() bidding.current = ['1♥', 'pass', '1SA', 'pass', 'pass', 'pass'] bidding.whoStarts = north assert bidding.contract() == ('1SA', south)
def testLeaderW(): bidding = Bidding() bidding.current = ['1♥', 'pass', '1SA', 'pass', '2♦', 'pass', 'pass', '2♥', 'pass', 'pass', '3♣', 'pass', 'pass', 'pass'] bidding.whoStarts = east assert bidding.contract() == ('3♣', west)