def test_operacje_naprzemian(self): a = automat.Automat(automat.LISTA_NOMINALOW) a.dodaj_bilet(automat.Bilet(60, "ulgowy", 240)) a.wrzuc_monety(500) a.wrzuc_monety(10) a.dodaj_bilet(automat.Bilet(40, "normalny", 380)) a.wrzuc_monety(100) a.wrzuc_monety(10) zwrocone = a.zaplac() self.assertEqual(zwrocone, {x: 0 for x in a.nominaly})
def test_odliczona_kwota(self): a = automat.Automat(automat.LISTA_NOMINALOW) b = automat.Bilet(50, "ulgowy", 240) a.dodaj_bilet(b) a.wrzuc_monety(200) a.wrzuc_monety(20, 2) self.assertEqual(a.zaplac(), {x: 0 for x in a.nominaly})
def test_nieudane_wydanie_reszty(self): a = automat.Automat(automat.LISTA_NOMINALOW) b = automat.Bilet(60, "ulgowy", 240) a.dodaj_bilet(b) a.wrzuc_monety(500) wrzucone = a.wrzucone.copy() zwrocone = a.zaplac() self.assertEqual(zwrocone, wrzucone)
def test_udane_wydanie_reszty(self): a = automat.Automat(automat.LISTA_NOMINALOW) b = automat.Bilet(50, "ulgowy", 240) a.napelnij(2) a.dodaj_bilet(b) a.wrzuc_monety(500) reszta = a.zaplac() self.assertEqual(a.suma_monet(reszta), 260)
def odswiez_bilet(self): """ Metoda aktualizująca ilość biletów wybranych przez użytkownika oraz łączną kwotę do zapłaty za nie. """ self.automat.usun_bilet_all() for typ, bilet in self.bilety_count.items(): for dlugosc_cena, ile in bilet.items(): dlugosc, cena = dlugosc_cena.split(',') self.automat.dodaj_bilet( automat.Bilet(dlugosc, typ, int(cena)), ile.get()) self.do_zaplaty.set(self.automat.do_zaplaty()) update_var(self.do_zaplaty, self.do_zaplaty_string)
def test_dwa_rozne_bilety(self): a = automat.Automat(automat.LISTA_NOMINALOW) a.dodaj_bilet(automat.Bilet(60, "ulgowy", 240)) a.dodaj_bilet(automat.Bilet(60, "normalny", 480)) self.assertEqual(a.do_zaplaty(), 240 + 480)