# Path: pyeqs/dsl/terms.py
# class Terms(dict):
# 
#     def __init__(self, field_name, terms, execution=None):
#         super(Terms, self).__init__()
#         self.field_name = field_name
#         self.terms = terms
#         self.execution = execution
#         self["terms"] = self._build_dict()
# 
#     def _build_dict(self):
#         terms = {
#             self.field_name: self.terms
#         }
#         if self.execution is not None:
#             terms["execution"] = self.execution
#         return terms
# 
# Path: tests/helpers.py
# def homogeneous(a, b):
#     json.dumps(a, sort_keys=True).should.equal(json.dumps(b, sort_keys=True))


from pyeqs.dsl import Terms
from tests.helpers import homogeneous
    """
    # When add a Terms field
    t = Terms("foo", ["bar", "baz"])

    # Then I see the appropriate JSON
    results = {
        "terms": {
            "foo": ["bar", "baz"]
        }
    }

    homogeneous(t, results)


def test_add_terms_with_execution():
    """
    Create Terms With Execution
    """
    # When add a Terms field
    t = Terms("foo", ["bar", "baz"], execution="and")

    # Then I see the appropriate JSON
    results = {
        "terms": {
            "foo": ["bar", "baz"],
            "execution": "and"

        }
    }


# Path: pyeqs/dsl/terms.py
# class Terms(dict):
# 
#     def __init__(self, field_name, terms, execution=None):
#         super(Terms, self).__init__()
#         self.field_name = field_name
#         self.terms = terms
#         self.execution = execution
#         self["terms"] = self._build_dict()
# 
#     def _build_dict(self):
#         terms = {
#             self.field_name: self.terms
#         }
#         if self.execution is not None:
#             terms["execution"] = self.execution
#         return terms
# 
# Path: tests/helpers.py
# def homogeneous(a, b):
#     json.dumps(a, sort_keys=True).should.equal(json.dumps(b, sort_keys=True))


# Path: tests/unit/test_terms.py
from pyeqs.dsl import Terms
from tests.helpers import homogeneous

    """
    # When add a Terms field
    t = Terms("foo", ["bar", "baz"])

    # Then I see the appropriate JSON
    results = {
        "terms": {
            "foo": ["bar", "baz"]
        }
    }

    homogeneous(t, results)


def test_add_terms_with_execution():
    """
    Create Terms With Execution
    """
    # When add a Terms field
    t = Terms("foo", ["bar", "baz"], execution="and")

    # Then I see the appropriate JSON
    results = {
        "terms": {
            "foo": ["bar", "baz"],
            "execution": "and"

        }
    }


    homogeneous(t, results)