class TestZone: POSITION1 = script.Position(100, 55) POSITION2 = script.Position(101, 34) ZONE = script.Zone(POSITION1, POSITION2) AGENT = script.Agent(POSITION1, agreeableness=1) # - trouver une zone qui contient une position def test_find_zone_that_contains(self): found_zone = script.Zone.find_zone_that_contains(self.POSITION1) assert found_zone.corner1.longitude == self.ZONE.corner1.longitude # - ajouter un habitant dans une zone def test_add_inhabitant_in_zone(self): self.ZONE.add_inhabitant(self.AGENT) assert len(self.ZONE.inhabitants) # - récupérer toutes les instances Zone (Zone.ZONES) def test_get_zone(self): assert len(script.Zone.ZONES) == 64800 # - récupérer la densité de population d'une zone def test_density_population(self): assert self.ZONE.population_density() == 3.851330242248779e-06 # - récupérer l'agréabilité moyenne d'une zone def test_get_average_agreeableness(self): assert self.ZONE.average_agreeableness() == 1
def setup_method(self): self.position1 = script.Position(100, 33) self.position2 = script.Position(101, 34) self.zone = script.Zone(self.position1, self.position2) script.Zone._initialize_zones() agent = script.Agent(self.position1, agreeableness=1) self.zone.inhabitants = [agent]
def setup_class(cls): script.Zone._initialize_zones() cls.ZONE = script.Zone.ZONES[0] cls.GRAPH = script.AgreeablenessGraph() cls.ZONES = script.Zone.ZONES for _ in range(0,10): cls.ZONE.add_inhabitant(script.Agent(script.Position(-180, -89), agreeableness=1))
def setup_method(self): script.Zone._initialize_zones() self.zone = script.Zone.ZONES[0] self.graph = script.AgreeablenessPerAgeGraph() self.zones = script.Zone.ZONES for _ in range(0,10): self.zone.add_inhabitant(script.Agent(script.Position(-180, -89), agreeableness=1, age=50))
def setup_method(self): script.Zone._initialize_zones() self.zone = script.Zone.ZONES[0] self.graph = script.IncomeGraph() self.zones = script.Zone.ZONES for _ in range(0, 10): self.zone.add_inhabitant( script.Agent(script.Position(-180, -89), income=40, age=20))
class TestZone: POSITION1 = script.Position(100, 33) POSITION2 = script.Position(101, 34) ZONE = script.Zone(POSITION1, POSITION2) AGENT = script.Agent(POSITION1, agreeableness=1) # - Zone : # - récupérer un coin inférieur gauche (corner1) def test_zone_corner1(self): assert self.ZONE.corner1 == self.POSITION1 # - récupérer un coin supérieur droit (corner2) def test_zone_corner2(self): assert self.ZONE.corner2 == self.POSITION2 # - trouver une zone qui contient une position def test_find_zone_that_contains(self): found_zone = script.Zone.find_zone_that_contains(self.POSITION1) assert found_zone.corner1.longitude == self.ZONE.corner1.longitude # - ajouter un habitant dans une zone def test_add_inhabitant_in_zone(self): init = self.ZONE.inhabitants self.ZONE.add_inhabitant(self.AGENT) assert len(self.ZONE.inhabitants) == 1 # - récupérer toutes les instances Zone (Zone.ZONES) # On devrait avoir exactement 64800 zones def test_get_zones(self): assert len(script.Zone.ZONES) == 64800 # - récupérer la densité de population d'une zone def test_get_population_density(self): assert self.ZONE.population_density() == 8.087793508722422e-05 # - récupérer l'agréabilité moyenne d'une zone def test_get_average_agreeableness(self): assert self.ZONE.average_agreeableness() == 1 # - AgreeablenessGraph : # - récupérer un titre # - récupérer x_label # - récupérer y_label # - récupérer xy_values sous forme de tuples # - la première valeur de xy_values est la densité de population moyenne # - la seconde valeur de xy_values est l'agréabilité moyenne # - IncomeGraph : # - récupérer un titre # - récupérer x_label # - récupérer y_label # - récupérer xy_values sous forme de tuples # - la première valeur de xy_values est l'âge # - la seconde valeur de xy_values est le revenu
class TestAgent: AGENT = script.Agent(3) # - modifier un attribut position def test_set_position(self): self.AGENT.position = 5 assert self.AGENT.position == 5 # - récupérer un attribut position def test_get_position(self): assert self.AGENT.position == 5 # - assigner un dictionnaire en tant qu'attributs def test_set_agent_attributes(self): agent = script.Agent(3, agreeableness=1) assert agent.agreeableness == 1
def test_set_agent_attributes(self): agent = script.Agent(3, agreeableness=1) assert agent.agreeableness == 1
def setup_method(self): self.agent = script.Agent(3)
def test_add_inhabitant_in_zone(self): agent = script.Agent(self.position1, agreeableness=1) self.zone.add_inhabitant(agent) assert len(self.zone.inhabitants) == 2