from django.test import TestCase
from django.utils import translation

from geotrek.infrastructure.models import Infrastructure
from geotrek.infrastructure.factories import InfrastructureFactory, SignageFactory
from geotrek.maintenance.models import Intervention
from geotrek.maintenance.factories import (InterventionFactory,
                                           InfrastructureInterventionFactory,
                                           InfrastructurePointInterventionFactory,
                                           SignageInterventionFactory,
                                           ProjectFactory, ManDayFactory)
from geotrek.core.factories import PathFactory, TopologyFactory, StakeFactory


class InterventionTest(TestCase):
    def test_topology_has_intervention_kind(self):
        topo = TopologyFactory.create()
        self.assertEqual('TOPOLOGY', topo.kind)
        i = InterventionFactory.create(topology=topo)
        self.assertEqual('INTERVENTION', i.topology.kind)

    def test_infrastructure(self):
        i = InterventionFactory.create()
        self.assertFalse(i.on_infrastructure)
        infra = InfrastructureFactory.create()
        i.set_infrastructure(infra)
        self.assertTrue(i.on_infrastructure)
        sign = SignageFactory.create()
        i.set_infrastructure(sign)
        self.assertTrue(i.on_infrastructure)

    def test_default_stake(self):
        i = InterventionFactory.create()
        i.stake = None
        self.assertTrue(i.stake is None)
        i.save()
        self.assertTrue(i.stake is None)

        lowstake = StakeFactory.create()
        highstake = StakeFactory.create()
        if lowstake > highstake: