def SortirajAutomobile(self, kriterijum): ''' Metoda koja prima parametar kriterujama za sortiranje koji prosledjuje kontroleru od kojeg dobija sortiranu kolekciju koju koristi pri ponovnom osvezavanju graficke komponente za prikaz. ''' if (kriterijum == 'Maksimalna brzina'): sortiranaKolekcija = sortirajAutomobile('maksimalna_brzina') for i in self.treeAutomobili.get_children(): self.treeAutomobili.delete(i) for index, i in enumerate(sortiranaKolekcija): self.treeAutomobili.insert("", 'end' ,text = index + 1, values = (i.oznaka, i.opis, i.izlozbeni_prostor.oznaka)) elif(kriterijum == 'Broj sedista'): sortiranaKolekcija = sortirajAutomobile('broj_sedista') for i in self.treeAutomobili.get_children(): self.treeAutomobili.delete(i) for index, i in enumerate(sortiranaKolekcija): self.treeAutomobili.insert("", 'end' ,text = index + 1, values = (i.oznaka, i.opis, i.izlozbeni_prostor.oznaka))
def test_sortiraj_automobile_similar(): with pytest.raises(ValueError): sortirajAutomobile('maksimalna_brzinaa')
def test_sortiraj_automobile_reverse_case(): with pytest.raises(ValueError): sortirajAutomobile('MAKSIMALNA_BRZINA')
def test_sortiraj_automobile_int(): with pytest.raises(ValueError): sortirajAutomobile(123)
def test_sortiraj_automobile_none(): with pytest.raises(ValueError): sortirajAutomobile(None)
def test_sortiraj_automobile_pogresna_vrednost(): with pytest.raises(ValueError): sortirajAutomobile('asdfasdfasdfasdfasdf')
def test_sortiraj_automobile(): sorted = sortirajAutomobile('maksimalna_brzina') assert sorted != None assert len(sorted) == len(Projekat().automobili)