Skip to content

Commit

Permalink
Add __str__ for AffiliateOffer model (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamanikeev authored and Stranger6667 committed Jun 18, 2018
1 parent a59393e commit 17c46cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pyoffers/models/affiliate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class AffiliateOffer(Model):
"""
Model that defines relation between Offer and Affiliate
"""
def __str__(self):
return '{}: {}'.format(self.__class__.__name__, self.approval_status)


class AffiliateOfferManager(InvisibleModelManager):
Expand Down
10 changes: 9 additions & 1 deletion tests/models/test_affiliate.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# coding: utf-8
from unittest.mock import Mock

import pytest

from pyoffers.exceptions import HasOffersException
from pyoffers.models import Affiliate, AffiliateUser, OfferFile
from pyoffers.models import Affiliate, AffiliateOffer, AffiliateUser, OfferFile


CASSETTE_NAME = 'affiliate'
Expand Down Expand Up @@ -68,3 +70,9 @@ def test_get_offer_files_with_creative_code(affiliate):
assert len(files) == 1
assert isinstance(files[0], OfferFile)
assert files[0].creativecode == 'http://www.example.com'


def test_affiliate_offer_str():
affiliate_offer = AffiliateOffer(manager=Mock())
affiliate_offer.approval_status = 'approved'
assert str(affiliate_offer) == 'AffiliateOffer: approved'

0 comments on commit 17c46cb

Please sign in to comment.