2011-04-26 21:05:02 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
"""
|
|
|
|
test_refine.py
|
|
|
|
|
|
|
|
These tests require a connection to a Refine server either at
|
2011-04-26 23:02:40 +02:00
|
|
|
http://127.0.0.1:3333/ or by specifying environment variables
|
|
|
|
GOOGLE_REFINE_HOST and GOOGLE_REFINE_PORT.
|
2011-04-26 21:05:02 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
# Copyright (c) 2011 Paul Makepeace, Real Programmers. All rights reserved.
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
from google.refine import refine
|
|
|
|
from google.refine import facet
|
2011-04-26 21:13:25 +02:00
|
|
|
from google.test import refinetest
|
2011-04-26 21:05:02 +02:00
|
|
|
|
|
|
|
|
2011-04-26 21:13:25 +02:00
|
|
|
class RefineServerTest(refinetest.RefineTestCase):
|
2011-04-26 21:05:02 +02:00
|
|
|
def test_init(self):
|
|
|
|
self.assertEqual(self.server.server,
|
|
|
|
'http://%s:%s' % (refine.REFINE_HOST, refine.REFINE_PORT))
|
2011-04-26 22:55:07 +02:00
|
|
|
# strip trailing /
|
2011-04-26 21:05:02 +02:00
|
|
|
server = refine.RefineServer('http://refine.example/')
|
|
|
|
self.assertEqual(server.server, 'http://refine.example')
|
|
|
|
|
|
|
|
def test_list_projects(self):
|
|
|
|
projects = self.refine.list_projects()
|
|
|
|
self.assertTrue(isinstance(projects, dict))
|
|
|
|
|
|
|
|
def test_get_version(self):
|
|
|
|
version_info = self.refine.get_version()
|
|
|
|
for item in ('revision', 'version', 'full_version', 'full_name'):
|
|
|
|
self.assertTrue(item in version_info)
|
|
|
|
|
|
|
|
|
2011-04-26 21:13:25 +02:00
|
|
|
class RefineTest(refinetest.RefineTestCase):
|
2011-04-26 21:05:02 +02:00
|
|
|
project_file = 'duplicates.csv'
|
|
|
|
|
|
|
|
def test_new_project(self):
|
|
|
|
self.assertTrue(isinstance(self.project, refine.RefineProject))
|
|
|
|
|
2011-04-27 05:52:13 +02:00
|
|
|
def _test_get_models(self):
|
2011-04-26 21:05:02 +02:00
|
|
|
self.assertEqual(self.project.key_column, 'email')
|
|
|
|
self.assertTrue('email' in self.project.column_order)
|
|
|
|
self.assertEqual(self.project.column_order['name'], 1)
|
|
|
|
|
|
|
|
def test_delete_project(self):
|
|
|
|
self.assertTrue(self.project.delete())
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|