def test_generate_jsons(self): filesystem = MockFileSystem() test_json = { 'array.json': [1, 2, 3, { 'key': 'value' }], 'dictionary.json': { 'somekey': 'somevalue', 'array': [4, 5] } } capture = OutputCapture() capture.capture_output() AnalyzeChangeLog._generate_jsons(filesystem, test_json, 'bar') self.assertEqual(set(filesystem.files.keys()), set(['bar/array.json', 'bar/dictionary.json'])) capture.restore_output() self.assertEqual(json.loads(filesystem.files['bar/array.json']), test_json['array.json']) self.assertEqual(json.loads(filesystem.files['bar/dictionary.json']), test_json['dictionary.json'])
def test_enumerate_enumerate_changelogs(self): filesystem = MockFileSystem({ 'foo/ChangeLog': '', 'foo/ChangeLog-2010-06-23': '', 'foo/ChangeLog-2010-12-31': '', 'foo/ChangeLog-x': '', 'foo/ChangeLog-2011-01-01': '', }) changelogs = AnalyzeChangeLog._enumerate_changelogs(filesystem, 'foo/', None) self.assertEqual(changelogs, ['foo/ChangeLog', 'foo/ChangeLog-2011-01-01', 'foo/ChangeLog-2010-12-31', 'foo/ChangeLog-2010-06-23']) changelogs = AnalyzeChangeLog._enumerate_changelogs(filesystem, 'foo/', 2) self.assertEqual(changelogs, ['foo/ChangeLog', 'foo/ChangeLog-2011-01-01'])
def test_generate_jsons(self): filesystem = MockFileSystem() test_json = {'array.json': [1, 2, 3, {'key': 'value'}], 'dictionary.json': {'somekey': 'somevalue', 'array': [4, 5]}} capture = OutputCapture() capture.capture_output() AnalyzeChangeLog._generate_jsons(filesystem, test_json, 'bar') self.assertEqual(set(filesystem.files.keys()), set(['bar/array.json', 'bar/dictionary.json'])) capture.restore_output() self.assertEqual(json.loads(filesystem.files['bar/array.json']), test_json['array.json']) self.assertEqual(json.loads(filesystem.files['bar/dictionary.json']), test_json['dictionary.json'])