Beispiel #1
0
 def test_two_populations(self):
     key = self.population1.individual_next_key()
     individual = Individual(id=key)
     individual.put(self.population1.name)
     individual.put(self.population2.name)
     self.assertIsInstance(individual.get(), Individual)
     self.assertIsInstance(individual.get(as_dict=True), dict)
Beispiel #2
0
 def test_put(self):
     key = self.population1.individual_next_key()
     individual = Individual(id=key)
     individual.another_property = "test"
     self.assertEqual(individual.put(self.population1.name), True)
     self.assertEqual(individual.id, key)
     self.assertEqual(individual.another_property, "test")
Beispiel #3
0
    def test_get(self):
        key = self.population1.individual_next_key()
        individual = Individual(id=key)

        #No se puede hacer get sin guardar antes
        try:
            self.assertRaises(LookupError, individual.get())
        except:
            pass
        individual.put(self.population1.name)
        self.assertIsInstance(individual.get(), Individual)
        self.assertIsInstance(individual.get(as_dict=True), dict)
Beispiel #4
0
def get_individual(key, as_dict=True):
    return Individual(id=key).get(as_dict=as_dict)
Beispiel #5
0
 def test_as_dict(self):
     key = self.population1.individual_next_key()
     individual = Individual(id=key)
     self.assertIsInstance(individual.as_dict(), dict)