def test_to_json(self): c = CompletedStructure('/a/source/dir', '/a/build/dir', '/b/source/dir', '/b/build/dir', '/results/dir') t = TestEntry('filename', 'weather') t = TestTestEntry.fully_populated_entry_successful(t) c.add_test_entry(t) valid_temp_json_file = tempfile.mkstemp(suffix='.json')[1] c.to_json_summary(valid_temp_json_file) with open(valid_temp_json_file) as f: json_body = f.read() obj = json.loads(json_body) self.assertIn('directories', obj) self.assertIn('runs', obj) self.assertIn('diffs', obj) self.assertIn('results_by_file', obj)
def test_to_json_object_response(self): c = CompletedStructure('/a/source/dir', '/a/build/dir', '/b/source/dir', '/b/build/dir', '/r/dir1', '/r/dir2') t = TestEntry('filename', 'weather') t = TestTestEntry.fully_populated_entry_successful(t) c.add_test_entry(t) obj = c.to_json_summary() self.assertIn('directories', obj) self.assertIn('runs', obj) self.assertIn('diffs', obj) self.assertIn('results_by_file', obj)