def test_get_equipment_point_records_successful(self, get_weather_data, populate_weatherstation_id_on_records, uow):
        syrx_file_handler = SyrxFileHandler()
        syrx_file_handler.date_time = Mock()
        syrx_file_handler.date_time_str = Mock()

        weather_data = {"ws1": {pytz.utc.localize(datetime.datetime(2014, 9, 8, 0, 0, 0)): "weather_record_1",
                                pytz.utc.localize(datetime.datetime(2014, 9, 8, 13, 0, 0)): "weather_record_2",
                                pytz.utc.localize(datetime.datetime(2014, 8, 8, 13, 0, 0)): "weather_record_3"}}
        get_weather_data.return_value = weather_data

        records = [{"value": 100, "timestamp": "2014-09-08 00:15:00", "weatherstation_id": "ws1", "syrx_num": "400000-0001-237323-EP-001"},
                   {"value": 100, "timestamp": "2014-09-08 13:00:00", "weatherstation_id": "ws1", "syrx_num": "400000-0001-237323-EP-001"},
                   {"value": 100, "timestamp": "2014-08-08 13:00:00", "weatherstation_id": "ws1", "syrx_num": "400000-0001-237323-EP-001"}]

        rv = syrx_file_handler.get_equipment_point_records(records)

        populate_weatherstation_id_on_records.assert_called_with(records)
        get_weather_data.assert_called_with(records)

        assert len(rv.equipment_point_records) == 3
        assert len(rv.bad_records) == 0

        uow.return_value.energy_records.get_equipment_point_record.assert_has_calls([
            call(pytz.utc.localize(datetime.datetime(2014, 9, 8, 0, 15, 0)), "400000-0001-237323-EP-001", 100,
                 "weather_record_1", syrx_file_handler.date_time),
            call(pytz.utc.localize(datetime.datetime(2014, 9, 8, 13, 0, 0)), "400000-0001-237323-EP-001", 100,
                 "weather_record_2", syrx_file_handler.date_time),
            call(pytz.utc.localize(datetime.datetime(2014, 8, 8, 13, 0, 0)), "400000-0001-237323-EP-001", 100,
                 "weather_record_3", syrx_file_handler.date_time)

        ])
    def test_get_equipment_point_records_missing_weather_data(self, get_weather_data, populate_weatherstation_id_on_records, uow):
        syrx_file_handler = SyrxFileHandler()
        syrx_file_handler.date_time = Mock()
        syrx_file_handler.date_time_str = Mock()

        weather_data = {"ws1": {pytz.utc.localize(datetime.datetime(2014, 8, 8, 0, 0, 0)): "weather_record_1"}}
        get_weather_data.return_value = weather_data

        records = [{"value": 100, "timestamp": "2014-09-08 00:15:00", "weatherstation_id": "ws1", "syrx_num": "400000-0001-237323-EP-001"}]

        rv = syrx_file_handler.get_equipment_point_records(records)

        populate_weatherstation_id_on_records.assert_called_with(records)
        get_weather_data.assert_called_with(records)

        assert len(rv.equipment_point_records) == 0
        assert len(rv.bad_records) == 1

        assert rv.bad_records[0] == {"value": 100, "timestamp": "2014-09-08 00:15:00", "weatherstation_id": "ws1",
                                     "syrx_num": "400000-0001-237323-EP-001",
                                     "error": {"date": syrx_file_handler.date_time_str,
                                               "messages": ['Time 2014-09-08 00:00:00 not found in weather data']}}