Skip to content

Commit

Permalink
Merge pull request #477 from SFDO-Tooling/feature/respect-batch-size
Browse files Browse the repository at this point in the history
Support all relevant mapping features in load.yml
  • Loading branch information
Paul Prescod authored Sep 27, 2021
2 parents c5007a4 + 49d3206 commit 82147b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
9 changes: 7 additions & 2 deletions snowfakery/cci_mapping_files/declaration_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AtomicDecl(T.NamedTuple):

sf_object: str
key: str
value: T.Union[T.List, str]
value: T.Union[T.List, str, date, int]
priority: int
merge_rule: T.Callable # what to do if two declarations for same val

Expand Down Expand Up @@ -87,7 +87,12 @@ def case_normalizer(cls, val):
return val

def as_mapping(self):
rc = {"api": self.api, "bulk_mode": self.bulk_mode}
rc = {
"api": self.api,
"bulk_mode": self.bulk_mode,
"batch_size": self.batch_size,
"anchor_date": self.anchor_date,
}
return {k: v for k, v in rc.items() if v is not None}


Expand Down
4 changes: 3 additions & 1 deletion tests/cci/mapping_mixins.load.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
api: rest

- sf_object: Account
api: smart
api: rest
batch_size: 100
anchor_date: 2000-01-01
8 changes: 5 additions & 3 deletions tests/cci/test_declaration_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
SObjectRuleDeclaration(sf_object="bar", priority="medium", api="smart"),
SObjectRuleDeclaration(sf_object="bar", priority="medium", bulk_mode="serial"),
SObjectRuleDeclaration(sf_object="bar", priority="high", bulk_mode="Parallel"),
SObjectRuleDeclaration(sf_object="foo", priority="low", batch_size=2000),
SObjectRuleDeclaration(sf_object="foo", priority="low", anchor_date="2000-01-01"),
]


Expand All @@ -42,9 +44,9 @@ def test_priority_overrides(self):
load_after=None,
priority=None,
api="bulk",
batch_size=None,
batch_size=2000,
bulk_mode="serial",
anchor_date=None,
anchor_date="2000-01-01",
),
}

Expand Down Expand Up @@ -74,7 +76,7 @@ def test_cli__infers_load_file(self, tmpdir):
"Insert Contact",
"Insert Opportunity",
]
assert map_data["Insert Account"]["api"] == "smart"
assert map_data["Insert Account"]["api"] == "rest"

def test_cli__explicit_file(self, tmpdir):
sample_yaml = Path(__file__).parent / "mapping_mixins.recipe.yml"
Expand Down

0 comments on commit 82147b1

Please sign in to comment.