# Path: pypd/models/escalation_policy.py
# class EscalationPolicy(Entity):
#     """PagerDuty escalation policy entity."""
# 
#     STR_OUTPUT_FIELDS = ('id', 'name',)
#     TRANSLATE_QUERY_PARAM = ('name',)
# 
#     def services(self):
#         """Fetch all instances of services for this EP."""
#         ids = [ref['id'] for ref in self['services']]
#         return [Service.fetch(id) for id in ids]
# 
#     def update(self, *args, **kwargs):
#         """Update this escalation policy."""
#         raise NotImplemented


import re
import json
import unittest
import os.path
import requests_mock
    from urllib import urlencode
    from urllib.parse import urlencode
from operator import itemgetter
from pypd import EscalationPolicy

        for ep in eps:
            # ensure that there is a name field shown for stringified version
            for field in EscalationPolicy.STR_OUTPUT_FIELDS:
                matches = re.findall(r'%s=\"(.+?)\"' % field, str(ep))
                self.assertEqual(matches[0], ep[field])

            matches = re.findall(r'id=\"(.+?)\"', str(ep))
            self.assertEqual(matches[0], ep['id'])

    @requests_mock.Mocker()
    def test_translate_query_params(self, m):
        name = 'Alexis demo EP'
        query = {
            'query': name,
            'limit': self.query_datas[0]['limit'],
            'offset': self.query_datas[0]['offset'],
        }
        url = self.url + '?%s' % urlencode(query)

        # filter the dataset to only include eps with "Alexis" in it
        filtered = list(filter(
            lambda d: d['name'].count('Alexis'),
            self.query_datas[0]['escalation_policies']
        ))
        data = self.query_datas[0].copy()
        data['escalation_policies'] = filtered
        m.register_uri('GET', url, json=data, complete_qs=True)

        # query for the eps

# Path: pypd/models/escalation_policy.py
# class EscalationPolicy(Entity):
#     """PagerDuty escalation policy entity."""
# 
#     STR_OUTPUT_FIELDS = ('id', 'name',)
#     TRANSLATE_QUERY_PARAM = ('name',)
# 
#     def services(self):
#         """Fetch all instances of services for this EP."""
#         ids = [ref['id'] for ref in self['services']]
#         return [Service.fetch(id) for id in ids]
# 
#     def update(self, *args, **kwargs):
#         """Update this escalation policy."""
#         raise NotImplemented


# Path: test/unit/models/escalation_policy.py
import re
import json
import unittest
import os.path
import requests_mock
    from urllib import urlencode
    from urllib.parse import urlencode
from operator import itemgetter
from pypd import EscalationPolicy


        for ep in eps:
            # ensure that there is a name field shown for stringified version
            for field in EscalationPolicy.STR_OUTPUT_FIELDS:
                matches = re.findall(r'%s=\"(.+?)\"' % field, str(ep))
                self.assertEqual(matches[0], ep[field])

            matches = re.findall(r'id=\"(.+?)\"', str(ep))
            self.assertEqual(matches[0], ep['id'])

    @requests_mock.Mocker()
    def test_translate_query_params(self, m):
        name = 'Alexis demo EP'
        query = {
            'query': name,
            'limit': self.query_datas[0]['limit'],
            'offset': self.query_datas[0]['offset'],
        }
        url = self.url + '?%s' % urlencode(query)

        # filter the dataset to only include eps with "Alexis" in it
        filtered = list(filter(
            lambda d: d['name'].count('Alexis'),
            self.query_datas[0]['escalation_policies']
        ))
        data = self.query_datas[0].copy()
        data['escalation_policies'] = filtered
        m.register_uri('GET', url, json=data, complete_qs=True)

        # query for the eps

        eps = EscalationPolicy.find(api_key=self.api_key, name=name,)