Beispiel #1
0
    def test_clean_all_addresses(self):
        hatchbuck = Hatchbuck("", noop=True)
        self.maxDiff = None

        originalprofile = copy.deepcopy(self.testProfile)
        changedprofile = copy.deepcopy(self.testProfile)
        # fill in test data to be cleaned up
        changedprofile["addresses"].append({
            "id": "1",
            "street": "Klingenstr 1",
            "zip": "8005",
            "city": "Zürich",
            "country": "Switzerland",
            "state": "",
            "type": "Work",
        })
        changedprofile["addresses"].append({
            "id": "2",
            "street": "Klingenstr. 1",
            "zip": "8005",
            "city": "Zurich",
            "country": "Switzerland",
            "state": "",
            "type": "Work",
        })
        changedprofile["addresses"].append({
            "id": "3",
            "state": "ZH",
            "city": "Zurich",
            "country": "Switzerland",
            "type": "Work",
        })
        changedprofile["addresses"].append({
            "id": "4",
            "city": "Zürich",
            "country": "Switzerland",
            "type": "Home"
        })
        changedprofile["addresses"].append({
            "id": "5",
            "country": "Switzerland",
            "type": "Work"
        })

        # reference to compare
        originalprofile["addresses"] = [
            {
                "city": "Zürich",
                "country": "Switzerland",
                "countryId":
                "QmJzeldzQ25rbXluZGc4RzlDYmFmYlZOY2xTemMwX2ZoMll5UTJPenhsNDE1",
                "id":
                "Q0NjajF2U1lTWnBHM1hjRFlnQzhzMHZ2UUxLY2d6a1JaU3Nicm5hRTN6azE1",
                "state": "ZH",
                "street": "Neugasse 10",
                "type": "Work",
                "typeId":
                "SjFENlU0Y2s2RDFpM0NKWEExRmVvSjZ4T3NJMG5pLWNYZjRseDBSaTVfVTE1",
                "zip": "8005",
            },
            {
                "id": "1",
                "street": "Klingenstrasse 1",
                "zip": "8005",
                "city": "Zürich",
                "country": "Switzerland",
                "state": "",
                "type": "Work",
            },
        ]
        self.assertEqual(
            hatchbuck.clean_all_addresses(changedprofile),
            originalprofile,
            "all addresses should have been cleaned and deduplicated",
        )
Beispiel #2
0
from hatchbuck import Hatchbuck
import pprint
import sys
import logging

LOGFORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
logging.basicConfig(level=logging.DEBUG, format=LOGFORMAT)
pp = pprint.PrettyPrinter()

hatchbuck = Hatchbuck(sys.argv[1], noop=False)
profile = hatchbuck.search_email(sys.argv[2])
pp.pprint(profile["addresses"])
profile = hatchbuck.clean_all_addresses(profile)
pp.pprint(profile["addresses"])