class DetectionRbot(TestCase): def setUp(self): self.analyseImageWorld = AnalyseImageWorld() self.analyseImageWorld.chargerImage('images/table2/robotTest1.png') self.detection = DetectionRobot(self.analyseImageWorld.image, 2) def test_detecter(self): self.detection.detecter() self.assertIsNotNone(self.detection.robotIdentifiee) def test_trouverContoursRobot(self): c, h = self.detection.trouverContoursRobot() bool = len(c) >= 2 self.assertTrue(bool) def test_trouverRobot(self): c, h = self.detection.trouverContoursRobot() c = self.detection.eleminerCoutoursNegligeable(c, h) self.detection.trouverRobot(c) self.assertIsNotNone(self.detection.robotIdentifiee) def test_eleminerCoutoursNegligeable(self): c, h = self.detection.trouverContoursRobot() c2 = self.detection.eleminerCoutoursNegligeable(c, h) bool = len(c2) <= len(c) self.assertTrue(bool)
class DetectionIle(TestCase): def setUp(self): self.analyseImageWorld = AnalyseImageWorld() self.analyseImageWorld.chargerImage("images/table2/detection1.png") self.detection = DetectionIles(self.analyseImageWorld.image, 2) def test_detecter(self): self.detection.detecter() nombreTresor = len(self.detection.ilesIdentifiees) self.assertEqual(nombreTresor, 16) def test_trouverContourIles(self): c, h = self.detection.trouverContoursIles("Rouge") bool = len(c) >= 4 self.assertTrue(bool) def test_trouverIles(self): c, h = self.detection.trouverContoursIles("Rouge") self.detection.trouverIles(c, h, "Rouge") bool = len(self.detection.ilesIdentifiees) == len(c) self.assertTrue(bool) def test_eleminerCoutoursNegligeable(self): c, h = self.detection.trouverContoursIles("Rouge") c2 = self.detection.eleminerCoutoursNegligeable(c, h) bool = len(c2) <= len(c) self.assertTrue(bool)
class AnalyseImageWorld(TestCase): def setUp(self): self.analyseImageWorld = AnalyseImageWorld() def test_retourne_bon_nombre_total_elements_apres_detection(self): self.analyseImageWorld.chargerImage('images/table2/detection1.png') self.analyseImageWorld.trouverElementsCartographiques() nombreElement = len(self.analyseImageWorld.elementsCartographiques) self.assertEqual(nombreElement, 19) def test_retourne_bon_nombre_tresors_apres_detection(self): self.analyseImageWorld.chargerImage('images/table2/detection1.png') self.analyseImageWorld.trouverElementsCartographiques() nombreTresor = len(self.analyseImageWorld.tresorIdentifies) self.assertEqual(nombreTresor, 3) def test_retourne_bon_nombre_iles_apres_detection(self): self.analyseImageWorld.chargerImage('images/table2/detection1.png') self.analyseImageWorld.trouverElementsCartographiques() nombreTresor = len(self.analyseImageWorld.ilesIdentifiees) self.assertEqual(nombreTresor, 16) def test_trouverRobot(self): self.analyseImageWorld.chargerImage('images/table2/robotTest1.png') self.analyseImageWorld.trouverRobot() self.assertIsNotNone(self.analyseImageWorld.robotIdentifie) def test_chargement_image(self): self.analyseImageWorld.chargerImage('images/table2/detection1.png') self.assertIsNotNone(self.analyseImageWorld.imageCamera) def test_resultatPlusCommun(self): test = [[1, 2, 3, 4], [1, 2, 3], [1, 2, 3], [1, 2, 3]] list = self.analyseImageWorld.resultatPlusCommun(test) bool = [1, 2, 3].__eq__(list) self.assertTrue(bool)
class DetectionTresor(TestCase): def setUp(self): self.analyseImageWorld = AnalyseImageWorld() self.analyseImageWorld.chargerImage('images/table2/detection1.png') self.detection = DetectionTresors(self.analyseImageWorld.image, 2) def test_detecter(self): self.detection.detecter() nombreTresor = len(self.detection.tresorIdentifies) self.assertEqual(nombreTresor, 3) def test_trouverContourTresors(self): c = self.detection.trouverContoursTresors() bool = len(c) >= 3 self.assertTrue(bool) def test_trouverTresors(self): c = self.detection.trouverContoursTresors() self.detection.trouverTresors(c) bool = len(self.detection.tresorIdentifies) == len(c) self.assertTrue(bool) def test_eliminerTresorsImpossible(self): self.detection.tresorIdentifies.append(Tresor(500, 500)) self.detection.eliminerTresorsImpossibles() bool = self.detection.tresorIdentifies == [] self.assertTrue(bool) def test_eleminerCoutoursNegligeable(self): c, h = self.detection.trouverContoursTresors() c2 = self.detection.eleminerCoutoursNegligeables(c) bool = len(c2) <= len(c) self.assertTrue(bool)