# Path: scraper/inmates.py
# class Inmates(ConcurrentBase):
# 
#     def __init__(self, inmate_class, raw_inmate_data, monitor):
#         super(Inmates, self).__init__(monitor)
#         self._inmate_class = inmate_class
#         self.__raw_inmate_data = raw_inmate_data
# 
#     def active_inmates_ids(self, response_queue):
#         self._put(self._active_inmates_ids, response_queue)
# 
#     def _active_inmates_ids(self, response_queue):
#         _send_inmate_ids(response_queue, self._inmate_class.active_inmates())
# 
#     def add(self, inmate_id, inmate_details):
#         self._put(self._create_update_inmate, {'inmate_id': inmate_id, 'inmate_details': inmate_details})
# 
#     def _create_update_inmate(self, args):
#         inmate = self._inmate_class(args['inmate_id'], args['inmate_details'], self._monitor)
#         inmate.save()
#         self.__raw_inmate_data.add(args['inmate_details'])
# 
#     def discharge(self, inmate_id):
#         self._put(self._discharge, inmate_id)
# 
#     def _discharge(self, inmate_id):
#         self._inmate_class.discharge(inmate_id, self._monitor)
# 
#     def known_inmates_ids_starting_with(self, response_queue, start_date):
#         self._put(self._known_inmates_ids_starting_with, {'response_queue': response_queue, 'start_date': start_date})
# 
#     def _known_inmates_ids_starting_with(self, args):
#         known_inmates_ids = []
#         cur_date = args['start_date']
#         the_yesterday = yesterday()
#         while cur_date <= the_yesterday:
#             known_inmates_ids.extend([inmate.jail_id for inmate in self._inmate_class.known_inmates_for_date(cur_date)])
#             cur_date += ONE_DAY
#         args['response_queue'].put(known_inmates_ids)
# 
#     def recently_discharged_inmates_ids(self, response_queue):
#         self._put(self._recently_discharged_inmates_ids, response_queue)
# 
#     def _recently_discharged_inmates_ids(self, response_queue):
#         _send_inmate_ids(response_queue, self._inmate_class.recently_discharged_inmates())
# 
#     def update(self, inmate_id, inmate_details):
#         self._put(self._create_update_inmate, {'inmate_id': inmate_id, 'inmate_details': inmate_details})


from gevent.queue import Queue
from mock import Mock, call
from scraper.inmates import Inmates
        inmates.active_inmates_ids(response_q)
        active_inmates_ids = response_q.get()
        assert active_inmates_ids == j_ids
        assert self.__raw_inmate_data.call_args_list == []

    def test_add_inmate(self):
        Inmate_TestDouble.clear_class_vars()
        inmates = Inmates(Inmate_TestDouble, self.__raw_inmate_data, Mock())
        inmate_details = Mock()
        inmate_id = 23
        inmate_details.jail_id.return_value = inmate_id
        inmates.add(inmate_id, inmate_details)
        assert Inmate_TestDouble.instantiated_called(1)
        inmate = Inmate_TestDouble.instantiated[0]
        assert inmate.inmate_details == inmate_details
        assert inmate.saved_count == 1
        assert self.__raw_inmate_data.add.call_args_list == [call(inmate_details)]

    def test_discharge_inmate(self):
        inmate_class = Mock()
        monitor = Mock()
        inmates = Inmates(inmate_class, self.__raw_inmate_data, monitor)
        inmate__id = 232
        inmates.discharge(inmate__id)
        assert inmate_class.discharge.call_args_list == [call(inmate__id, monitor)]
        assert self.__raw_inmate_data.call_args_list == []

    def test_finish(self):
        Inmate_TestDouble.clear_class_vars()
        monitor = Mock()

# Path: scraper/inmates.py
# class Inmates(ConcurrentBase):
# 
#     def __init__(self, inmate_class, raw_inmate_data, monitor):
#         super(Inmates, self).__init__(monitor)
#         self._inmate_class = inmate_class
#         self.__raw_inmate_data = raw_inmate_data
# 
#     def active_inmates_ids(self, response_queue):
#         self._put(self._active_inmates_ids, response_queue)
# 
#     def _active_inmates_ids(self, response_queue):
#         _send_inmate_ids(response_queue, self._inmate_class.active_inmates())
# 
#     def add(self, inmate_id, inmate_details):
#         self._put(self._create_update_inmate, {'inmate_id': inmate_id, 'inmate_details': inmate_details})
# 
#     def _create_update_inmate(self, args):
#         inmate = self._inmate_class(args['inmate_id'], args['inmate_details'], self._monitor)
#         inmate.save()
#         self.__raw_inmate_data.add(args['inmate_details'])
# 
#     def discharge(self, inmate_id):
#         self._put(self._discharge, inmate_id)
# 
#     def _discharge(self, inmate_id):
#         self._inmate_class.discharge(inmate_id, self._monitor)
# 
#     def known_inmates_ids_starting_with(self, response_queue, start_date):
#         self._put(self._known_inmates_ids_starting_with, {'response_queue': response_queue, 'start_date': start_date})
# 
#     def _known_inmates_ids_starting_with(self, args):
#         known_inmates_ids = []
#         cur_date = args['start_date']
#         the_yesterday = yesterday()
#         while cur_date <= the_yesterday:
#             known_inmates_ids.extend([inmate.jail_id for inmate in self._inmate_class.known_inmates_for_date(cur_date)])
#             cur_date += ONE_DAY
#         args['response_queue'].put(known_inmates_ids)
# 
#     def recently_discharged_inmates_ids(self, response_queue):
#         self._put(self._recently_discharged_inmates_ids, response_queue)
# 
#     def _recently_discharged_inmates_ids(self, response_queue):
#         _send_inmate_ids(response_queue, self._inmate_class.recently_discharged_inmates())
# 
#     def update(self, inmate_id, inmate_details):
#         self._put(self._create_update_inmate, {'inmate_id': inmate_id, 'inmate_details': inmate_details})


# Path: tests/scraper/test_inmates.py
from gevent.queue import Queue
from mock import Mock, call
from scraper.inmates import Inmates

        inmates.active_inmates_ids(response_q)
        active_inmates_ids = response_q.get()
        assert active_inmates_ids == j_ids
        assert self.__raw_inmate_data.call_args_list == []

    def test_add_inmate(self):
        Inmate_TestDouble.clear_class_vars()
        inmates = Inmates(Inmate_TestDouble, self.__raw_inmate_data, Mock())
        inmate_details = Mock()
        inmate_id = 23
        inmate_details.jail_id.return_value = inmate_id
        inmates.add(inmate_id, inmate_details)
        assert Inmate_TestDouble.instantiated_called(1)
        inmate = Inmate_TestDouble.instantiated[0]
        assert inmate.inmate_details == inmate_details
        assert inmate.saved_count == 1
        assert self.__raw_inmate_data.add.call_args_list == [call(inmate_details)]

    def test_discharge_inmate(self):
        inmate_class = Mock()
        monitor = Mock()
        inmates = Inmates(inmate_class, self.__raw_inmate_data, monitor)
        inmate__id = 232
        inmates.discharge(inmate__id)
        assert inmate_class.discharge.call_args_list == [call(inmate__id, monitor)]
        assert self.__raw_inmate_data.call_args_list == []

    def test_finish(self):
        Inmate_TestDouble.clear_class_vars()
        monitor = Mock()

        inmates = Inmates(Inmate_TestDouble, self.__raw_inmate_data, monitor)