from addresser.parser import parse, Address


def test_parser():
    tests = [
        ("Kaiserin Augusta Str 123", Address("Kaiserin Augusta Str", "123")),
        ("Winterallee 3", Address("Winterallee", "3")),
        ("Musterstrasse 45", Address("Musterstrasse", "45")),
        ("Blaufeldweg 123B", Address("Blaufeldweg", "123B")),
        ("Am Bächle 23", Address("Am Bächle", "23")),
        ("Auf der Vogelwiese 23 b", Address("Auf der Vogelwiese", "23 b")),
        ("4, rue de la revolution", Address("rue de la revolution", "4")),
        ("200 Broadway Av", Address("Broadway Av", "200")),
        ("Calle Aduana, 29", Address("Calle Aduana", "29")),
        ("Calle 39 No 1540", Address("Calle 39", "No 1540")),
        # generated
        ("604 Jiménez Valley Suite 759",
         Address("Jiménez Valley", "604")),
        ("24219 Prévost Mountain Suite 924",
         Address("Prévost Mountain", "24219")),
        ("Pasadizo Marino Martin 45",
         Address("Pasadizo Marino Martin", "45")),
        ("набережна Иванова Андрея, 801",
         Address("набережна Иванова Андрея", "801")),
        ("6 Webb Line",
         Address("Webb Line", "6")),
        ("Vial de Trinidad Roig 61",
         Address("Vial de Trinidad Roig", "61")),
        ("Jl. R.E Martadinata No. 342",
         Address("Jl. R.E Martadinata", "No. 342")),
        ("алл. Труда, д. 8",
         Address("алл. Труда", "д. 8")),
        ("пер. Песчаный, д. 901",
         Address("пер. Песчаный", "д. 901")),
        ("Ulica bratov Škofov 8a",
         Address("Ulica bratov Škofov", "8a")),
        ("Verkkopolku 9",
         Address("Verkkopolku", "9")),
        ("מרגיל מחוור 51",
         Address("מרגיל מחוור", "51")),  # this is R2L
        ("מבוא הדס 33",
         Address("מבוא הדס", "33")),  # this is R2L
        ("35256 Garcia Crossroad",
         Address("Garcia Crossroad", "35256")),
        ("和平街9段11號",
         Address("和平街9段11號", "")),
        ("91615 Demir Place",
         Address("Demir Place", "91615")),
        ("17/3008 உதர் தணிகைவேலன்",
         Address("உதர் தணிகைவேலன்", "17/3008")),
        ("대전광역시 노원구 영동대로",
         Address("대전광역시 노원구 영동대로", "")),
        ("345 Piirsalu Underpass",
         Address("Piirsalu Underpass", "345")),
        ("302 Benchapatranon Forges Suite 720",
         Address("Benchapatranon Forges", "302")),
        ("9845 Irène Dale",
         Address("Irène Dale", "9845")),
        ("1508 John Villages Apt. 459",
         Address("John Villages", "1508")),
        ("Perivoj biskupa Stjepana II. 4c",
         Address("Perivoj biskupa Stjepana II.", "4c")),
        ("1093  n63sh",
         Address("n63sh", "1093")),
        ("960 Jasmine Land",
         Address("Jasmine Land", "960")),
        ("ул. Моховая, д. 82 к. 8",
         Address("ул. Моховая", "д. 82")),
        ("Plaza de Angelino Duque 406 Piso 1",
         Address("Plaza de Angelino Duque", "406")),
        ("06650 Supasit Alley Suite 891",
         Address("Supasit Alley", "06650")),
        ("3442 Neringa Keys",
         Address("Neringa Keys", "3442")),
        ("71428 چنگیزی خیابان",
         Address("چنگیزی خیابان", "71428")),
        ("003 بدر Village",
         Address("بدر Village", "003")),
        ("關渡路777號",
         Address("關渡路777號", "")),  # unrecognized
        ("3694 Edward Hill",
         Address("Edward Hill", "3694")),
        ("590 Frank Wall Apt. 682",
         Address("Frank Wall", "590")),
        ("3042 Koit Grove",
         Address("Koit Grove", "3042")),
        ("אלרשיד 77",
         Address("אלרשיד", "77")),
        ("517 Tyler Bypass",
         Address("Tyler Bypass", "517")),
        ("229 Terri Points",
         Address("Terri Points", "229")),
        ("30601 Austra Lock",
         Address("Austra Lock", "30601")),
        ("Rennerring 49",
         Address("Rennerring", "49")),
        ("Hanssenberget 87",
         Address("Hanssenberget", "87")),
        ("76430 Salinas Plaza Apt. 765",
         Address("Salinas Plaza", "76430")),
        ("97296 Krūmiņš Mount Suite 577",
         Address("Krūmiņš Mount", "97296")),
        ("2492 कुलकर्णी",
         Address("कुलकर्णी", "2492")),
        ("Սայաթ-Նովայի 0",
         Address("Սայաթ-Նովայի", "0")),
        ("Kevinsteeg 227",
         Address("Kevinsteeg", "227")),
        ("8809 Laura Motorway Suite 163",
         Address("Laura Motorway", "8809")),
        ("Višnjičke 4a/8",
         Address("Višnjičke", "4a/8")),
        ("74466 Brown Port Apt. 450",
         Address("Brown Port", "74466")),
        ("rue Patricia Jacot-Descombes 3",
         Address("rue Patricia Jacot-Descombes", "3")),
        ("rue Théo Deladoëy 3",
         Address("rue Théo Deladoëy", "3")),
        ("Jalan Merdeka No. 5",
         Address("Jalan Merdeka", "No. 5")),
        ("Rita-Weiser-Straße 3",
         Address("Rita-Weiser-Straße", "3")),
        ("вулиця Бабушкина, 05",
         Address("вулиця Бабушкина", "05")),
        ("Ylänköbulevardi 230",
         Address("Ylänköbulevardi", "230")),
        ("Viale Danilo 629 Appartamento 14",
         Address("Viale Danilo", "629")),
        ("曾路a座",
         Address("曾路a座", "")),
        ("boulevard Chantal Cosendey",
         Address("boulevard Chantal Cosendey", "")),
        ("Գրիգոր Հարությունյան 046",
         Address("Գրիգոր Հարությունյան", "046")),
        ("Svibovac 4b/7",
         Address("Svibovac", "4b/7")),
        ("Studio 16a Chloe wells",
         Address("Studio 16a Chloe wells", "")),
        ("Před Skalkami Ii 3",
         Address("Před Skalkami Ii", "3")),
        ("наб. Школьная, д. 763 к. 4",
         Address("наб. Школьная", "д. 763")),
        # ("ბარისახოს ქ. 58", Address("", "")),

        # very weird ones
        # ("Block 13 Lot 57 King Drive, Mars Homes 1", Address("", "")),
        # ("5th Floor Oliva Suites 8, 6534 54th Highway", Address("", "")),
        # ("Circunvalación Sur Cepeda 489 267", Address("", "")),
    ]

    for t in tests:
        addr_raw, addr_expected = t
        addr_got = parse(addr_raw)
        assert(addr_got.street == addr_expected.street)
        assert(addr_got.number == addr_expected.number)
