# Path: greenpithumb/camera_manager.py
# _FILENAME_FORMAT = '%Y-%m-%dT%H%MZ.jpg'
# LIGHT_THRESHOLD_PCT = 60
# class CameraManager(object):
#     def __init__(self, image_path, clock, camera, light_sensor):
#     def sufficient_light(self):
#     def save_photo(self):
#     def close(self):


import contextlib
import datetime
import os
import unittest
import mock
import pytz
from greenpithumb import camera_manager
        with contextlib.closing(
                camera_manager.CameraManager(
                    self.image_path, self.mock_local_clock, self.mock_camera,
                    self.mock_light_sensor)):
            pass
        mock_exists.assert_called_once_with(self.image_path)
        mock_makedirs.assert_called_once_with(self.image_path)

    @mock.patch.object(os.path, 'exists')
    @mock.patch.object(os, 'makedirs')
    def test_sufficient_light_below_threshold(self, mock_makedirs, mock_exists):
        self.mock_light_sensor.light.return_value = (
            camera_manager.LIGHT_THRESHOLD_PCT - 1)
        with contextlib.closing(
                camera_manager.CameraManager(
                    self.image_path, self.mock_local_clock, self.mock_camera,
                    self.mock_light_sensor)) as manager:
            self.assertFalse(manager.sufficient_light())

    @mock.patch.object(os.path, 'exists')
    @mock.patch.object(os, 'makedirs')
    def test_sufficient_light_at_threshold(self, mock_makedirs, mock_exists):
        self.mock_light_sensor.light.return_value = (
            camera_manager.LIGHT_THRESHOLD_PCT)
        with contextlib.closing(
                camera_manager.CameraManager(
                    self.image_path, self.mock_local_clock, self.mock_camera,
                    self.mock_light_sensor)) as manager:
            self.assertTrue(manager.sufficient_light())


# Path: greenpithumb/camera_manager.py
# _FILENAME_FORMAT = '%Y-%m-%dT%H%MZ.jpg'
# LIGHT_THRESHOLD_PCT = 60
# class CameraManager(object):
#     def __init__(self, image_path, clock, camera, light_sensor):
#     def sufficient_light(self):
#     def save_photo(self):
#     def close(self):


# Path: tests/test_camera_manager.py
import contextlib
import datetime
import os
import unittest
import mock
import pytz
from greenpithumb import camera_manager

        with contextlib.closing(
                camera_manager.CameraManager(
                    self.image_path, self.mock_local_clock, self.mock_camera,
                    self.mock_light_sensor)):
            pass
        mock_exists.assert_called_once_with(self.image_path)
        mock_makedirs.assert_called_once_with(self.image_path)

    @mock.patch.object(os.path, 'exists')
    @mock.patch.object(os, 'makedirs')
    def test_sufficient_light_below_threshold(self, mock_makedirs, mock_exists):
        self.mock_light_sensor.light.return_value = (
            camera_manager.LIGHT_THRESHOLD_PCT - 1)
        with contextlib.closing(
                camera_manager.CameraManager(
                    self.image_path, self.mock_local_clock, self.mock_camera,
                    self.mock_light_sensor)) as manager:
            self.assertFalse(manager.sufficient_light())

    @mock.patch.object(os.path, 'exists')
    @mock.patch.object(os, 'makedirs')
    def test_sufficient_light_at_threshold(self, mock_makedirs, mock_exists):
        self.mock_light_sensor.light.return_value = (
            camera_manager.LIGHT_THRESHOLD_PCT)
        with contextlib.closing(
                camera_manager.CameraManager(
                    self.image_path, self.mock_local_clock, self.mock_camera,
                    self.mock_light_sensor)) as manager:
            self.assertTrue(manager.sufficient_light())


    @mock.patch.object(os.path, 'exists')