# Path: k8s/base.py
# LOG = logging.getLogger(__name__)
#     ADDED = "ADDED"
#     MODIFIED = "MODIFIED"
#     DELETED = "DELETED"
# class MetaModel(type):
# class ApiMixIn(object):
# class Model(six.with_metaclass(MetaModel)):
# class WatchEvent(object):
# class LabelSelector(object):
# class Equality(LabelSelector):
# class Inequality(LabelSelector):
# class LabelSetSelector(LabelSelector):
# class In(LabelSetSelector):
# class NotIn(LabelSetSelector):
# class Exists(LabelSelector):
# class SelfModel:
#     def __new__(mcs, cls, bases, attrs):
#     def _build_url(cls, **kwargs):
#     def find(cls, name="", namespace="default", labels=None):
#     def list(cls, namespace="default"):
#     def watch_list(cls, namespace=None):
#     def get(cls, name, namespace="default"):
#     def get_or_create(cls, **kwargs):
#     def delete(cls, name, namespace="default", **kwargs):
#     def delete_list(cls, namespace="default", labels=None, delete_options=None, **kwargs):
#     def save(self):
#     def _label_selector(labels):
#     def __init__(self, new=True, **kwargs):
#     def _validate_fields(self):
#     def as_dict(self):
#     def merge(self, other):
#     def update_from_dict(self, d):
#     def from_dict(cls, d):
#     def __repr__(self):
#     def __eq__(self, other):
# def _api_name(name):
#     def __init__(self, event_json, cls):
#     def __repr__(self):
#     def __init__(self, value=""):
#     def __str__(self):
#     def __str__(self):
#     def __init__(self):
#     def __str__(self):
# 
# Path: k8s/models/common.py
# class DeleteOptions(Model):
#     apiVersion = Field(six.text_type)
#     dryRun = ListField(six.text_type)
#     gracePeriodSeconds = Field(int)
#     kind = Field(six.text_type)
#     preconditions = Field(Preconditions)
#     propagationPolicy = Field(six.text_type)
# 
# class Preconditions(Model):
#     resourceVersion = Field(six.text_type)
#     uid = Field(six.text_type)


import mock
import pytest
from k8s.base import Model, Field, WatchEvent, Equality, Inequality, In, NotIn, Exists
from k8s.models.common import DeleteOptions, Preconditions
        watch_event = WatchEvent({"type": "DELETED", "object": {"value": 42}}, Example)
        assert watch_event.type == WatchEvent.DELETED
        assert watch_event.object == Example(value=42)


class TestFind(object):
    @pytest.fixture
    def client(self):
        with mock.patch.object(Example, "_client") as m:
            yield m

    def test_find_by_name(self, client):
        Example.find("app_name")
        client.get.assert_called_once_with("/example", params={"labelSelector": "app=app_name"})

    @pytest.mark.parametrize("value, selector", (
        (Equality("my_value"), "my_key=my_value"),
        (Inequality("my_value"), "my_key!=my_value"),
        (In(("value1", "value2")), "my_key in (value1,value2)"),
        (NotIn(("value1", "value2")), "my_key notin (value1,value2)"),
        (Exists(), "my_key"),
        ("my_unwrapped_value", "my_key=my_unwrapped_value"),
    ))
    def test_find_by_selectors(self, client, value, selector):
        Example.find(labels={"my_key": value})
        client.get.assert_called_once_with("/example", params={"labelSelector": selector})

    def test_repeated_keys_in_label_selector(self, client):
        labels = [
            ("foo", Inequality("bar")),

# Path: k8s/base.py
# LOG = logging.getLogger(__name__)
#     ADDED = "ADDED"
#     MODIFIED = "MODIFIED"
#     DELETED = "DELETED"
# class MetaModel(type):
# class ApiMixIn(object):
# class Model(six.with_metaclass(MetaModel)):
# class WatchEvent(object):
# class LabelSelector(object):
# class Equality(LabelSelector):
# class Inequality(LabelSelector):
# class LabelSetSelector(LabelSelector):
# class In(LabelSetSelector):
# class NotIn(LabelSetSelector):
# class Exists(LabelSelector):
# class SelfModel:
#     def __new__(mcs, cls, bases, attrs):
#     def _build_url(cls, **kwargs):
#     def find(cls, name="", namespace="default", labels=None):
#     def list(cls, namespace="default"):
#     def watch_list(cls, namespace=None):
#     def get(cls, name, namespace="default"):
#     def get_or_create(cls, **kwargs):
#     def delete(cls, name, namespace="default", **kwargs):
#     def delete_list(cls, namespace="default", labels=None, delete_options=None, **kwargs):
#     def save(self):
#     def _label_selector(labels):
#     def __init__(self, new=True, **kwargs):
#     def _validate_fields(self):
#     def as_dict(self):
#     def merge(self, other):
#     def update_from_dict(self, d):
#     def from_dict(cls, d):
#     def __repr__(self):
#     def __eq__(self, other):
# def _api_name(name):
#     def __init__(self, event_json, cls):
#     def __repr__(self):
#     def __init__(self, value=""):
#     def __str__(self):
#     def __str__(self):
#     def __init__(self):
#     def __str__(self):
# 
# Path: k8s/models/common.py
# class DeleteOptions(Model):
#     apiVersion = Field(six.text_type)
#     dryRun = ListField(six.text_type)
#     gracePeriodSeconds = Field(int)
#     kind = Field(six.text_type)
#     preconditions = Field(Preconditions)
#     propagationPolicy = Field(six.text_type)
# 
# class Preconditions(Model):
#     resourceVersion = Field(six.text_type)
#     uid = Field(six.text_type)


# Path: tests/k8s/test_base.py
import mock
import pytest
from k8s.base import Model, Field, WatchEvent, Equality, Inequality, In, NotIn, Exists
from k8s.models.common import DeleteOptions, Preconditions

        watch_event = WatchEvent({"type": "DELETED", "object": {"value": 42}}, Example)
        assert watch_event.type == WatchEvent.DELETED
        assert watch_event.object == Example(value=42)


class TestFind(object):
    @pytest.fixture
    def client(self):
        with mock.patch.object(Example, "_client") as m:
            yield m

    def test_find_by_name(self, client):
        Example.find("app_name")
        client.get.assert_called_once_with("/example", params={"labelSelector": "app=app_name"})

    @pytest.mark.parametrize("value, selector", (
        (Equality("my_value"), "my_key=my_value"),
        (Inequality("my_value"), "my_key!=my_value"),
        (In(("value1", "value2")), "my_key in (value1,value2)"),
        (NotIn(("value1", "value2")), "my_key notin (value1,value2)"),
        (Exists(), "my_key"),
        ("my_unwrapped_value", "my_key=my_unwrapped_value"),
    ))
    def test_find_by_selectors(self, client, value, selector):
        Example.find(labels={"my_key": value})
        client.get.assert_called_once_with("/example", params={"labelSelector": selector})

    def test_repeated_keys_in_label_selector(self, client):
        labels = [
            ("foo", Inequality("bar")),

            ("foo", Exists())