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')
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'))
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'), )