How to use resolve_conflicts method in localstack

Best Python code snippet using localstack_python

test_conflict_resolver.py

Source:test_conflict_resolver.py Github

copy

Full Screen

...3from estnltk_core.layer_operations import resolve_conflicts4from estnltk_core.converters import records_to_layer5def test_conflict_resolving_strategy_type():6 with pytest.raises(ValueError):7 resolve_conflicts(layer=Layer(name='test_layer', attributes=['_priority_']),8 conflict_resolving_strategy='unexpected value')9def test_no_conflict_resolving():10 layer = Layer(name='test_layer', attributes=['_priority_'])11 layer = records_to_layer(layer, [{'start': 1, 'end': 8, '_priority_': 0},12 {'start': 2, 'end': 4, '_priority_': 1},13 {'start': 3, 'end': 6, '_priority_': 2}])14 result = resolve_conflicts(layer=layer,15 conflict_resolving_strategy='ALL',16 priority_attribute=None)17 assert result is layer18 assert len(result) == 319def test_status():20 layer = Layer(name='test_layer', attributes=['_priority_'])21 layer = records_to_layer(layer, [{'start': 1, 'end': 8, '_priority_': 0},22 {'start': 2, 'end': 4, '_priority_': 1},23 {'start': 3, 'end': 6, '_priority_': 2}])24 status = {}25 result = resolve_conflicts(layer=layer,26 conflict_resolving_strategy='ALL',27 status=status,28 priority_attribute='_priority_')29 assert status == {'number_of_conflicts': 3}30 assert result is layer31 assert len(result) == 132def test_resolve_conflicts_MAX():33 # empty span list34 layer = Layer(name='test_layer', attributes=['_priority_'])35 layer = records_to_layer(layer, [])36 layer = resolve_conflicts(layer, conflict_resolving_strategy='MAX', priority_attribute='_priority_')37 assert [] == [(span.start, span.end) for span in layer]38 # one span39 layer = Layer(name='test_layer', attributes=['_priority_'])40 layer = records_to_layer(layer, [{'start': 1, 'end': 4, '_priority_': 0}])41 layer = resolve_conflicts(layer, conflict_resolving_strategy='MAX', priority_attribute='_priority_')42 assert [(1, 4)] == [(span.start, span.end) for span in layer]43 # equal spans44 layer = Layer(name='test_layer', attributes=['_priority_'], ambiguous=True)45 layer = records_to_layer(layer, [[{'start': 1, 'end': 4, '_priority_': 0},46 {'start': 1, 'end': 4, '_priority_': 0} ]])47 layer = resolve_conflicts(layer, conflict_resolving_strategy='MAX', priority_attribute='_priority_')48 assert len(layer[0].annotations) == 149 assert [(1, 4)] == [(span.start, span.end) for span in layer]50 # common start51 layer = Layer(name='test_layer', attributes=['_priority_'])52 layer = records_to_layer(layer, [{'start': 1, 'end': 4, '_priority_': 0},53 {'start': 1, 'end': 6, '_priority_': 0}])54 layer = resolve_conflicts(layer, conflict_resolving_strategy='MAX', priority_attribute='_priority_')55 assert [(1, 6)] == [(span.start, span.end) for span in layer]56 # common end57 layer = Layer(name='test_layer', attributes=['_priority_'])58 layer = records_to_layer(layer, [{'start': 3, 'end': 6, '_priority_': 0},59 {'start': 1, 'end': 6, '_priority_': 0} ])60 layer = resolve_conflicts(layer, conflict_resolving_strategy='MAX', priority_attribute='_priority_')61 assert [(1, 6)] == [(span.start, span.end) for span in layer]62 # complex63 layer = Layer(name='test_layer', attributes=['_priority_'])64 layer = records_to_layer(layer, [{'start': 1, 'end': 8, '_priority_': 0},65 {'start': 2, 'end': 4, '_priority_': 0},66 {'start': 3, 'end': 6, '_priority_': 0}])67 layer = resolve_conflicts(layer, conflict_resolving_strategy='MAX', priority_attribute='_priority_')68 assert [(1, 8)] == [(span.start, span.end) for span in layer]69 # complex, different priorities70 layer = Layer(name='test_layer', attributes=['_priority_'])71 layer = records_to_layer(layer, [{'start': 1, 'end': 8, '_priority_': 1},72 {'start': 2, 'end': 4, '_priority_': 0},73 {'start': 3, 'end': 6, '_priority_': 1}])74 layer = resolve_conflicts(layer, conflict_resolving_strategy='MAX', priority_attribute='_priority_')75 assert [(2, 4)] == [(span.start, span.end) for span in layer]76 # complex, no priority attribute77 layer = Layer(name='test_layer', attributes=['_priority_'])78 layer = records_to_layer(layer, [{'start': 1, 'end': 8, '_priority_': 1},79 {'start': 2, 'end': 4, '_priority_': 0},80 {'start': 3, 'end': 6, '_priority_': 1}])81 layer = resolve_conflicts(layer, conflict_resolving_strategy='MAX', priority_attribute=None)82 assert [(1, 8)] == [(span.start, span.end) for span in layer]83def test_resolve_conflicts_MIN(): 84 # empty span list85 layer = Layer(name='test_layer', attributes=['_priority_'])86 layer = records_to_layer(layer, [])87 layer = resolve_conflicts(layer, conflict_resolving_strategy='MIN', priority_attribute='_priority_')88 assert [] == [(span.start, span.end) for span in layer]89 # one span90 layer = Layer(name='test_layer', attributes=['_priority_'])91 layer = records_to_layer(layer, [{'start': 1, 'end': 4, '_priority_': 0}])92 layer = resolve_conflicts(layer, conflict_resolving_strategy='MIN', priority_attribute='_priority_')93 assert [(1, 4)] == [(span.start, span.end) for span in layer]94 # equal spans95 layer = Layer(name='test_layer', attributes=['_priority_'], ambiguous=True)96 layer = records_to_layer(layer, [[{'start': 1, 'end': 4, '_priority_': 0},97 {'start': 1, 'end': 4, '_priority_': 0}]])98 layer = resolve_conflicts(layer, conflict_resolving_strategy='MIN', priority_attribute='_priority_')99 assert len(layer[0].annotations) == 1100 assert [(1, 4)] == [(span.start, span.end) for span in layer]101 # common start102 layer = Layer(name='test_layer', attributes=['_priority_'])103 layer = records_to_layer(layer, [{'start': 1, 'end': 4, '_priority_': 0},104 {'start': 1, 'end': 6, '_priority_': 0}])105 layer = resolve_conflicts(layer, conflict_resolving_strategy='MIN', priority_attribute='_priority_')106 assert [(1, 4)] == [(span.start, span.end) for span in layer]107 # common end108 layer = Layer(name='test_layer', attributes=['_priority_'])109 layer = records_to_layer(layer, [{'start': 3, 'end': 6, '_priority_': 0},110 {'start': 1, 'end': 6, '_priority_': 0}])111 layer = resolve_conflicts(layer, conflict_resolving_strategy='MIN', priority_attribute='_priority_')112 assert [(3, 6)] == [(span.start, span.end) for span in layer]113 # complex114 layer = Layer(name='test_layer', attributes=['_priority_'])115 layer = records_to_layer(layer, [{'start': 1, 'end': 8, '_priority_': 0},116 {'start': 2, 'end': 4, '_priority_': 0},117 {'start': 3, 'end': 6, '_priority_': 0} ])118 layer = resolve_conflicts(layer, conflict_resolving_strategy='MIN', priority_attribute='_priority_')119 assert [(2, 4)] == [(span.start, span.end) for span in layer]120 # complex, different priorities121 layer = Layer(name='test_layer', attributes=['_priority_'])122 layer = records_to_layer(layer, [{'start': 1, 'end': 8, '_priority_': 1},123 {'start': 2, 'end': 4, '_priority_': 1},124 {'start': 3, 'end': 6, '_priority_': 0} ])125 layer = resolve_conflicts(layer, conflict_resolving_strategy='MIN', priority_attribute='_priority_')126 assert [(3, 6)] == [(span.start, span.end) for span in layer]127def test_resolve_conflicts_ALL():128 # complex129 layer = Layer(name='test_layer', attributes=['_priority_'])130 layer = records_to_layer(layer, [{'start': 1, 'end': 8, '_priority_': 0},131 {'start': 2, 'end': 4, '_priority_': 0},132 {'start': 3, 'end': 6, '_priority_': 0}])133 layer = resolve_conflicts(layer, conflict_resolving_strategy='ALL', priority_attribute='_priority_')134 assert [(1, 8), (2, 4), (3, 6)] == [(span.start, span.end) for span in layer]135 # complex, different priorities136 layer = Layer(name='test_layer', attributes=['_priority_'])137 layer = records_to_layer(layer, [{'start': 1, 'end': 8, '_priority_': 1},138 {'start': 2, 'end': 4, '_priority_': 1},139 {'start': 3, 'end': 6, '_priority_': 0}])140 layer = resolve_conflicts(layer, conflict_resolving_strategy='ALL', priority_attribute='_priority_')141 assert [(3, 6)] == [(span.start, span.end) for span in layer]142 # complex, different priorities143 layer = Layer(name='test_layer', attributes=['_priority_'])144 layer = records_to_layer(layer, [{'start': 1, 'end': 3, '_priority_': 2},145 {'start': 2, 'end': 7, '_priority_': 1},146 {'start': 4, 'end': 8, '_priority_': 0}])147 layer = resolve_conflicts(layer, conflict_resolving_strategy='ALL', priority_attribute='_priority_')148 assert [(1, 3), (4, 8)] == [(span.start, span.end) for span in layer]149def test_resolve_conflicts_ambiguous_layer():150 # keep_equal=True151 layer = Layer(name='test_layer', attributes=['attr_1', '_priority_'], ambiguous=True)152 layer = records_to_layer(layer, [ \153 [{'start': 1, 'end': 2, 'attr_1': 1, '_priority_': 0}],154 [{'start': 2, 'end': 3, 'attr_1': 1, '_priority_': 1},155 {'start': 2, 'end': 3, 'attr_1': 2, '_priority_': 2},156 {'start': 2, 'end': 3, 'attr_1': 3, '_priority_': 3},157 {'start': 2, 'end': 3, 'attr_1': 4, '_priority_': 4}],158 [{'start': 4, 'end': 5, 'attr_1': 1, '_priority_': 1},159 {'start': 4, 'end': 5, 'attr_1': 2, '_priority_': 1},160 {'start': 4, 'end': 5, 'attr_1': 3, '_priority_': 0},161 {'start': 4, 'end': 5, 'attr_1': 4, '_priority_': 0}],162 [{'start': 6, 'end': 7, 'attr_1': 1, '_priority_': 2},163 {'start': 6, 'end': 7, 'attr_1': 2, '_priority_': 1},164 {'start': 6, 'end': 7, 'attr_1': 3, '_priority_': 2},165 {'start': 6, 'end': 7, 'attr_1': 4, '_priority_': 3}],166 ])167 layer = resolve_conflicts(layer,168 conflict_resolving_strategy='ALL',169 priority_attribute='_priority_',170 keep_equal=True)171 result = [(annotation.start, annotation.end) for span in layer for annotation in span.annotations]172 assert [(1, 2), (2, 3), (4, 5), (4, 5), (6, 7)] == result, result173 # keep_equal=False174 layer = Layer(name='test_layer', attributes=['attr_1', '_priority_'], ambiguous=True)175 layer = records_to_layer(layer, [ \176 [{'start': 1, 'end': 4, 'attr_1': 1, '_priority_': 0}],177 [{'start': 3, 'end': 6, 'attr_1': 1, '_priority_': 1},178 {'start': 3, 'end': 6, 'attr_1': 2, '_priority_': 2},179 {'start': 3, 'end': 6, 'attr_1': 3, '_priority_': 3},180 {'start': 3, 'end': 6, 'attr_1': 4, '_priority_': 4}],181 [{'start': 5, 'end': 7, 'attr_1': 1, '_priority_': 1},182 {'start': 5, 'end': 7, 'attr_1': 2, '_priority_': 1},183 {'start': 5, 'end': 7, 'attr_1': 3, '_priority_': 0},184 {'start': 5, 'end': 7, 'attr_1': 4, '_priority_': 0}],185 ])186 layer = resolve_conflicts(layer,187 conflict_resolving_strategy='ALL',188 priority_attribute='_priority_',189 keep_equal=False)...

