def test_getAvailablePlace(self): Place.tous = [] p2 = Place(1, 300, 200, 500, 788) c = Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, Voiture(), 12363663, 144, "12/12/1212", p2, None) Placement(None, p2, c, "date..", None) self.assertEqual(p2.isAvailable(), False) v = Voiture("IMMAT", 100, 200, 40) self.assertEqual(Place.getAvailablePlace(v), None) p2 = Place(1, 300, 200, 500, 788) self.assertNotEqual(Place.getAvailablePlace(v), None) self.assertEqual(Place.getAvailablePlace(v), p2)
def test_estEnCours(self): p2 = Place(1, 300, 200, 500, 788) c = Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, Voiture(), 12363663, 144, "12/12/1212", p2, None) pp = Placement("ID", p2, c, "date..", None) self.assertEqual(pp.estEnCours, True)
def test_recupererVehicule(self): v1 = Voiture() c1 = Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, v1, 12363663, 144, "12/12/1212", None, "W9V69Q27") p2 = Place(1, 300, 200, 500, 778) self.assertEqual(c1.recupererVehicule(), False) Placement(None, p2, c1, "date..", None) self.assertEqual(c1.recupererVehicule(), True)
def test_getServices(self): p2 = Place(1, 300, 200, 500, 788) c = Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, Voiture(), 12363663, 144, "12/12/1212", p2, None) pp = Placement("ID", p2, c, "date..", None) s1 = Service(pp, "26/10/2015", 1, "Livraison") s2 = Service(pp, "28/10/2015", 2, "Livraison 2") self.assertEqual(pp.getServices(), [s1, s2])
def test_effectuerTache(self): p2 = Place(1, 300, 200, 500, 788) c = Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, Voiture(), 12363663, 144, "12/12/1212", p2, None) pp = Placement("ID", p2, c, "date..", None) s = Service(pp, None, 1, "Livraison") s.effectuerTache() self.assertNotEqual(s.dateF, None)
def test_get(self): Placement.tous = [] p2 = Place(1, 300, 200, 500, 788) c = Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, Voiture(), 12363663, 144, "12/12/1212", p2, None) pp = Placement("ID", p2, c, "date..", None) self.assertEqual(Placement.get("ID"), pp) self.assertNotEqual(Placement.get("IDD"), pp)
def test_nbPlaceOccupes(self): Placement.tous = [] self.assertEqual(Placement.nbPlaceOccupes(), 0) p2 = Place(1, 300, 200, 500, 788) c = Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, Voiture(), 12363663, 144, "12/12/1212", p2, None) Placement("ID", p2, c, "date..", None) self.assertEqual(Placement.nbPlaceOccupes(), 1)
def test_creerService(self): p2 = Place(1, 300, 200, 500, 788) c = Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, Voiture(), 12363663, 144, "12/12/1212", p2, None) pp = Placement("ID", p2, c, "date..", None) s = Service(pp, "26/10/2015", 1, "Livraison") self.assertEqual(s.dateF, "26/10/2015") self.assertEqual(s.argument, "Livraison") self.assertEqual(s.placement, pp) self.assertEqual(s.typeService, 1)
def test_create(self): v1 = Voiture() c = Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, v1, 12363663, 144, "12/12/1212", None) self.assertEqual(c.nom, "PEREIRA") self.assertEqual(c.prenom, "Alexandre") self.assertEqual(c.adr, "4 Boulevard Koenings 31300 Toulouse") self.assertEqual(c.placeReserve, None) self.assertEqual(c.cryptoVisuel, 144) self.assertEqual(c.dateExpiration, "12/12/1212") self.assertEqual(c.estAbonne, True) self.assertEqual(c.numCB, 12363663) self.assertEqual(c.voiture, v1)
def test_isAvailable(self): p = Place(1, 300, 200, 500, 777) self.assertEqual(p.isAvailable(), True) # la place a été réservé c = Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, Voiture(), 12363663, 144, "12/12/1212", p, None) self.assertEqual(p.isAvailable(), False) p2 = Place(1, 300, 200, 500, 778) Placement(None, p2, c, "date..", None) self.assertEqual(p2.isAvailable(), False)
def test_creer(self): p2 = Place(1, 300, 200, 500, 788) c = Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, Voiture(), 12363663, 144, "12/12/1212", p2, None) pp = Placement("ID", p2, c, "date..", None) self.assertEqual(pp.client, c) self.assertEqual(pp.dateD, "date..") self.assertEqual(pp.dateF, None) self.assertEqual(pp.id, "ID") self.assertEqual(pp.place, p2) self.assertEqual(pp.services, [])
def loadAll(): """ Cette fonction permet de charger tous les clients qui sont dans la base de donnée. Chaque client présent dans la base de données sont alors instancié. """ con = sqlite3.connect("test.db") with con: con.row_factory = sqlite3.Row cur = con.cursor() for row in cur.execute("""SELECT * FROM Client"""): Client(row["nomClient"], row["prenomClient"], row["adrClient"], True if (row["estAbonne"] == 1) else False, Voiture.get(row["idVoiture"]), row["numCB"], row["cryptoVisuel"], row["dateExpiration"], Place.get(row["placeReserve"]), row["numClient"]) con.close()
def capturerImmat(): """ Cette fonction permet de générer l'immatriculation aléatoirement d'un véhicule :return String: """ chars1 = "".join([random.choice(string.ascii_uppercase) for _ in range(2)]) digits = "".join([random.choice(string.digits) for _ in range(3)]) chars2 = "".join([random.choice(string.ascii_uppercase) for _ in range(2)]) digits2 = "".join([random.choice(string.digits) for _ in range(2)]) d = chars1 + "-" + digits + "-" + chars2 + "(" + digits2 + ")" while Voiture.get(d) != None: chars1 = "".join([random.choice(string.ascii_uppercase) for _ in range(2)]) digits = "".join([random.choice(string.digits) for _ in range(3)]) chars2 = "".join([random.choice(string.ascii_uppercase) for _ in range(2)]) digits2 = "".join([random.choice(string.digits) for _ in range(2)]) d = chars1 + "-" + digits + "-" + chars2 + "(" + digits2 + ")" return d
def test_create_voiture(self): v= Voiture() self.assertNotEquals(v.immatriculation, None) self.assertNotEquals(v.hauteur, None) self.assertNotEquals(v.largeur, None) self.assertNotEquals(v.longueur, None)
def test_get_id(self): v= Voiture("IMMAT", 100, 200, 300) self.assertEquals(v.immatriculation, "IMMAT")
def test_get_dim(self): v= Voiture("IMMAT", 100, 200, 300) self.assertEquals(v.hauteur, 300) self.assertEquals(v.longueur, 100) self.assertEquals(v.largeur, 200)
def test_get_voiture(self): v= Voiture() self.assertEquals(v, Voiture.get(v.immatriculation))
def test_getNbAbonne(self): Client.tous = [] self.assertEqual(Client.getNbAbonne(), 0) Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, Voiture(), 12363663, 144, "12/12/1212", None, "W9V69Q27") self.assertEqual(Client.getNbAbonne(), 1)
def test_get(self): v1 = Voiture() c = Client("PEREIRA", "Alexandre", "4 Boulevard Koenings 31300 Toulouse", True, v1, 12363663, 144, "12/12/1212", None, "W9V69Q27") self.assertEqual(c.num, "W9V69Q27")