Ejemplo n.º 1
0
def check_alerts_and_generate_mail_body(alerts):

    bodyElements = []
    unmatchedAlerts = list(alerts)

    for alert in alerts:
        cid = alert['cid']
        store = alert['store']

        if "###" in cid:
            shop = Eshop(store)
        else:
            shop = Psn(store)

        try:
            item = shop.get_item_by(id=cid)
        except Exception as e:
            print(
                "Did not find an item for id %s in store %s with exception '%s'"
                % (cid, store, e))
            continue

        if (alert_is_matched(alert, item)):
            bodyElements.append(generate_body_element(alert, item))

            unmatchedAlerts.remove(alert)

    body = "\n".join(bodyElements)

    return unmatchedAlerts, body
def check_alerts_and_generate_mail_body(alerts):

    bodyElements = []
    unmatchedAlerts = list(alerts)

    for alert in alerts:
        cid = alert['cid']
        store = alert['store']

        if "###" in cid:
            shop = Eshop(store)
        else:
            shop = Psn(store)

        try:
            item = shop.get_item_by(id=cid)
        except Exception as e:
            print(
                "Did not find an item for id %s in store %s with exception '%s'" %
                (cid, store, e))
            continue

        if (alert_is_matched(alert, item)):
            bodyElements.append(generate_body_element(alert, item))

            unmatchedAlerts.remove(alert)

    body = "\n".join(bodyElements)

    return unmatchedAlerts, body
Ejemplo n.º 3
0
class EshopTest(unittest.TestCase):

    eshop = Eshop(country="DE")

    def test_get_item_for_id(self):
        game_offers = self.eshop.search("Celeste")
        game_offer = game_offers[0]
        assert game_offer.name == "Celeste"

    def test_search_alot(self):
        game_offers = self.eshop.search("a")
        print('\n'.join(str(e) for e in game_offers))
        assert len(game_offers) > 1

    def test_id_encoder(self):
        assert "DE###1207064###Celeste_123" == self.eshop._encode_id(
            id=1207064, name="Celeste 123")

    def test_id_decoder(self):
        assert ("DE", "1207064", "Celeste 123"
                ) == self.eshop._decode_id("DE###1207064###Celeste_123")

    def test_mailfunc(self):
        mailalert("DE/de###1174779###Sonic_Mania,100.00,DE/de",
                  psnmailalert_main)
Ejemplo n.º 4
0
def eshop_main():
    main(Eshop("DE/de"))