Full Screen

Full Screen

addon.py

Source:addon.py Github

copy

Full Screen

...71 def addon_version(self, value: Optional[pulumi.Input[str]]):72 pulumi.set(self, "addon_version", value)73 @property74 @pulumi.getter(name="resolveConflicts")75 def resolve_conflicts(self) -> Optional[pulumi.Input['AddonResolveConflicts']]:76 """77 Resolve parameter value conflicts78 """79 return pulumi.get(self, "resolve_conflicts")80 @resolve_conflicts.setter81 def resolve_conflicts(self, value: Optional[pulumi.Input['AddonResolveConflicts']]):82 pulumi.set(self, "resolve_conflicts", value)83 @property84 @pulumi.getter(name="serviceAccountRoleArn")85 def service_account_role_arn(self) -> Optional[pulumi.Input[str]]:86 """87 IAM role to bind to the add-on's service account88 """89 return pulumi.get(self, "service_account_role_arn")90 @service_account_role_arn.setter91 def service_account_role_arn(self, value: Optional[pulumi.Input[str]]):92 pulumi.set(self, "service_account_role_arn", value)93 @property94 @pulumi.getter95 def tags(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['AddonTagArgs']]]]:96 """97 An array of key-value pairs to apply to this resource.98 """99 return pulumi.get(self, "tags")100 @tags.setter101 def tags(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['AddonTagArgs']]]]):102 pulumi.set(self, "tags", value)103class Addon(pulumi.CustomResource):104 @overload105 def __init__(__self__,106 resource_name: str,107 opts: Optional[pulumi.ResourceOptions] = None,108 addon_name: Optional[pulumi.Input[str]] = None,109 addon_version: Optional[pulumi.Input[str]] = None,110 cluster_name: Optional[pulumi.Input[str]] = None,111 resolve_conflicts: Optional[pulumi.Input['AddonResolveConflicts']] = None,112 service_account_role_arn: Optional[pulumi.Input[str]] = None,113 tags: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['AddonTagArgs']]]]] = None,114 __props__=None):115 """116 Resource Schema for AWS::EKS::Addon117 :param str resource_name: The name of the resource.118 :param pulumi.ResourceOptions opts: Options for the resource.119 :param pulumi.Input[str] addon_name: Name of Addon120 :param pulumi.Input[str] addon_version: Version of Addon121 :param pulumi.Input[str] cluster_name: Name of Cluster122 :param pulumi.Input['AddonResolveConflicts'] resolve_conflicts: Resolve parameter value conflicts123 :param pulumi.Input[str] service_account_role_arn: IAM role to bind to the add-on's service account124 :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['AddonTagArgs']]]] tags: An array of key-value pairs to apply to this resource.125 """126 ...127 @overload128 def __init__(__self__,129 resource_name: str,130 args: AddonArgs,131 opts: Optional[pulumi.ResourceOptions] = None):132 """133 Resource Schema for AWS::EKS::Addon134 :param str resource_name: The name of the resource.135 :param AddonArgs args: The arguments to use to populate this resource's properties.136 :param pulumi.ResourceOptions opts: Options for the resource.137 """138 ...139 def __init__(__self__, resource_name: str, *args, **kwargs):140 resource_args, opts = _utilities.get_resource_args_opts(AddonArgs, pulumi.ResourceOptions, *args, **kwargs)141 if resource_args is not None:142 __self__._internal_init(resource_name, opts, **resource_args.__dict__)143 else:144 __self__._internal_init(resource_name, *args, **kwargs)145 def _internal_init(__self__,146 resource_name: str,147 opts: Optional[pulumi.ResourceOptions] = None,148 addon_name: Optional[pulumi.Input[str]] = None,149 addon_version: Optional[pulumi.Input[str]] = None,150 cluster_name: Optional[pulumi.Input[str]] = None,151 resolve_conflicts: Optional[pulumi.Input['AddonResolveConflicts']] = None,152 service_account_role_arn: Optional[pulumi.Input[str]] = None,153 tags: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['AddonTagArgs']]]]] = None,154 __props__=None):155 opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)156 if not isinstance(opts, pulumi.ResourceOptions):157 raise TypeError('Expected resource options to be a ResourceOptions instance')158 if opts.id is None:159 if __props__ is not None:160 raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')161 __props__ = AddonArgs.__new__(AddonArgs)162 __props__.__dict__["addon_name"] = addon_name163 __props__.__dict__["addon_version"] = addon_version164 if cluster_name is None and not opts.urn:165 raise TypeError("Missing required property 'cluster_name'")166 __props__.__dict__["cluster_name"] = cluster_name167 __props__.__dict__["resolve_conflicts"] = resolve_conflicts168 __props__.__dict__["service_account_role_arn"] = service_account_role_arn169 __props__.__dict__["tags"] = tags170 __props__.__dict__["arn"] = None171 super(Addon, __self__).__init__(172 'aws-native:eks:Addon',173 resource_name,174 __props__,175 opts)176 @staticmethod177 def get(resource_name: str,178 id: pulumi.Input[str],179 opts: Optional[pulumi.ResourceOptions] = None) -> 'Addon':180 """181 Get an existing Addon resource's state with the given name, id, and optional extra182 properties used to qualify the lookup.183 :param str resource_name: The unique name of the resulting resource.184 :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.185 :param pulumi.ResourceOptions opts: Options for the resource.186 """187 opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))188 __props__ = AddonArgs.__new__(AddonArgs)189 __props__.__dict__["addon_name"] = None190 __props__.__dict__["addon_version"] = None191 __props__.__dict__["arn"] = None192 __props__.__dict__["cluster_name"] = None193 __props__.__dict__["resolve_conflicts"] = None194 __props__.__dict__["service_account_role_arn"] = None195 __props__.__dict__["tags"] = None196 return Addon(resource_name, opts=opts, __props__=__props__)197 @property198 @pulumi.getter(name="addonName")199 def addon_name(self) -> pulumi.Output[str]:200 """201 Name of Addon202 """203 return pulumi.get(self, "addon_name")204 @property205 @pulumi.getter(name="addonVersion")206 def addon_version(self) -> pulumi.Output[Optional[str]]:207 """208 Version of Addon209 """210 return pulumi.get(self, "addon_version")211 @property212 @pulumi.getter213 def arn(self) -> pulumi.Output[str]:214 """215 Amazon Resource Name (ARN) of the add-on216 """217 return pulumi.get(self, "arn")218 @property219 @pulumi.getter(name="clusterName")220 def cluster_name(self) -> pulumi.Output[str]:221 """222 Name of Cluster223 """224 return pulumi.get(self, "cluster_name")225 @property226 @pulumi.getter(name="resolveConflicts")227 def resolve_conflicts(self) -> pulumi.Output[Optional['AddonResolveConflicts']]:228 """229 Resolve parameter value conflicts230 """231 return pulumi.get(self, "resolve_conflicts")232 @property233 @pulumi.getter(name="serviceAccountRoleArn")234 def service_account_role_arn(self) -> pulumi.Output[Optional[str]]:235 """236 IAM role to bind to the add-on's service account237 """238 return pulumi.get(self, "service_account_role_arn")239 @property240 @pulumi.getter241 def tags(self) -> pulumi.Output[Optional[Sequence['outputs.AddonTag']]]:...

Full Screen

Full Screen

test_supar.py

Source:test_supar.py Github

copy

Full Screen

2from src.libdamla.supar import Version, VersionRange, resolve_conflicts3import pytest4class TestResolveConflicts:5 def test_non_matching(self):6 assert resolve_conflicts(vl, vrl) == [7 Version("0.4.0"),8 Version("0.1.3"),9 Version("1.2.3"),10 ]11 def test_none_error(self):12 with pytest.raises(ValueError):13 resolve_conflicts(vl, [VersionRange("7.8")])14 def test_matching(self):15 assert resolve_conflicts(16 vl, [VersionRange("1"), VersionRange("1.2"), VersionRange(">=1, <2")]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful