class FieldTestCase(unittest.TestCase):
    def setUp(self):
        self.field = None

    def tearDown(self):
        if self.field is not None:
            del self.field

    def test_decimal_field(self):
        self.field = Field(Decimal)
        self.assertEqual(type(self.field.deserialize("1.23")), Decimal)

    def test_string_field(self):
        self.field = Field(str)
        self.assertEqual(type(self.field.deserialize("1.23")), str)
Esempio n. 2
0
class SeatBid(Serializable):
    """At least one seatbid object is required in a bid response object.
    A bid response can contain multiple “seatbid” objects, each on behalf of a different bidder seat.
    Since a bid request can include multiple impressions,
    each “seatbid” object can contain multiple bids each pertaining to a different impression on behalf of a seat.
    Thus, each “bid” object must include the impression ID to which it pertains as well as the bid price.
    The “group” attribute can be used to specify if a seat is willing to accept
    any impressions that it can win (default) or if it is only interested
    in winning any if it can win them all (i.e., all or nothing).
    """

    #: Array of 1+ Bid objects (Section 4.2.3) each related to an impression.
    #: Multiple bids can relate to the same impression.
    bid = Field(Array(Bid), required=True)

    #: ID of the bidder seat on whose behalf this bid is made.
    seat = Field(String)
Esempio n. 3
0
class BidResponse(Serializable):
    """The top-level bid response object.
    The “id” attribute is a reflection of the bid request ID for logging purposes.
    Similarly, “bidid” is an optional response tracking ID for bidders.
    If specified, it can be included in the subsequent win notice call if the bidder wins.
    At least one “seatbid” object is required, which contains a bid on at least one impression.
    Other attributes are optional since an exchange may establish default values.
    """

    #: ID of the bid request to which this is a response.
    id = Field(String, required=True)

    #: Array of seatbid objects; 1+ required if a bid is to be made.
    seatbid = Field(Array(SeatBid), required=True)

    #: Bidder generated response ID to assist with logging/tracking.
    bidid = Field(String)

    #: Bid currency using ISO-4217 alpha codes.
    cur = Field(String)
Esempio n. 4
0
class BidRequest(Serializable):
    id = Field(String, required=True)

    bcat = Field(Array(String))

    imp = Field(Array(Impression), required=True)

    site = Field(Site)

    user = Field(User)

    device = Field(Device)

    def __str__(self):
        return str(self.serialize())
Esempio n. 5
0
class Site(Serializable):
    id = Field(String)

    cat = Field(Array(String))
 def test_string_field(self):
     self.field = Field(str)
     self.assertEqual(type(self.field.deserialize("1.23")), str)
 def test_decimal_field(self):
     self.field = Field(Decimal)
     self.assertEqual(type(self.field.deserialize("1.23")), Decimal)
Esempio n. 8
0
class Impression(Serializable):
    id = Field(String, required=True)
Esempio n. 9
0
class User(Serializable):
    id = Field(String)
Esempio n. 10
0
class Device(Serializable):
    ua = Field(String)

    ip = Field(String)