def test_get_bldg_meters():
    """ Pass a single building ID number; return a list of meter objects in
        .JSON format associated with the given building """

    with HTTMock(meter_list_response_content):
        bldgIDs = ['1266'] 
        bldgMeterDct = deltamtrsvs.get_bldg_meters(bldg_meters_url, bldgIDs,
                                                   private.headers)
        assert type(bldgMeterDct) == tp.DictType
        for key, value in bldgMeterDct.iteritems():
            assert type(key) == tp.StringType
            assert type(value) == tp.DictType
            assert len(value) <= 2
def test_get_bldg_meters():
    """ Pass a single building ID number; return a list of meter objects in
        .JSON format associated with the given building """

    for site in sites:
        bldgIDct = deltamtrsvs.get_property_bldgs(properties_url, site,
                                                  headers)
        bldgIDs = []
        for key in bldgIDct:
            bldgIDs.append(str(key))

        bldgMeterDct = deltamtrsvs.get_bldg_meters(pvt.bldg_meters_url, bldgIDs
                                                   , headers)
        assert type(bldgMeterDct) == tp.DictType
        for key, value in bldgMeterDct.iteritems():
            assert type(key) == tp.StringType
            assert type(value) == tp.DictType
            assert len(value) <= 2
def test_get_meter_records():
    """ Pass a dictionary of *audit* spans from amsaves_usage_range with
        reference model IDs from the amsaves_usage_range function as keys and
        a list of meter IDs from get_bldg_meters function  """

    #for site in sites:
    site = '46'
    bldgIDct = deltamtrsvs.get_property_bldgs(properties_url, site, headers)
    bldgIDs = []
    for key in bldgIDct:
        bldgIDs.append(str(key))

    bldgModelsDct = deltamtrsvs.get_bldg_models(model_url, bldgIDs,
                                                headers)
    refModelsDct = {}
    for key, value in bldgModelsDct.iteritems():
        refModelsDct[key] = value['Reference Model']
            
    comparisonsDct = deltamtrsvs.get_model_comparisons(comparison_url,
                                                       bldgModelsDct,
                                                       headers)
    audits = deltamtrsvs.get_model_audits(audit_url, refModelsDct, headers)
    auditSpans = ams.amsaves_usage_range(audits)
    bldgMeterDct = deltamtrsvs.get_bldg_meters(pvt.bldg_meters_url, bldgIDs,
                                               headers)
    bldgMeterRecordsDct = deltamtrsvs.get_meter_records(auditSpans,
                                                        bldgMeterDct,
                                                        pvt.meter_records_url,
                                                        headers)
    assert type(bldgMeterRecordsDct) == tp.DictType
    for key, value in bldgMeterRecordsDct.iteritems():
        assert type(key) == tp.StringType
        assert type(value) == tp.DictType
        assert len(value) <= 2
        elecMtrVals = value['Elec. Meter Records']
        assert type(elecMtrVals) == tp.ListType
        assert [type(elecMtrVal) == tp.DictType for elecMtrVal in elecMtrVals]
        if len(value) == 2:
            gasMtrVals = value['Gas Meter Records']
            assert type(gasMtrVals) == tp.ListType
            assert [type(gasMtrVal) == tp.DictType for gasMtrVal in gasMtrVals]
            assert elecMtrVals != gasMtrVals