# 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
        mock_exists.return_value = True
        self.mock_local_clock.now.return_value = datetime.datetime(
            2016, 7, 23, 10, 51, 9, 928000, tzinfo=pytz.utc)
        with contextlib.closing(
                camera_manager.CameraManager(
                    self.image_path, self.mock_local_clock, self.mock_camera,
                    self.mock_light_sensor)) as manager:
            manager.save_photo()
        self.mock_camera.capture.assert_called_once_with(
            'C:/Users/Jeet/2016-07-23T1051Z.jpg')
        mock_exists.assert_called_once_with(self.image_path)
        mock_makedirs.assert_not_called()
        self.mock_camera.close.assert_called()

    @mock.patch.object(os.path, 'exists')
    @mock.patch.object(os, 'makedirs')
    def test_create_path_if_does_not_exist(self, mock_makedirs, mock_exists):
        mock_exists.return_value = False
        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 = (

# 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

        mock_exists.return_value = True
        self.mock_local_clock.now.return_value = datetime.datetime(
            2016, 7, 23, 10, 51, 9, 928000, tzinfo=pytz.utc)
        with contextlib.closing(
                camera_manager.CameraManager(
                    self.image_path, self.mock_local_clock, self.mock_camera,
                    self.mock_light_sensor)) as manager:
            manager.save_photo()
        self.mock_camera.capture.assert_called_once_with(
            'C:/Users/Jeet/2016-07-23T1051Z.jpg')
        mock_exists.assert_called_once_with(self.image_path)
        mock_makedirs.assert_not_called()
        self.mock_camera.close.assert_called()

    @mock.patch.object(os.path, 'exists')
    @mock.patch.object(os, 'makedirs')
    def test_create_path_if_does_not_exist(self, mock_makedirs, mock_exists):
        mock_exists.return_value = False
        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)