Skip to content

Commit

Permalink
Merge pull request #322 from BuildingSync/test/no-name-duplicates
Browse files Browse the repository at this point in the history
test: add test for duplicate element names
  • Loading branch information
macintoshpie authored Apr 13, 2021
2 parents d27d3dc + 6486c09 commit 3f1aecc
Showing 1 changed file with 187 additions and 1 deletion.
188 changes: 187 additions & 1 deletion spec/validation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,190 @@

expect(conflicts).to be_empty
end
end
end

RSpec.describe 'No naming collisions within the schema' do
it 'should not have any elements with duplicate names' do
schema_doc = Nokogiri::XML(File.read('BuildingSync.xsd'))
named_elements = schema_doc.xpath("//xs:element[@name]")
element_names = Hash.new
named_elements.each do |node|
element_name = node['name']
if element_names.key?(element_name)
element_names[element_name].append(node.line())
else
element_names[element_name] = [node.line()]
end
end

# TODO: remove ignored dupes once we fix them all. (ie make no exceptions)
# See https://github.com/BuildingSync/project-tracker/issues/21
ignored_dupes = [
'ActiveDehumidification',
'AdvancedPowerStrip',
'AnnualCoolingEfficiencyValue',
'AnnualDemandSavingsCost',
'AnnualHeatingEfficiencyValue',
'AnnualPeakElectricityReduction',
'AnnualSavingsByFuel',
'AnnualSavingsByFuels',
'AnnualSavingsCost',
'AnnualSavingsNativeUnits',
'AnnualSavingsSiteEnergy',
'AnnualSavingsSourceEnergy',
'AnnualWaterCostSavings',
'AnnualWaterSavings',
'AssemblyType',
'BoilerLWT',
'Building',
'BurnerQuantity',
'BurnerTurndownRatio',
'CBECS',
'CDDBaseTemperature',
'Capacity',
'ChilledWaterSupplyTemperature',
'ClimateZone',
'ClothesWasherCapacity',
'ClothesWasherModifiedEnergyFactor',
'ClothesWasherWaterFactor',
'Combustion',
'CombustionEfficiency',
'CommunicationProtocol',
'CondenserPlantID',
'CondenserPlantIDs',
'CondenserWaterTemperature',
'CondensingTemperature',
'Control',
'ControlSensor',
'ControlStrategy',
'ControlSystemTypes',
'Controls',
'ConveyanceSystems',
'CoolingSourceID',
'CoolingStageCapacity',
'DemandRatchetPercentage',
'DemandRateAdjustment',
'DemandWindow',
'DryerElectricEnergyUsePerLoad',
'DryerGasEnergyUsePerLoad',
'ElectricDemandRate',
'ElectricResistance',
'EndTimestamp',
'EndUse',
'EnergyCostRate',
'EnergyRateAdjustment',
'EnergySellRate',
'EnergyUse',
'EquipmentDisposalAndSalvageCosts',
'ExistingScheduleAffected',
'ExteriorRoughness',
'Facility',
'FanBased',
'FenestrationArea',
'FloorsAboveGrade',
'FloorsBelowGrade',
'FoundationHeightAboveGrade',
'FoundationWallConstruction',
'FoundationWallInsulationCondition',
'FoundationWallInsulationThickness',
'FoundationWallRValue',
'FoundationWallUFactor',
'FundingFromIncentives',
'FundingFromTaxCredits',
'HDDBaseTemperature',
'HeatPump',
'HeatingStageCapacityFraction',
'HotWaterBoilerMaximumFlowRate',
'InputCapacity',
'InteriorVisibleAbsorptance',
'InternalRateOfReturn',
'IntervalFrequency',
'LampLabel',
'LampPower',
'LinkedBuildingID',
'LinkedFacilityID',
'LinkedScheduleID',
'LinkedScheduleIDs',
'LinkedSectionID',
'LinkedSiteID',
'LinkedSpaceID',
'LinkedSystemID',
'LinkedSystemIDs',
'LinkedThermalZoneID',
'MVCost',
'MakeupAirSourceID',
'Manual',
'MeasureName',
'MinimumPartLoadRatio',
'ModifiedSchedule',
'NPVofTaxImplications',
'NetPresentValue',
'NoCooling',
'NoHeating',
'NumberOfDiscreteCoolingStages',
'NumberOfHeatingStages',
'OMCostAnnualSavings',
'Occupancy',
'Other',
'OtherCombination',
'OtherControlStrategyName',
'OtherControlTechnology',
'OtherControlTechnologyName',
'OutputCapacity',
'PipeInsulationThickness',
'PipeLocation',
'PortfolioManager',
'PrimaryFuel',
'Priority',
'RatePeriod',
'RatePeriodName',
'RatePeriods',
'RatedCoolingSensibleHeatRatio',
'RefrigerantChargeFactor',
'RequiredVentilationRate',
'Section',
'SimplePayback',
'Site',
'SiteEnergyUse',
'SlabArea',
'SlabExposedPerimeter',
'SlabInsulationCondition',
'SlabInsulationThickness',
'SlabPerimeter',
'SourceEnergyUse',
'SourceEnergyUseIntensity',
'Space',
'SpaceID',
'SpaceIDs',
'StartTimestamp',
'SteamBoilerMaximumOperatingPressure',
'SteamBoilerMinimumOperatingPressure',
'Story',
'StreetAdditionalInfo',
'SummerPeakElectricityReduction',
'ThermalEfficiency',
'ThermalZone',
'ThermalZoneID',
'ThermalZoneIDs',
'TimeSeries',
'Timer',
'TransformerNeeded',
'Unknown',
'UtilityAccountNumber',
'UtilityBillpayer',
'UtilityMeterNumber',
'VentilationControlMethods',
'VentilationRate',
'WaterSideEconomizer',
'WaterSideEconomizerDBTemperatureMaximum',
'WaterSideEconomizerTemperatureMaximum',
'WaterUse',
'WeightedAverageLoad',
'WinterPeakElectricityReduction',
'YearOfConstruction'
]

dupe_names = element_names.select{ |k, v| v.length() > 1 && !ignored_dupes.include?(k) }
expect(dupe_names).to be_empty
end
end

0 comments on commit 3f1aecc

Please sign in to comment.