-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: init factories and write first test.
- Loading branch information
1 parent
921e424
commit 7354578
Showing
5 changed files
with
81 additions
and
4 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,31 @@ | ||
import factory | ||
from src import models | ||
|
||
|
||
class UserFactory(factory.Factory): | ||
class Meta: | ||
model = models.User | ||
|
||
username = factory.Faker("uuidv4") | ||
email = factory.Faker("uuidv4") | ||
|
||
|
||
class UserFavorisFactory(factory.Factory): | ||
class Meta: | ||
model = models.UserFavori | ||
|
||
|
||
class FormationFactory(factory.Factory): | ||
class Meta: | ||
model = models.Formation | ||
|
||
code_nsf = 334 | ||
type = "baccalauréat technologique" | ||
libelle = ( | ||
"bac techno STHR Sciences et technologies de l'hôtellerie et de la restauration" | ||
) | ||
tutelle = "Ministère chargé de l'Éducation nationale et de la Jeunesse" | ||
url = "http://www.onisep.fr/http/redirection/formation/slug/FOR.494" | ||
domain = "hôtellerie-restauration, tourisme/hôtellerie | hôtellerie-restauration, tourisme/restauration" | ||
niveau_de_sortie = "Bac ou équivalent" | ||
duree = "1 an" |
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,20 @@ | ||
import uuid | ||
from sqlalchemy import func | ||
from src.models.formation import Formation | ||
from src.tests.factories.factories import FormationFactory | ||
|
||
|
||
def test_check_if_formation_table_is_empty_should_return_0(db_session): | ||
formation_count = db_session.query(func.count(Formation.id)).scalar() | ||
assert formation_count == 0 | ||
|
||
|
||
def test_create_one_formation_should_return_1(db_session): | ||
formation: Formation = FormationFactory() | ||
db_session.add(formation) | ||
db_session.commit() | ||
|
||
assert formation.id is not None | ||
assert isinstance(formation.id, uuid.UUID) | ||
formation_count = db_session.query(func.count(Formation.id)).scalar() | ||
assert formation_count == 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