示例#1
0
 def test_checkCurrentlyReducedItem_NoPlusReduction(self):
     store = "DE/de"
     item = psn.getItemForCid("EP9000-CUSA00194_00-UNTILDAWN0000001", store)
     print("Checking: ", item['name'])
     assert psn.getNormalPrice(item) == 59.99
     assert psn.getPlaystationPlusPrice(item) == None
     assert psn.getNonPlaystationPlusPrice(item) == 44.99
     assert psn.getPrice(item) == 44.99
示例#2
0
 def test_checkCurrentlyReducedItem_AllPrices(self):
     store = "DE/de"
     item = psn.getItemForCid("EP2107-CUSA00327_00-DONTSTARVEPS4V01", store)
     print("Checking: ", item['name'])
     assert psn.getNormalPrice(item) == 13.99
     assert psn.getPlaystationPlusPrice(item) == 4.89
     assert psn.getNonPlaystationPlusPrice(item) == 6.99
     assert psn.getPrice(item) == 4.89
示例#3
0
def generateBodyElement(alert, item):

    returnBody = []
    store = alert['store']
    returnBody.append("<p><img src='" + psn.getImage(item) + "'/></p>")
    returnBody.append("<p>" + psn.getName(item) + "</p>")
    returnBody.append("<p>Wished: " + str(alert['price']) +
                      (psn.getCurrencySymbol(store)) + "</p>")
    returnBody.append("<p>Is now: " + str(psn.getPrice(item)) +
                      (psn.getCurrencySymbol(store)) + "</p>")

    return "\n".join(returnBody)
示例#4
0
def checkWishPrice(cid, store, wishPrice):

    item = psn.getItemForCid(cid, store)
    normalPrice = psn.getPrice(item)
    name = psn.getName(item)

    if (normalPrice > wishPrice):
        utils.print_enc(("Wish price {0:.2f} for '" + name +
                         "' does not yet match {1:.2f}, exiting").format(
                             wishPrice, normalPrice))
        return False
    else:
        utils.print_enc(
            ("Wish price {0:.2f} for '" + name +
             "' matched. Is now: {1:.2f}").format(wishPrice, normalPrice))
        return True
示例#5
0
def formatItems(items):
    cids = []
    foundItems = []

    for item in items:
        try:
            logging.debug("Parsing:\n" + utils.prettyPrintJson(item))
            name = item['name']
            itemType = item['game_contentType']
            cid = item['id']
            price = str(psn.getPrice(item))

            platform = ", ".join(item['playable_platform'])
            foundItems.append((cid + "\t" + name + "\t" + platform + "\t" +
                               price + "\t" + itemType))
            cids.append(cid)
        except Exception as e:
            logging.exception(e)

    return foundItems
示例#6
0
    def test_getPlaystationPlusPrice(self):
        store = "DE/de"
        item = psn.getItemForCid(self.freeForPlusCid, store)

        print(
            "Using '" + item['name'] + "' (" + self.freeForPlusCid +
            ") from " + store +
            " for comparison. Item must be free for Plus members in order to pass the unit test. This might fail due to price changes"
        )

        assert item is not None

        normalPrice = psn.getPrice(item)
        plusPrice = psn.getPlaystationPlusPrice(item)

        print("Normal Price: ", "%.2f" % normalPrice, "Plus Price: ",
              "%.2f" % plusPrice)

        assert type(normalPrice) is float
        assert type(plusPrice) is float
        assert plusPrice == 0
示例#7
0
def alertIsMatched(alert, item):
    return float(psn.getPrice(item)) <= float(alert['price'])