Allow RefineProject to take just a project id as a convenience.
This commit is contained in:
parent
f3354f6fc1
commit
45a80902ef
|
@ -221,7 +221,11 @@ class RefineProject:
|
||||||
if not isinstance(server, RefineServer):
|
if not isinstance(server, RefineServer):
|
||||||
if '/project?project=' in server:
|
if '/project?project=' in server:
|
||||||
server, project_id = server.split('/project?project=')
|
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
|
self.server = server
|
||||||
if not project_id:
|
if not project_id:
|
||||||
raise Exception('Missing Refine project ID')
|
raise Exception('Missing Refine project ID')
|
||||||
|
|
|
@ -63,6 +63,9 @@ class RefineProjectTest(unittest.TestCase):
|
||||||
p = RP('http://server/varnish/project?project=1658955153749')
|
p = RP('http://server/varnish/project?project=1658955153749')
|
||||||
self.assertEqual(p.server.server, 'http://server/varnish')
|
self.assertEqual(p.server.server, 'http://server/varnish')
|
||||||
self.assertEqual(p.project_id, '1658955153749')
|
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):
|
def tearDown(self):
|
||||||
# Restore mocked get_models
|
# Restore mocked get_models
|
||||||
|
|
Loading…
Reference in New Issue