コード例 #1
0
    def setUpClass(cls):
        """
        Set up variables for testing
        """

        logging.info("Setting up variables for testing GridLocation class")

        cls.gridLocChar = "G"
        cls.gridLocNumb = 10

        with open("TestGloomlogGridLocation.json", "r") as file:
            cls.textJSON = file.read()

        cls.gridLocTest = gloommodel.GridLocation(
            cls.gridLocChar, cls.gridLocNumb)
        cls.gridLocTestJSON = gloommodel.GridLocation(
            fullJSON=cls.textJSON)
コード例 #2
0
    def testScenarioLocationEqual(self):
        """
        Test whether the scenario location has been correctly set
        """

        logging.info(
            "Testing whether the scenario location has been correctly set")

        gridLocCopy = gloommodel.GridLocation(
            self.gridLocChar, self.gridLocNumb)

        self.assertEqual(self.scenTest.gridLocation, gridLocCopy)
コード例 #3
0
    def helperFunctionEqualityAndFromJSON(self):
        """
        Helper function for testing the __eq__ and fromJSON methods
        """

        gridLocDict = self.gridLocTest.fromJSON(self.textJSON)
        gridLocCharacter = gridLocDict["character"]
        gridLocNumber = gridLocDict["identifier"]

        gridLocCopy = gloommodel.GridLocation(gridLocCharacter, gridLocNumber)

        self.assertEqual(self.gridLocTest, gridLocCopy)
        self.assertEqual(self.gridLocTestJSON, gridLocCopy)
        self.assertEqual(self.gridLocTest, self.gridLocTestJSON)
コード例 #4
0
    def testScenarioFromJSON(self):
        """
        Test whether a Scenario can be succesfully generated from a correct JSON
        """

        logging.info(
            "Testing whether a Scenario can be succesfully generated from a correct JSON")

        scenDict = self.scenTest.fromJSON(self.textJSON)
        scenNumber = scenDict["identifier"]
        scenName = scenDict["name"]
        scenGridLoc = gloommodel.GridLocation(
            fullJSON=json.dumps(scenDict["gridLocation"]))
        scenSucces = scenDict["succes"]

        scenCopy = gloommodel.Scenario(
            scenNumber, scenName, scenGridLoc, scenSucces
        )

        self.assertEqual(self.scenTest, scenCopy)
        self.assertEqual(self.scenTestJSON, scenCopy)
        self.assertEqual(self.scenTest, self.scenTestJSON)
コード例 #5
0
    def setUpClass(cls):
        """
        Set up variables for testing
        """

        logging.info("Setting up variables for testing Scenario class")

        cls.identifier = 1
        cls.name = "Black Barrow"
        cls.gridLocChar = "G"
        cls.gridLocNumb = 10
        cls.succes = False

        with open("TestGloomlogScenario.json", "r") as file:
            cls.textJSON = file.read()

        cls.scenTest = gloommodel.Scenario(
            cls.identifier,
            cls.name,
            gloommodel.GridLocation(cls.gridLocChar, cls.gridLocNumb),
            cls.succes
        )
        cls.scenTestJSON = gloommodel.Scenario(fullJSON=cls.textJSON)