Skip to content

Commit

Permalink
Black
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl committed Oct 29, 2024
1 parent db862e2 commit d29b54d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions apptax/taxonomie/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ class TMedias(db.Model):
taxon = db.relationship(Taxref, back_populates="medias")

@hybrid_property
def media_url(self):
def media_url(self):
if self.url:
return self.url
elif self.chemin:
elif self.chemin:
return url_for("media_taxhub", filename=self.chemin, _external=True)

def __repr__(self):
Expand Down
17 changes: 6 additions & 11 deletions apptax/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,12 @@ def test_taxref_comparison(self):
assert not cinnamon <= capra_ibex
assert not capra_ibex <= cinnamon


def test_tmedias_media_url_url(self, nom_with_media):
taxon = db.session.execute(
sa.select(Taxref).where(Taxref.cd_nom == 60577)
).scalar_one()
assert len(taxon.medias) == 1
def test_tmedias_media_url_url(self, nom_with_media):
taxon = db.session.execute(sa.select(Taxref).where(Taxref.cd_nom == 60577)).scalar_one()
assert len(taxon.medias) == 1
assert taxon.medias[0].media_url == "http://photo.com"

def test_tmedias_media_url_chemin(self, nom_with_media_chemin):
taxon = db.session.execute(
sa.select(Taxref).where(Taxref.cd_nom == 60577)
).scalar_one()

def test_tmedias_media_url_chemin(self, nom_with_media_chemin):
taxon = db.session.execute(sa.select(Taxref).where(Taxref.cd_nom == 60577)).scalar_one()
assert len(taxon.medias) == 1
assert taxon.medias[0].media_url.endswith("media/taxhub/mon_image.jpg")

0 comments on commit d29b54d

Please sign in to comment.