@@ -882,6 +882,7 @@ def test_patch_cross_stack_policy(monkeypatch):
882
882
883
883
assert definition == test_case ["expected_output" ]
884
884
885
+
885
886
def test_patch_cross_stack_policy_errors ():
886
887
# Error case 1 :: Instance profile not in Resources
887
888
with pytest .raises (click .UsageError ):
@@ -932,3 +933,48 @@ def test_patch_cross_stack_policy_errors():
932
933
}}
933
934
934
935
patch_cross_stack_policy (definition , elastigroup_config )
936
+
937
+
938
+ def test_multiple_elastigroups (monkeypatch ):
939
+ config1 = {
940
+ "Name" : "eg1" ,
941
+ "SecurityGroups" : "sg1" ,
942
+ "InstanceType" : "big" ,
943
+ "SpotAlternatives" : [
944
+ "smaller" ,
945
+ "small" ,
946
+ "small-ish"
947
+ ]
948
+ }
949
+ config2 = {
950
+ "Name" : "eg2" ,
951
+ "SecurityGroups" : "sg1" ,
952
+ "InstanceType" : "big" ,
953
+ "SpotAlternatives" : [
954
+ "smaller" ,
955
+ "small" ,
956
+ "small-ish"
957
+ ]
958
+ }
959
+ args = MagicMock ()
960
+ args .region = "reg1"
961
+ info = {'StackName' : 'foobar' , 'StackVersion' : '0.1' , 'SpotinstAccessToken' : 'token1' }
962
+ subnets = ["sn1" , "sn2" , "sn3" ]
963
+ server_subnets = {"reg1" : {"Subnets" : subnets }}
964
+ senza = {"Info" : info }
965
+ mappings = {"Senza" : senza , "ServerSubnets" : server_subnets }
966
+ definition = {"Resources" : {}, "Mappings" : mappings }
967
+ mock_sg = MagicMock ()
968
+ mock_sg .return_value = "sg1"
969
+ monkeypatch .setattr ('senza.aws.resolve_security_group' , mock_sg )
970
+
971
+ mock_resolve_account_id = MagicMock ()
972
+ mock_resolve_account_id .return_value = 'act-12345abcdef'
973
+ monkeypatch .setattr ('senza.components.elastigroup.resolve_account_id' , mock_resolve_account_id )
974
+
975
+ mock_account_info = MagicMock ()
976
+ mock_account_info .Region = "reg1"
977
+ mock_account_info .AccountID = "12345"
978
+
979
+ component_elastigroup (definition , config1 , args , info , False , mock_account_info )
980
+ component_elastigroup (definition , config2 , args , info , False , mock_account_info )
0 commit comments