Skip to content

Commit eef77cc

Browse files
committed
Adding test for clonable shared models
1 parent 680855a commit eef77cc

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

bigml/api_handlers/resourcehandler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,9 +850,11 @@ def _set_clone_from_args(self, origin, resource_type, args=None,
850850
if args is not None:
851851
create_args.update(args)
852852

853-
attr = "shared_hash" if origin_id.startswith("shared") else "origin"
854-
if attr == "shared_hash":
853+
if origin["object"].get("shared_hash"):
854+
attr = "shared_hash"
855855
origin_id = origin["object"][attr]
856+
else:
857+
attr = "origin"
856858
create_args.update({attr: origin_id})
857859

858860
return create_args

bigml/tests/create_model_steps.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,14 @@ def model_from_public_url(step):
151151
eq_(get_status(world.model)['code'], FINISHED)
152152

153153

154-
def make_the_model_shared(step):
154+
def make_the_model_shared(step, cloneable=False):
155155
"""Step: I make the model shared"""
156+
shared = {'shared': True}
157+
if cloneable:
158+
shared.update({"shared_clonable": True})
156159
resource = world.api.update_model(world.model['resource'],
157-
{'shared': True})
160+
shared)
161+
world.api.ok(resource)
158162
world.status = resource['code']
159163
eq_(world.status, HTTP_ACCEPTED)
160164
world.location = resource['location']
@@ -644,6 +648,7 @@ def clone_model(step, model):
644648
# save reference
645649
world.models.append(resource['resource'])
646650

651+
647652
def the_cloned_model_is(step, model):
648653
"""Checking the model is a clone"""
649654
eq_(world.model["origin"], model)

bigml/tests/test_46_model_cloning.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ def test_scenario1(self):
6262
And I wait until the dataset is ready less than <dataset_wait> secs
6363
And I create a model
6464
And I wait until the model is ready less than <model_wait> secs
65+
And I clone the model
6566
Then the origin model is the previous model
67+
And I share and clone the shared model
68+
Then the origin model is the previous model
69+
6670
"""
6771
show_doc(self.test_scenario1)
6872
headers = ["data", "source_wait", "dataset_wait", "model_wait"]
@@ -80,10 +84,14 @@ def test_scenario1(self):
8084
self, example["dataset_wait"], shared=example["data"])
8185
model_create.i_create_a_model(self, shared=example["data"])
8286
model_create.the_model_is_finished_in_less_than(
83-
self, example["model_wait"], shared=example["data"])
87+
self, example["model_wait"])
8488
model = world.model["resource"]
89+
model_create.make_the_model_shared(self, cloneable=True)
90+
model_hash = "shared/model/%s" % world.model["shared_hash"]
8591
model_create.clone_model(self, model)
8692
model_create.the_cloned_model_is(self, model)
93+
model_create.clone_model(self, model_hash)
94+
model_create.the_cloned_model_is(self, model)
8795

8896
def test_scenario2(self):
8997
"""

0 commit comments

Comments
 (0)