예제 #1
0
    def test_getValueOrNone_not_found(self):
        """
        getValueOrNone will raise AssertionError if key is not found.
        """
        content = '{ "some": "value"}'
        json_file = manufacture.makeJSONFile(content=content)

        with self.assertRaises(AssertionError):
            json_file.getValueOrNone(json_file.data, 'other')
예제 #2
0
    def test_getValueOrNone_none(self):
        """
        getValueOrNone will return `None` for disabled values.
        """
        content = '{ "some": "None", "blah": "Disabled", "deh": ""}'
        json_file = manufacture.makeJSONFile(content=content)

        self.assertIsNone(json_file.getValueOrNone(json_file.data, 'some'))
        self.assertIsNone(json_file.getValueOrNone(json_file.data, 'blah'))
        self.assertIsNone(json_file.getValueOrNone(json_file.data, 'deh'))
예제 #3
0
    def test_getValueOrNone_value(self):
        """
        getValueOrNone will return the actual value.
        """
        value = manufacture.getUniqueString()
        content = '{ "some": "%s"}' % (value)
        json_file = manufacture.makeJSONFile(content=content)

        self.assertEqual(
            value,
            json_file.getValueOrNone(json_file.data, 'some'),
            )