Skip to content

Commit 8c6e0f0

Browse files
authored
Merge pull request #16 from RavenPack/fix-creating-edge-dataset
Fix creating EDGE dataset without product attribute specified
2 parents 849287b + 2e6fa30 commit 8c6e0f0

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

ravenpackapi/examples/edge_entity_reference_filtered.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
you get those mappings for the entities you are interested into, without having
1010
to download all the rest.
1111
"""
12+
1213
import csv
1314

1415
from ravenpackapi import RPApi

ravenpackapi/examples/ravenpack_annotations_batch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Note: this example requires the "futures" package in python 2.7,
44
or python 3.2+
55
"""
6+
67
import glob
78
import os
89
from concurrent.futures.thread import ThreadPoolExecutor

ravenpackapi/models/dataset.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ def __init__(
6565

6666
self.uuid = uuid
6767

68-
# If the product is not specified, we assume it is RPA
69-
# unless the uuid is specified, in which case we'll ask the server
7068
self.product = product
71-
if self.product is None and self.uuid is None:
72-
self.product = "RPA"
69+
if self.product is None and self.uuid is None and self.api is not None:
70+
self.product = self.api.product
7371

7472
self.name = name
7573
self.description = description

ravenpackapi/tests/unit/models/test_dataset.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
class TestDataset:
77
def test_create_rpa_dataset(self, fake_api):
8-
dataset = Dataset(api=fake_api, name="test")
8+
dataset = Dataset(product="rpa", api=fake_api, name="test")
99
assert dataset.name == "test"
1010
assert dataset.api == fake_api
11-
assert dataset.product == "RPA"
11+
assert dataset.product == "rpa"
1212
dataset.save()
1313
assert fake_api.datasets["1"] == {
1414
"uuid": "1",
15-
"product": "RPA",
15+
"product": "rpa",
1616
"product_version": "1.0",
1717
"name": "test",
1818
}
@@ -30,13 +30,18 @@ def test_create_edge_dataset(self, fake_api):
3030
"name": "test",
3131
}
3232

33-
def test_create_dataset_with_default_product(self, fake_api):
33+
@pytest.mark.parametrize(
34+
"product",
35+
["rpa", "edge"],
36+
)
37+
def test_create_dataset_with_default_product(self, product):
38+
fake_api = FakeAPI(product=product)
3439
dataset = Dataset(api=fake_api, name="test")
35-
assert dataset.product == "RPA"
40+
assert dataset.product == product
3641
dataset.save()
3742
assert fake_api.datasets["1"] == {
3843
"uuid": "1",
39-
"product": "RPA",
44+
"product": product,
4045
"product_version": "1.0",
4146
"name": "test",
4247
}
@@ -117,8 +122,9 @@ def fake_api(self):
117122

118123

119124
class FakeAPI:
120-
def __init__(self):
125+
def __init__(self, product="rpa"):
121126
self.datasets = {}
127+
self.product = product
122128

123129
def request(self, endpoint, method="get", json=None):
124130
if method == "post":

0 commit comments

Comments
 (0)