Exemple #1
0
def test_custom_resource_type_create_success():
    mock = MagicMock()
    with patch(CLIENT_CONFIG, MagicMock(return_value=mock)):
        fake_type = FakeCRD.generate_crd_type()
        v1beta = k8s.extensions_client_from_config()
        expected_crd = custom_resource.CustomResourceDefinition(
            v1beta, fake_type, "default", "fake-crd")
        with patch(CUSTOM_RESOURCE, MagicMock(side_effect=[False, True])):
            result = fake_type.create("fake-crd", namespace="default")
            assert vars(result) == vars(expected_crd)
Exemple #2
0
def test_third_party_resource_type_create_success():
    mock = MagicMock()
    with patch(K8S_EXTENSIONS_CLIENT, MagicMock(return_value=mock)):
        fake_type = FakeTPR.generate_tpr_type()
        v1beta = k8s.extensions_client_from_config()
        expected_tpr = third_party.ThirdPartyResource(v1beta, fake_type,
                                                      "default", "fake-tpr")
        with patch('intel.third_party.ThirdPartyResourceType.exists',
                   MagicMock(side_effect=[False, True])):
            result = fake_type.create("fake-tpr", namespace="default")
            assert vars(result) == vars(expected_tpr)
Exemple #3
0
 def generate_crd():
     v1beta = k8s.extensions_client_from_config()
     fake_type = FakeCRD.generate_crd_type()
     fake_crd = custom_resource.CustomResourceDefinition(
         v1beta, fake_type, "default", "fake-crd")
     return fake_crd
Exemple #4
0
 def generate_crd_type():
     v1beta = k8s.extensions_client_from_config()
     fake_type = custom_resource.CustomResourceDefinitionType(
         v1beta, "fake_url", "fake_name", ["fake"])
     return fake_type
Exemple #5
0
 def generate_tpr():
     v1beta = k8s.extensions_client_from_config()
     fake_type = FakeTPR.generate_tpr_type()
     return third_party.ThirdPartyResource(v1beta, fake_type, "default",
                                           "fake-tpr")
Exemple #6
0
 def generate_tpr_type():
     v1beta = k8s.extensions_client_from_config()
     return third_party.ThirdPartyResourceType(v1beta, "fake_url",
                                               "fake_name", "v1")