# 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: greenpithumb/record_processor.py
# class Error(Exception):
# class UnsupportedRecordError(Error):
# class RecordProcessor(object):
#     def __init__(self, record_queue, soil_moisture_store, light_store,
#                  humidity_store, temperature_store, watering_event_store):
#     def try_process_next_record(self):


import datetime
import Queue
import unittest
import mock
import pytz
from greenpithumb import db_store
from greenpithumb import record_processor
    def test_process_humidity_record(self):
        record = db_store.HumidityRecord(
            timestamp=datetime.datetime(
                2016, 7, 23, 10, 51, 9, 928000, tzinfo=pytz.utc),
            humidity=184.5)
        self.record_queue.put(record)
        self.assertTrue(self.processor.try_process_next_record())
        self.mock_humidity_store.insert.assert_called_with(record)

    def test_process_temperature_record(self):
        record = db_store.TemperatureRecord(
            timestamp=datetime.datetime(
                2016, 7, 23, 10, 51, 9, 928000, tzinfo=pytz.utc),
            temperature=32.9)
        self.record_queue.put(record)
        self.assertTrue(self.processor.try_process_next_record())
        self.mock_temperature_store.insert.assert_called_with(record)

    def test_process_watering_event_record(self):
        record = db_store.WateringEventRecord(
            timestamp=datetime.datetime(
                2016, 7, 23, 10, 51, 9, 928000, tzinfo=pytz.utc),
            water_pumped=15.6)
        self.record_queue.put(record)
        self.assertTrue(self.processor.try_process_next_record())
        self.mock_watering_event_store.insert.assert_called_with(record)

    def test_rejects_unsupported_record(self):
        record = 'dummy invalid record'
        self.record_queue.put(record)

# 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: greenpithumb/record_processor.py
# class Error(Exception):
# class UnsupportedRecordError(Error):
# class RecordProcessor(object):
#     def __init__(self, record_queue, soil_moisture_store, light_store,
#                  humidity_store, temperature_store, watering_event_store):
#     def try_process_next_record(self):


# Path: tests/test_record_processor.py
import datetime
import Queue
import unittest
import mock
import pytz
from greenpithumb import db_store
from greenpithumb import record_processor

    def test_process_humidity_record(self):
        record = db_store.HumidityRecord(
            timestamp=datetime.datetime(
                2016, 7, 23, 10, 51, 9, 928000, tzinfo=pytz.utc),
            humidity=184.5)
        self.record_queue.put(record)
        self.assertTrue(self.processor.try_process_next_record())
        self.mock_humidity_store.insert.assert_called_with(record)

    def test_process_temperature_record(self):
        record = db_store.TemperatureRecord(
            timestamp=datetime.datetime(
                2016, 7, 23, 10, 51, 9, 928000, tzinfo=pytz.utc),
            temperature=32.9)
        self.record_queue.put(record)
        self.assertTrue(self.processor.try_process_next_record())
        self.mock_temperature_store.insert.assert_called_with(record)

    def test_process_watering_event_record(self):
        record = db_store.WateringEventRecord(
            timestamp=datetime.datetime(
                2016, 7, 23, 10, 51, 9, 928000, tzinfo=pytz.utc),
            water_pumped=15.6)
        self.record_queue.put(record)
        self.assertTrue(self.processor.try_process_next_record())
        self.mock_watering_event_store.insert.assert_called_with(record)

    def test_rejects_unsupported_record(self):
        record = 'dummy invalid record'
        self.record_queue.put(record)

        with self.assertRaises(record_processor.UnsupportedRecordError):