def test_save_object_basics(): s = Scraper('jurisdiction', '2013', '/tmp/') p = Person('Michael Jordan') p.add_source('http://example.com') with mock.patch('json.dump') as json_dump: s.save_object(p) # saved in right place filename = 'person_' + p._id + '.json' assert_in(filename, s.output_names['person']) json_dump.assert_called_once_with(p.as_dict(), mock.ANY, cls=mock.ANY)
def test_save_related(): s = Scraper('jurisdiction', '2013', '/tmp/') p = Person('Michael Jordan') p.add_source('http://example.com') o = Organization('Chicago Bulls') o.add_source('http://example.com') p._related.append(o) with mock.patch('json.dump') as json_dump: s.save_object(p) assert_equal(json_dump.mock_calls, [ mock.call(p.as_dict(), mock.ANY, cls=mock.ANY), mock.call(o.as_dict(), mock.ANY, cls=mock.ANY) ])