Allow RefineProject to take just a project id as a convenience.

This commit is contained in:
Paul Makepeace 2011-05-26 23:24:56 +01:00 committed by Paul Makepeace
parent f3354f6fc1
commit 45a80902ef
2 changed files with 8 additions and 1 deletions

View File

@ -221,7 +221,11 @@ class RefineProject:
if not isinstance(server, RefineServer):
if '/project?project=' in server:
server, project_id = server.split('/project?project=')
server = RefineServer(server)
server = RefineServer(server)
elif re.match(r'\d+$', server): # just digits => project ID
server, project_id = RefineServer(), server
else:
server = RefineServer(server)
self.server = server
if not project_id:
raise Exception('Missing Refine project ID')

View File

@ -63,6 +63,9 @@ class RefineProjectTest(unittest.TestCase):
p = RP('http://server/varnish/project?project=1658955153749')
self.assertEqual(p.server.server, 'http://server/varnish')
self.assertEqual(p.project_id, '1658955153749')
p = RP('1658955153749')
self.assertEqual(p.server.server, 'http://127.0.0.1:3333')
self.assertEqual(p.project_id, '1658955153749')
def tearDown(self):
# Restore mocked get_models