def test_get_extract_by_odes(self): db = Mock() db.fetchone.return_value = ('123', 'XYZ', '456', [1,2,3,4], '7', 8, 'Oakland', 85921881, None) odes = data.ODES('7') extract = data.get_extract(db, odes=odes) self.assertEqual(db.mock_calls[0][0], 'execute') self.assertEqual(db.mock_calls[0][1][1], ('7', )) self.assertEqual(db.mock_calls[0][1][0], ''' SELECT id, name, envelope_id, envelope_bbox, odes_id, user_id, wof_name, wof_id, created FROM extracts WHERE odes_id = %s ''') self.assertEqual(extract.id, '123') self.assertEqual(extract.name, 'XYZ') self.assertEqual(id(extract.odes), id(odes)) self.assertEqual(extract.user_id, 8) self.assertEqual(extract.envelope.id, '456') self.assertEqual(extract.envelope.bbox, [1,2,3,4]) self.assertEqual(extract.wof.id, 85921881) self.assertEqual(extract.wof.name, 'Oakland') with self.assertRaises(AssertionError) as bad_id: odes2 = data.ODES(7)
def test_get_extract_by_odes(self): db = Mock() db.fetchone.return_value = ('123', 'XYZ', '456', [1, 2, 3, 4], '7', 8, 'Oakland', 85921881, None) odes = data.ODES('7') extract = data.get_extract(db, odes=odes) self.assertEqual(db.mock_calls[0][0], 'execute') self.assertEqual(db.mock_calls[0][1][1], ('7', )) self.assertEqual( db.mock_calls[0][1][0], ''' SELECT id, name, envelope_id, envelope_bbox, odes_id, user_id, wof_name, wof_id, created FROM extracts WHERE odes_id = %s ''') self.assertEqual(extract.id, '123') self.assertEqual(extract.name, 'XYZ') self.assertEqual(id(extract.odes), id(odes)) self.assertEqual(extract.user_id, 8) self.assertEqual(extract.envelope.id, '456') self.assertEqual(extract.envelope.bbox, [1, 2, 3, 4]) self.assertEqual(extract.wof.id, 85921881) self.assertEqual(extract.wof.name, 'Oakland') with self.assertRaises(AssertionError) as bad_id: odes2 = data.ODES(7)
def test_get_extract_by_envelope(self): db = Mock() db.fetchone.return_value = ('123', 'XYZ', '456', [1,2,3,4], '7', 8, 'Oakland', 85921881, None) extract = data.get_extract(db, envelope_id='456') self.assertEqual(db.mock_calls[0][0], 'execute') self.assertEqual(db.mock_calls[0][1][1], ('456', )) self.assertEqual(db.mock_calls[0][1][0], ''' SELECT id, name, envelope_id, envelope_bbox, odes_id, user_id, wof_name, wof_id, created FROM extracts WHERE envelope_id = %s ''') self.assertEqual(extract.id, '123') self.assertEqual(extract.name, 'XYZ') self.assertEqual(extract.odes.id, '7') self.assertEqual(extract.user_id, 8) self.assertEqual(extract.envelope.id, '456') self.assertEqual(extract.envelope.bbox, [1,2,3,4]) self.assertEqual(extract.wof.id, 85921881) self.assertEqual(extract.wof.name, 'Oakland')
def test_get_extract_by_id(self): db = Mock() db.fetchone.return_value = ('123', 'XYZ', '456', [1, 2, 3, 4], '7', 8, 'Oakland', 85921881, None) extract = data.get_extract(db, extract_id='123') self.assertEqual(db.mock_calls[0][0], 'execute') self.assertEqual(db.mock_calls[0][1][1], ('123', )) self.assertEqual( db.mock_calls[0][1][0], ''' SELECT id, name, envelope_id, envelope_bbox, odes_id, user_id, wof_name, wof_id, created FROM extracts WHERE id = %s ''') self.assertEqual(extract.id, '123') self.assertEqual(extract.name, 'XYZ') self.assertEqual(extract.odes.id, '7') self.assertEqual(extract.user_id, 8) self.assertEqual(extract.envelope.id, '456') self.assertEqual(extract.envelope.bbox, [1, 2, 3, 4]) self.assertEqual(extract.wof.id, 85921881) self.assertEqual(extract.wof.name, 'Oakland')