Skip to content

Commit b6e4060

Browse files
author
Christine WANJAU
committed
update tests
1 parent 359e19e commit b6e4060

File tree

7 files changed

+93
-65
lines changed

7 files changed

+93
-65
lines changed

src/azure-cli/azure/cli/command_modules/appconfig/_featuremodels.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ class FeatureUserAllocation:
283283
:ivar list Users:
284284
Collection of users where if any match the current user, the variant specified in the user allocation is used.
285285
'''
286+
286287
def __init__(self,
287288
variant,
288289
users):
@@ -477,7 +478,7 @@ def convert_from_json(cls, json_string):
477478
if allocation_user:
478479
allocation_user_list = []
479480
for user in allocation_user:
480-
feature_user_allocation = FeatureUserAllocation.convert_from_json(json.dumps(user))
481+
feature_user_allocation = FeatureUserAllocation.convert_from_json(json.dumps(user, ensure_ascii=False))
481482
if (feature_user_allocation):
482483
allocation_user_list.append(feature_user_allocation)
483484

@@ -488,7 +489,7 @@ def convert_from_json(cls, json_string):
488489
if allocation_group:
489490
allocation_group_list = []
490491
for group in allocation_group:
491-
feature_group_allocation = FeatureGroupAllocation.convert_from_json(json.dumps(group))
492+
feature_group_allocation = FeatureGroupAllocation.convert_from_json(json.dumps(group, ensure_ascii=False))
492493
if (feature_group_allocation):
493494
allocation_group_list.append(feature_group_allocation)
494495

@@ -499,7 +500,7 @@ def convert_from_json(cls, json_string):
499500
if allocation_percentile:
500501
allocation_percentile_list = []
501502
for percentile in allocation_percentile:
502-
feature_percentile_allocation = FeaturePercentileAllocation.convert_from_json(json.dumps(percentile))
503+
feature_percentile_allocation = FeaturePercentileAllocation.convert_from_json(json.dumps(percentile, ensure_ascii=False))
503504
if (feature_percentile_allocation):
504505
allocation_percentile_list.append(feature_percentile_allocation)
505506

@@ -752,10 +753,7 @@ def map_keyvalue_to_featureflagvalue(keyvalue):
752753
FeatureFlagConstants.ID,
753754
FeatureFlagConstants.DESCRIPTION,
754755
FeatureFlagConstants.ENABLED,
755-
FeatureFlagConstants.CONDITIONS,
756-
FeatureFlagConstants.ALLOCATION,
757-
FeatureFlagConstants.VARIANTS,
758-
FeatureFlagConstants.TELEMETRY}
756+
FeatureFlagConstants.CONDITIONS}
759757
if valid_fields != feature_flag_dict.keys():
760758
logger.debug("'%s' feature flag is missing required values or it contains ", keyvalue.key +
761759
"unsupported values. Setting missing value to defaults and ignoring unsupported values\n")
@@ -795,14 +793,14 @@ def map_keyvalue_to_featureflagvalue(keyvalue):
795793
# Allocation
796794
allocation = feature_flag_dict.get(FeatureFlagConstants.ALLOCATION, None)
797795
if allocation:
798-
feature_flag_dict[FeatureFlagConstants.ALLOCATION] = FeatureAllocation.convert_from_json(json.dumps(allocation))
796+
feature_flag_dict[FeatureFlagConstants.ALLOCATION] = FeatureAllocation.convert_from_json(json.dumps(allocation, ensure_ascii=False))
799797

800798
# Variants
801799
variants = feature_flag_dict.get(FeatureFlagConstants.VARIANTS, None)
802800
variant_list = []
803801
if variants:
804802
for variant in variants:
805-
feature_variant = FeatureVariant.convert_from_json(json.dumps(variant))
803+
feature_variant = FeatureVariant.convert_from_json(json.dumps(variant, ensure_ascii=False))
806804
if (feature_variant):
807805
variant_list.append(feature_variant)
808806

src/azure-cli/azure/cli/command_modules/appconfig/_kv_import_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ def __read_features_from_msfm_schema(feature_flags_list):
242242
new_feature.conditions[FeatureFlagConstants.REQUIREMENT_TYPE] = requirement_type
243243

244244
if allocation := feature.get(FeatureFlagConstants.ALLOCATION, None):
245-
new_feature.allocation = FeatureAllocation.convert_from_json(json.dumps(allocation))
245+
new_feature.allocation = FeatureAllocation.convert_from_json(json.dumps(allocation, ensure_ascii=False))
246246

247247
if variants := feature.get(FeatureFlagConstants.VARIANTS, None):
248248
new_feature.variants = []
249249
for variant in variants:
250-
new_variant = FeatureVariant.convert_from_json(json.dumps(variant))
250+
new_variant = FeatureVariant.convert_from_json(json.dumps(variant, ensure_ascii=False))
251251
if new_variant:
252252
new_feature.variants.append(new_variant)
253253

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
feature_management:
22
feature_flags:
3-
- id: Variant_Override_True
4-
description: ''
5-
enabled: true
6-
conditions:
7-
client_filters: []
8-
allocation:
9-
default_when_enabled: True_Override
10-
variants:
11-
- name: True_Override
12-
status_override: Disabled
13-
configuration_value: default
14-
- id: Variant_Override_False
15-
description: ''
16-
enabled: false
17-
conditions:
18-
client_filters: []
19-
allocation:
20-
default_when_disabled: False_Override
21-
variants:
22-
- name: False_Override
23-
status_override: Enabled
24-
configuration_value: default
25-
- id: TestVariants
26-
description: ''
27-
enabled: true
28-
conditions:
29-
client_filters:
30-
- Name: TimeWindow
31-
Parameters:
32-
Start: 'Wed, 01 May 2019 13:59:59 GMT'
33-
End: 'Mon, 01 July 2019 00:00:00 GMT'
34-
allocation:
35-
user:
36-
- variant: Alpha
37-
users:
38-
- Adam
39-
- variant: Beta
40-
users:
41-
- Britney
42-
variants:
43-
- name: Alpha
44-
configuration_value: The Variant Alpha.
45-
- name: Beta
46-
configuration_value: The Variant Beta.
3+
- id: TestVariants
4+
description: ''
5+
enabled: true
6+
conditions:
7+
client_filters:
8+
- name: TimeWindow
9+
parameters:
10+
Start: Wed, 01 May 2019 13:59:59 GMT
11+
End: Mon, 01 July 2019 00:00:00 GMT
12+
allocation:
13+
user:
14+
- variant: Alpha
15+
users:
16+
- Adam
17+
- variant: Beta
18+
users:
19+
- Britney
20+
variants:
21+
- name: Alpha
22+
configuration_value: The Variant Alpha.
23+
- name: Beta
24+
configuration_value: The Variant Beta.
25+
- id: Variant_Override_False
26+
description: ''
27+
enabled: false
28+
conditions:
29+
client_filters: []
30+
allocation:
31+
default_when_disabled: False_Override
32+
variants:
33+
- name: False_Override
34+
configuration_value: default
35+
status_override: Enabled
36+
- id: Variant_Override_True
37+
description: ''
38+
enabled: true
39+
conditions:
40+
client_filters: []
41+
allocation:
42+
default_when_enabled: True_Override
43+
variants:
44+
- name: True_Override
45+
configuration_value: default
46+
status_override: Disabled

src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/respectBothFmSchemaHyphenCase.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
{
22
"feature-management": {
3-
"FeatureX": true,
3+
"FeatureX": {
4+
"enabled-for": [
5+
{
6+
"Name": "TimeWindow",
7+
"Parameters": {
8+
"Start": "Wed, 01 May 2019 13:59:59 GMT",
9+
"End": "Mon, 01 July 2019 00:00:00 GMT"
10+
}
11+
}
12+
]
13+
},
414
"FeatureY": true
515
},
616
"feature_management": {

src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/respectBothFmSchemaPascalCase.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
{
22
"FeatureManagement": {
3-
"FeatureX": true,
3+
"FeatureX": {
4+
"EnabledFor": [
5+
{
6+
"Name": "TimeWindow",
7+
"Parameters": {
8+
"Start": "Wed, 01 May 2019 13:59:59 GMT",
9+
"End": "Mon, 01 July 2019 00:00:00 GMT"
10+
}
11+
}
12+
]
13+
},
414
"FeatureY": true
515
},
616
"feature_management": {

src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/respectBothFmSchemaUnderscoreCase.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@
1010
"enabled": false
1111
}
1212
],
13-
"FeatureX": true,
14-
"FeatureY": true
13+
"FeatureX": {
14+
"enabled_for": [
15+
{
16+
"Name": "TimeWindow",
17+
"Parameters": {
18+
"Start": "Wed, 01 May 2019 13:59:59 GMT",
19+
"End": "Mon, 01 July 2019 00:00:00 GMT"
20+
}
21+
}
22+
]
23+
},
24+
"FeatureY": true
1525
}
1626
}

src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/test_appconfig_commands.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ def test_azconfig_import_export_naming_conventions(self, resource_group, locatio
14831483
# Respect both fm schemas in file
14841484
# # Camel case naming convention
14851485
os.environ['AZURE_APPCONFIG_FM_COMPATIBILITY_MODE'] = 'False'
1486-
1486+
14871487
imported_both_schemas_camel_case_file_path = os.path.join(TEST_DIR, 'respectBothFmSchemaCamelCase.json')
14881488
exported_both_schemas_camel_case_file_path = os.path.join(TEST_DIR, 'export_features_both_schema_camel_case_file_path.json')
14891489
expected_exported_both_schemas_file_path = os.path.join(TEST_DIR, 'expected_export_features_both_schema_file_path.json')
@@ -1548,7 +1548,7 @@ def test_azconfig_import_export_naming_conventions(self, resource_group, locatio
15481548
with open(expected_exported_both_schemas_file_path) as json_file:
15491549
exported_kvs = json.load(json_file)
15501550
assert exported_hyphen_case_kvs == exported_kvs
1551-
os.remove(exported_both_schemas_pascal_case_file_path)
1551+
os.remove(exported_both_schemas_hyphen_case_file_path)
15521552

15531553

15541554
# # Underscore case naming convention
@@ -1565,13 +1565,13 @@ def test_azconfig_import_export_naming_conventions(self, resource_group, locatio
15651565
self.cmd(
15661566
'appconfig kv import -n {config_store_name} -s {import_source} --path "{imported_file_both_schemas_fm_path}" --format {imported_format} --label {label} -y')
15671567
self.cmd(
1568-
'appconfig kv export -n {config_store_name} -d {import_source} --path "{exported_file_both_schemas_fm_path}" --format {imported_format} --naming-convention {naming_convention} --label {label} -y')
1568+
'appconfig kv export -n {config_store_name} -d {import_source} --path "{exported_file_both_schemas_fm_path}" --format {imported_format} --label {label} -y')
15691569
with open(exported_both_schemas_underscore_case_file_path) as json_file:
15701570
exported_underscore_case_kvs = json.load(json_file)
15711571
with open(expected_exported_both_schemas_file_path) as json_file:
15721572
exported_kvs = json.load(json_file)
15731573
assert exported_underscore_case_kvs == exported_kvs
1574-
os.remove(exported_both_schemas_pascal_case_file_path)
1574+
os.remove(exported_both_schemas_underscore_case_file_path)
15751575

15761576
# Import/Export new fm yaml file
15771577
os.environ['AZURE_APPCONFIG_FM_COMPATIBILITY_MODE'] = 'False'
@@ -1580,7 +1580,7 @@ def test_azconfig_import_export_naming_conventions(self, resource_group, locatio
15801580
exported_new_fm_schema_as_yaml_file_path = os.path.join(TEST_DIR, 'export_features_new_fm_schema_as_yaml.json')
15811581

15821582
self.kwargs.update({
1583-
'label': 'YamlTests',
1583+
'label': 'NewFmSchemaYamlTests',
15841584
'imported_format': 'yaml',
15851585
'naming_convention': 'hyphen',
15861586
'imported_ffv2_file_path': imported_new_fm_schema_yaml_file_path,
@@ -1607,7 +1607,7 @@ def test_azconfig_import_export_naming_conventions(self, resource_group, locatio
16071607
exported_as_kv_prop_file_path = os.path.join(TEST_DIR, 'export_as_kv_prop.json')
16081608

16091609
self.kwargs.update({
1610-
'label': 'PropertiesTests',
1610+
'label': 'NewFmSchemaPropertiesTests',
16111611
'imported_format': 'properties',
16121612
'imported_file_path': imported_prop_file_path,
16131613
'exported_file_path': exported_prop_file_path

0 commit comments

Comments
 (0)