Skip to content

Commit

Permalink
Merge branch 'main' into dizajn
Browse files Browse the repository at this point in the history
  • Loading branch information
darijaaaa authored Mar 29, 2024
2 parents 448a68d + c439112 commit a05b960
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 2 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest Modeli_test.py
24 changes: 24 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Python Tests

on:
pull_request: {}
push: {}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run pytest
run: |
pip install pytest
pytest
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
venv
venv
__pycache__
.pytest_cache
.vscode
2 changes: 1 addition & 1 deletion Modeli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def remove_child(self, child_node):
if child is not child_node]

def dfs_search(self, target):
print(self.depth, self.value, target[self.depth])

if self is None:
return False

Expand Down
33 changes: 33 additions & 0 deletions Modeli_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from Modeli import *
import pytest

aviokompanija = Aviokompanija()
korisnik = Korisnik()

KlasaEkonomska = KlasaLeta(0, [Sediste(0, 1), Sediste(1, 1)], 500) # 0 - ekonomska
KlasaBiznis = KlasaLeta(1, [Sediste(0, 1), Sediste(1, 1)], 1000) # 1 - biznis
KlasaPrva = KlasaLeta(2, [Sediste(0, 1), Sediste(1, 1)], 2500) # 2 - prva

Polazak1 = Destinacija("19:30", "04.04.2024", "London", 0) # 0 - polazak
Dolazak1 = Destinacija("22:00", "04.04.2024", "Madrid", 1) # 1 - dolazak
Polazak2 = Destinacija("12:15", "04.07.2024", "Beograd", 0) # 0 - polazak
Dolazak2 = Destinacija("03:00", "06.07.2024", "Moskva", 1) # 1 - dolazak
Polazak3 = Destinacija("17:00", "12.05.2024", "Kanbera", 0) # 0 - polazak
Dolazak3 = Destinacija("17:55", "12.05.2024", "Sidni", 1) # 1 - dolazak

Let1 = Let(300, 150, [KlasaEkonomska, KlasaBiznis, KlasaPrva], Polazak1, Dolazak1)
Let2 = Let(300, 150, [KlasaEkonomska, KlasaBiznis, KlasaPrva], Polazak2, Dolazak2)
Let3 = Let(300, 150, [KlasaEkonomska, KlasaBiznis, KlasaPrva], Polazak3, Dolazak3)
aviokompanija.dodajLet(Let1)
aviokompanija.dodajLet(Let2)
aviokompanija.dodajLet(Let3)
"""
for child in aviokompanija.getLetovi().children:
print(child.value)
for child2 in child.children:
print(child2.value)
"""

@pytest.mark.parametrize("test_input,expected", [(["London", "04.04.2024", "19:30", "Madrid", "04.04.2024", "22:00"], True), (["Beograd", "04.07.2024", "12:15", "Moskva", "06.07.2024", "03:00"], True), (["Kanbera", "12.05.2024", "17:00", "Sidni", "12.05.2024", "17:55"], True)])
def test_eval(test_input, expected):
assert korisnik.dajArgumente(test_input, aviokompanija) == expected
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
colorama==0.4.6
exceptiongroup==1.2.0
iniconfig==2.0.0
packaging==24.0
pluggy==1.4.0
pytest==8.1.1
tomli==2.0.1

0 comments on commit a05b960

Please sign in to comment.