Exemplo n.º 1
0
 def test_make_body_complex(self):
     service_levels = [ServiceLevelEnum.BASIC, ServiceLevelEnum.BRONZE]
     param = {
         'a': 1,
         'b': UnityLun(_id='lun1'),
         'c': UnityLunList(cli=t_rest()),
         'd': [UnityLun(_id='lun10'),
               UnityLun(_id='lun11'), 0.1],
         'e': {
             'f': UnityLun(_id='lun12')
         },
         'g': 'string',
         'h': 0.2,
         'i': service_levels,
         'j': ServiceLevelEnumList.parse(service_levels)
     }
     ret = UnityClient.make_body(param)
     expected = {
         'a':
         1,
         'b': {
             'id': 'lun1'
         },
         'c': [{
             'id': 'sv_2'
         }, {
             'id': 'sv_3'
         }, {
             'id': 'sv_5'
         }, {
             'id': 'sv_6'
         }, {
             'id': 'sv_7'
         }],
         'd': [{
             'id': 'lun10'
         }, {
             'id': 'lun11'
         }, 0.1],
         'e': {
             'f': {
                 'id': 'lun12'
             }
         },
         'g':
         'string',
         'h':
         0.2,
         'i': [0, 1],
         'j': [0, 1]
     }
     assert_that(ret, equal_to(expected))
Exemplo n.º 2
0
    def test_get_capability_profile_service_levels(self):
        unity = t_unity()
        level_s = ServiceLevelEnum.SILVER
        level_p = ServiceLevelEnum.PLATINUM
        cp = unity.get_capability_profile(service_levels=[level_s, level_p])
        assert_that(cp, instance_of(UnityCapabilityProfileList))
        assert_that(len(cp), 2)

        # use Enum or EnumList are both ok
        cp2 = unity.get_capability_profile(service_levels=level_s)
        assert_that(cp2, instance_of(UnityCapabilityProfileList))
        assert_that(len(cp2), 1)
        assert_that(cp2[0].existed, equal_to(True))

        level_enum_list = ServiceLevelEnumList.parse([level_s, level_p])
        assert_that(level_enum_list, instance_of(ServiceLevelEnumList))
        cp3 = unity.get_capability_profile(service_levels=level_enum_list)
        assert_that(cp3, instance_of(UnityCapabilityProfileList))
        assert_that(len(cp3), 2)
        assert_that(cp3[0].existed, equal_to(True))
Exemplo n.º 3
0
    def test_get_capability_profile_service_levels(self):
        unity = t_unity()
        level_s = ServiceLevelEnum.SILVER
        level_p = ServiceLevelEnum.PLATINUM
        cp = unity.get_capability_profile(service_levels=[level_s, level_p])
        assert_that(cp, instance_of(UnityCapabilityProfileList))
        assert_that(len(cp), 2)

        # use Enum or EnumList are both ok
        cp2 = unity.get_capability_profile(service_levels=level_s)
        assert_that(cp2, instance_of(UnityCapabilityProfileList))
        assert_that(len(cp2), 1)
        assert_that(cp2[0].existed, equal_to(True))

        level_enum_list = ServiceLevelEnumList.parse([level_s, level_p])
        assert_that(level_enum_list, instance_of(ServiceLevelEnumList))
        cp3 = unity.get_capability_profile(service_levels=level_enum_list)
        assert_that(cp3, instance_of(UnityCapabilityProfileList))
        assert_that(len(cp3), 2)
        assert_that(cp3[0].existed, equal_to(True))
Exemplo n.º 4
0
 def test_make_body_complex(self):
     service_levels = [ServiceLevelEnum.BASIC, ServiceLevelEnum.BRONZE]
     param = {
         'a': 1,
         'b': UnityLun(_id='lun1'),
         'c': UnityLunList(cli=t_rest()),
         'd': [UnityLun(_id='lun10'), UnityLun(_id='lun11'), 0.1],
         'e': {'f': UnityLun(_id='lun12')},
         'g': 'string',
         'h': 0.2,
         'i': service_levels,
         'j': ServiceLevelEnumList.parse(service_levels)
     }
     ret = UnityClient.make_body(param)
     expected = {'a': 1,
                 'b': {'id': 'lun1'},
                 'c': [{'id': 'sv_2'}, {'id': 'sv_3'},
                       {'id': 'sv_5'}, {'id': 'sv_6'},
                       {'id': 'sv_7'}],
                 'd': [{'id': 'lun10'}, {'id': 'lun11'}, 0.1],
                 'e': {'f': {'id': 'lun12'}},
                 'g': 'string', 'h': 0.2, 'i': [0, 1], 'j': [0, 1]}
     assert_that(ret, equal_to(expected))