# Path: k8s/client.py
# class NotFound(K8sClientException):
#     """The resource was not found, and the operation could not be completed"""
# 
# Path: k8s/models/common.py
# class ObjectMeta(Model):
#     annotations = Field(dict)
#     creationTimestamp = ReadOnlyField(datetime.datetime)
#     deletionGracePeriodSeconds = ReadOnlyField(int)
#     deletionTimestamp = ReadOnlyField(datetime.datetime)
#     finalizers = ListField(six.text_type)
#     generateName = Field(six.text_type)
#     generation = ReadOnlyField(int)
#     labels = Field(dict)
#     name = Field(six.text_type)
#     namespace = Field(six.text_type, "default")
#     ownerReferences = ListField(OwnerReference)
#     resourceVersion = ReadOnlyField(six.text_type)
#     selfLink = ReadOnlyField(six.text_type)
#     uid = ReadOnlyField(six.text_type)
# 
# Path: k8s/models/resourcequota.py
# class ResourceQuotaSpec(Model):
# class ResourceQuotaStatus(Model):
# class ResourceQuota(Model):
#     class Meta:


import mock
import pytest
from k8s.client import NotFound
from k8s.models.common import ObjectMeta
from k8s.models.resourcequota import ResourceQuota, ResourceQuotaSpec, NotBestEffort, BestEffort
    def test_created_if_not_exists(self, post, api_get):
        api_get.side_effect = NotFound()
        resourcequota = _create_default_resourcequota()
        call_params = resourcequota.as_dict()
        post.return_value.json.return_value = call_params

        assert resourcequota._new
        resourcequota.save()
        assert not resourcequota._new

        pytest.helpers.assert_any_call(post, _uri(NAMESPACE), call_params)

    def test_updated_if_exists(self, get, put):
        mock_response = _create_mock_response()
        get.return_value = mock_response
        resourcequota = _create_default_resourcequota()

        from_api = ResourceQuota.get_or_create(metadata=resourcequota.metadata, spec=resourcequota.spec)
        assert not from_api._new
        assert from_api.spec == resourcequota.spec
        assert from_api.status == resourcequota.status

        from_api.spec = ResourceQuotaSpec(hard={'pods': "10"}, scopes=[BestEffort])
        call_params = from_api.as_dict()
        put.return_value.json.return_value = call_params

        from_api.save()
        pytest.helpers.assert_any_call(put, _uri(NAMESPACE, NAME), call_params)

    def test_deleted(self, delete):

# Path: k8s/client.py
# class NotFound(K8sClientException):
#     """The resource was not found, and the operation could not be completed"""
# 
# Path: k8s/models/common.py
# class ObjectMeta(Model):
#     annotations = Field(dict)
#     creationTimestamp = ReadOnlyField(datetime.datetime)
#     deletionGracePeriodSeconds = ReadOnlyField(int)
#     deletionTimestamp = ReadOnlyField(datetime.datetime)
#     finalizers = ListField(six.text_type)
#     generateName = Field(six.text_type)
#     generation = ReadOnlyField(int)
#     labels = Field(dict)
#     name = Field(six.text_type)
#     namespace = Field(six.text_type, "default")
#     ownerReferences = ListField(OwnerReference)
#     resourceVersion = ReadOnlyField(six.text_type)
#     selfLink = ReadOnlyField(six.text_type)
#     uid = ReadOnlyField(six.text_type)
# 
# Path: k8s/models/resourcequota.py
# class ResourceQuotaSpec(Model):
# class ResourceQuotaStatus(Model):
# class ResourceQuota(Model):
#     class Meta:


# Path: tests/k8s/test_resourcequota.py
import mock
import pytest
from k8s.client import NotFound
from k8s.models.common import ObjectMeta
from k8s.models.resourcequota import ResourceQuota, ResourceQuotaSpec, NotBestEffort, BestEffort

    def test_created_if_not_exists(self, post, api_get):
        api_get.side_effect = NotFound()
        resourcequota = _create_default_resourcequota()
        call_params = resourcequota.as_dict()
        post.return_value.json.return_value = call_params

        assert resourcequota._new
        resourcequota.save()
        assert not resourcequota._new

        pytest.helpers.assert_any_call(post, _uri(NAMESPACE), call_params)

    def test_updated_if_exists(self, get, put):
        mock_response = _create_mock_response()
        get.return_value = mock_response
        resourcequota = _create_default_resourcequota()

        from_api = ResourceQuota.get_or_create(metadata=resourcequota.metadata, spec=resourcequota.spec)
        assert not from_api._new
        assert from_api.spec == resourcequota.spec
        assert from_api.status == resourcequota.status

        from_api.spec = ResourceQuotaSpec(hard={'pods': "10"}, scopes=[BestEffort])
        call_params = from_api.as_dict()
        put.return_value.json.return_value = call_params

        from_api.save()
        pytest.helpers.assert_any_call(put, _uri(NAMESPACE, NAME), call_params)

    def test_deleted(self, delete):

        ResourceQuota.delete(NAME, namespace=NAMESPACE)