# Path: greenpithumb/db_store.py
# _CREATE_TABLE_COMMANDS = """
# CREATE TABLE temperature
# (
#     timestamp TEXT,
#     temperature REAL    --temperature (in degrees Celsius)
# );
# CREATE TABLE humidity
# (
#     timestamp TEXT,
#     humidity REAL
# );
# CREATE TABLE soil_moisture
# (
#     timestamp TEXT,
#     soil_moisture INTEGER
# );
# CREATE TABLE light
# (
#     timestamp TEXT,
#     light REAL
# );
# CREATE TABLE watering_events
# (
#     timestamp TEXT,
#     water_pumped REAL   --amount of water pumped (in mL)
# );
# """
# _TIMESTAMP_FORMAT = '%Y-%m-%dT%H:%MZ'
# def _timestamp_to_utc(timestamp):
# def _open_db(db_path):
# def _create_db(db_path):
# def open_or_create_db(db_path):
#     def __init__(self, connection):
#     def _do_insert(self, sql, timestamp, value):
#     def _do_get(self, sql, record_type):
#     def insert(self, soil_moisture_record):
#     def get(self):
#     def insert(self, light_record):
#     def get(self):
#     def insert(self, humidity_record):
#     def get(self):
#     def insert(self, temperature_record):
#     def get(self):
#     def insert(self, watering_event_record):
#     def get(self):
# class _DbStoreBase(object):
# class SoilMoistureStore(_DbStoreBase):
# class LightStore(_DbStoreBase):
# class HumidityStore(_DbStoreBase):
# class TemperatureStore(_DbStoreBase):
# class WateringEventStore(_DbStoreBase):


import contextlib
import datetime
import os
import shutil
import sqlite3
import tempfile
import unittest
import mock
import pytz
from dateutil import tz
from greenpithumb import db_store
        store = db_store.LightStore(self.mock_connection)
        store.insert(light_record)
        self.mock_cursor.execute.assert_called_once_with(
            'INSERT INTO light VALUES (?, ?)', ('2016-07-23T15:51Z', 50.0))
        self.mock_connection.commit.assert_called_once()

    def test_get_light(self):
        store = db_store.LightStore(self.mock_connection)
        self.mock_cursor.fetchall.return_value = [('2016-07-23T10:51Z', 300),
                                                  ('2016-07-23T10:52Z', 400)]
        light_data = store.get()
        light_data.sort(key=lambda LightRecord: LightRecord.timestamp)

        self.assertEqual(light_data[0].timestamp,
                         datetime.datetime(
                             2016, 7, 23, 10, 51, 0, tzinfo=pytz.utc))
        self.assertEqual(light_data[0].light, 300)
        self.assertEqual(light_data[1].timestamp,
                         datetime.datetime(
                             2016, 7, 23, 10, 52, 0, tzinfo=pytz.utc))
        self.assertEqual(light_data[1].light, 400)

    def test_get_light_empty_database(self):
        store = db_store.LightStore(self.mock_connection)
        self.mock_cursor.fetchall.return_value = []
        light_data = store.get()
        self.assertEqual(light_data, [])

    def test_insert_humidity(self):
        """Should insert timestamp and humidity level into database."""

# Path: greenpithumb/db_store.py
# _CREATE_TABLE_COMMANDS = """
# CREATE TABLE temperature
# (
#     timestamp TEXT,
#     temperature REAL    --temperature (in degrees Celsius)
# );
# CREATE TABLE humidity
# (
#     timestamp TEXT,
#     humidity REAL
# );
# CREATE TABLE soil_moisture
# (
#     timestamp TEXT,
#     soil_moisture INTEGER
# );
# CREATE TABLE light
# (
#     timestamp TEXT,
#     light REAL
# );
# CREATE TABLE watering_events
# (
#     timestamp TEXT,
#     water_pumped REAL   --amount of water pumped (in mL)
# );
# """
# _TIMESTAMP_FORMAT = '%Y-%m-%dT%H:%MZ'
# def _timestamp_to_utc(timestamp):
# def _open_db(db_path):
# def _create_db(db_path):
# def open_or_create_db(db_path):
#     def __init__(self, connection):
#     def _do_insert(self, sql, timestamp, value):
#     def _do_get(self, sql, record_type):
#     def insert(self, soil_moisture_record):
#     def get(self):
#     def insert(self, light_record):
#     def get(self):
#     def insert(self, humidity_record):
#     def get(self):
#     def insert(self, temperature_record):
#     def get(self):
#     def insert(self, watering_event_record):
#     def get(self):
# class _DbStoreBase(object):
# class SoilMoistureStore(_DbStoreBase):
# class LightStore(_DbStoreBase):
# class HumidityStore(_DbStoreBase):
# class TemperatureStore(_DbStoreBase):
# class WateringEventStore(_DbStoreBase):


# Path: tests/test_db_store.py
import contextlib
import datetime
import os
import shutil
import sqlite3
import tempfile
import unittest
import mock
import pytz
from dateutil import tz
from greenpithumb import db_store

        store = db_store.LightStore(self.mock_connection)
        store.insert(light_record)
        self.mock_cursor.execute.assert_called_once_with(
            'INSERT INTO light VALUES (?, ?)', ('2016-07-23T15:51Z', 50.0))
        self.mock_connection.commit.assert_called_once()

    def test_get_light(self):
        store = db_store.LightStore(self.mock_connection)
        self.mock_cursor.fetchall.return_value = [('2016-07-23T10:51Z', 300),
                                                  ('2016-07-23T10:52Z', 400)]
        light_data = store.get()
        light_data.sort(key=lambda LightRecord: LightRecord.timestamp)

        self.assertEqual(light_data[0].timestamp,
                         datetime.datetime(
                             2016, 7, 23, 10, 51, 0, tzinfo=pytz.utc))
        self.assertEqual(light_data[0].light, 300)
        self.assertEqual(light_data[1].timestamp,
                         datetime.datetime(
                             2016, 7, 23, 10, 52, 0, tzinfo=pytz.utc))
        self.assertEqual(light_data[1].light, 400)

    def test_get_light_empty_database(self):
        store = db_store.LightStore(self.mock_connection)
        self.mock_cursor.fetchall.return_value = []
        light_data = store.get()
        self.assertEqual(light_data, [])

    def test_insert_humidity(self):
        """Should insert timestamp and humidity level into database."""

        humidity_record = db_store.HumidityRecord(