Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Usprawnione odpinanie miejsc pracy (#1229)
- Loading branch information
1 parent
8944e42
commit e43231c
Showing
12 changed files
with
377 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
from datetime import timedelta | ||
|
||
import pytest | ||
|
||
from fixtures import * # noqa | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def today(): | ||
from django.utils import timezone | ||
|
||
return timezone.now().date() | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def yesterday(today): | ||
return today - timedelta(days=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import os | ||
|
||
import pytest | ||
from django.core.files.uploadedfile import SimpleUploadedFile | ||
from model_mommy import mommy | ||
|
||
from import_pracownikow.models import ImportPracownikow | ||
|
||
from bpp.models import Autor, Jednostka | ||
|
||
|
||
def testdata_xls_path_factory(suffix=""): | ||
return os.path.join(os.path.dirname(__file__), "", f"testdata{suffix}.xlsx") | ||
|
||
|
||
def import_pracownikow_factory(user, path): | ||
i = ImportPracownikow(owner=user) | ||
i.plik_xls = SimpleUploadedFile( | ||
"import_dyscyplin_zrodel_przyklad.xlsx", open(path, "rb").read() | ||
) | ||
i.save() | ||
return i | ||
|
||
|
||
@pytest.fixture | ||
def testdata_xlsx_path(): | ||
return testdata_xls_path_factory() | ||
|
||
|
||
@pytest.fixture | ||
def testdata_brak_naglowka_xlsx_path(): | ||
return testdata_xls_path_factory("_brak_naglowka") | ||
|
||
|
||
@pytest.fixture | ||
def autor_z_pliku(): | ||
return mommy.make(Autor, nazwisko="Kowalski", imiona="Jan", pk=50) | ||
|
||
|
||
@pytest.fixture | ||
def jednostka_z_pliku(): | ||
return mommy.make( | ||
Jednostka, | ||
nazwa="Katedra i Klinika Dermatologii, Wenerologii i Dermatologii Dziecięcej", | ||
skrot="Kat. i Klin. Derm., Wen. i Derm. Dz.", | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def baza_importu_pracownikow(autor_z_pliku, jednostka_z_pliku): | ||
pass | ||
|
||
|
||
@pytest.fixture | ||
def autor_spoza_pliku(): | ||
return mommy.make(Autor, nazwisko="Nowak", imiona="Marian", pk=100) | ||
|
||
|
||
@pytest.fixture | ||
def jednostka_spoza_pliku() -> Jednostka: | ||
return mommy.make( | ||
Jednostka, | ||
nazwa="Jednostka Spozaplikowa", | ||
skrot="Jedn. Spoz.", | ||
zarzadzaj_automatycznie=True, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def import_pracownikow(admin_user, baza_importu_pracownikow, testdata_xlsx_path): | ||
return import_pracownikow_factory(admin_user, testdata_xlsx_path) | ||
|
||
|
||
@pytest.fixture | ||
def import_pracownikow_performed(import_pracownikow) -> ImportPracownikow: | ||
import_pracownikow.perform() | ||
return import_pracownikow | ||
|
||
|
||
@pytest.fixture | ||
def import_pracownikow_brak_naglowka(admin_user, testdata_brak_naglowka_xlsx_path): | ||
return import_pracownikow_factory(admin_user, testdata_brak_naglowka_xlsx_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.