from backend.Property import Property
from unittest.mock import Mock
from recommendations.FireplaceRecommendations import FireplaceRecommendations


class TestFirepaceRecommendations:

    def test_no_fireplaces(self):
        property_instance = Property(id=0, address1="fake", postcode="fake", epc_client=Mock())
        property_instance.data = {
            "number-open-fireplaces": 0
        }

        recommender = FireplaceRecommendations(
            property_instance=property_instance
        )

        assert recommender.recommendation is None

        recommender.recommend()

        assert recommender.recommendation is None

    def test_one_fireplace(self):
        property_instance = Property(id=0, address1="fake", postcode="fake", epc_client=Mock())
        property_instance.data = {
            "number-open-fireplaces": 1
        }

        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):
        property_instance = Property(id=0, address1="fake", postcode="fake", epc_client=Mock())
        property_instance.data = {
            "number-open-fireplaces": 3
        }

        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
