from backend.Property import Property
from recommendations.FireplaceRecommendations import FireplaceRecommendations
from etl.epc.Record import EPCRecord


class TestFirepaceRecommendations:

    def test_no_fireplaces(self):
        epc_record = EPCRecord()
        epc_record.prepared_epc = {
            "number-open-fireplaces": 0,
        }

        property_instance = Property(id=0, address="fake", postcode="fake", epc_record=epc_record)

        recommender = FireplaceRecommendations(
            property_instance=property_instance
        )

        assert recommender.recommendation is None

        recommender.recommend()

        assert recommender.recommendation is None

    def test_one_fireplace(self):
        epc_record = EPCRecord()
        epc_record.prepared_epc = {
            "number-open-fireplaces": 1,
        }
        property_instance = Property(id=0, address="fake", postcode="fake", epc_record=epc_record)

        recommender = FireplaceRecommendations(
            property_instance=property_instance
        )

        assert recommender.recommendation is None

        recommender.recommend()

        assert recommender.recommendation
        assert recommender.recommendation[0]["type"] == "sealing_open_fireplace"
        assert recommender.recommendation[0]["total"] == 300

    def test_multiple_fireplaces(self):
        epc_record = EPCRecord()
        epc_record.prepared_epc = {
            "number-open-fireplaces": 3,
        }
        property_instance = Property(id=0, address="fake", postcode="fake", epc_record=epc_record)

        recommender = FireplaceRecommendations(
            property_instance=property_instance
        )

        assert recommender.recommendation is None

        recommender.recommend()

        assert recommender.recommendation
        assert recommender.recommendation[0]["type"] == "sealing_open_fireplace"
        assert recommender.recommendation[0]["total"] == 900
