def test_provider_resolution(): assert provider_from_address('*****@*****.**') == 'unknown' assert provider_from_address('*****@*****.**') == 'unknown' assert provider_from_address('*****@*****.**') == 'gmail' assert provider_from_address('*****@*****.**') == 'gmail' assert provider_from_address('*****@*****.**') == 'yahoo' assert provider_from_address('*****@*****.**') == 'yahoo' assert provider_from_address('*****@*****.**') == 'outlook' assert provider_from_address('*****@*****.**') == 'outlook' assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'gmail' assert provider_from_address('*****@*****.**') == 'eas' assert provider_from_address('*****@*****.**') == 'fastmail' assert provider_from_address('*****@*****.**') == 'fastmail' assert provider_from_address('*****@*****.**') == 'fastmail' assert provider_from_address('*****@*****.**') == 'icloud' assert provider_from_address('*****@*****.**') == 'icloud' assert provider_from_address('*****@*****.**') == 'gmx' assert provider_from_address('*****@*****.**') == 'gandi' assert provider_from_address('*****@*****.**') == 'gandi' with pytest.raises(InvalidEmailAddressError): provider_from_address('notanemail') with pytest.raises(InvalidEmailAddressError): provider_from_address('not@anemail') with pytest.raises(InvalidEmailAddressError): provider_from_address('notanemail.com') # Register a new provider try: providers.register_info( 'example', { "type": "generic", "imap": ("mail.example.net", 993), "smtp": ("smtp.example.net", 587), "auth": "password", "domains": ["example.com"], "mx_servers": ["mx.example.net"] }) assert provider_from_address('*****@*****.**') == 'example' finally: providers.reset() # Register a filter try: def my_filter(name, info): info['domains'].append('example.net') assert provider_from_address('*****@*****.**') == 'unknown' providers.register_info_filter('aol', my_filter) assert provider_from_address('*****@*****.**') == 'aol' finally: providers.reset()
def test_provider_resolution(): assert provider_from_address('*****@*****.**') == 'unknown' assert provider_from_address('*****@*****.**') == 'unknown' assert provider_from_address('*****@*****.**') == 'gmail' assert provider_from_address('*****@*****.**') == 'gmail' assert provider_from_address('*****@*****.**') == 'yahoo' assert provider_from_address('*****@*****.**') == 'yahoo' assert provider_from_address('*****@*****.**') == 'outlook' assert provider_from_address('*****@*****.**') == 'outlook' assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'gmail' assert provider_from_address('*****@*****.**') == 'eas' assert provider_from_address('*****@*****.**') == 'fastmail' assert provider_from_address('*****@*****.**') == 'fastmail' assert provider_from_address('*****@*****.**') == 'fastmail' assert provider_from_address('*****@*****.**') == 'icloud' assert provider_from_address('*****@*****.**') == 'icloud' assert provider_from_address('*****@*****.**') == 'gmx' assert provider_from_address('*****@*****.**') == 'gandi' assert provider_from_address('*****@*****.**') == 'gandi' with pytest.raises(InvalidEmailAddressError): provider_from_address('notanemail') with pytest.raises(InvalidEmailAddressError): provider_from_address('not@anemail') with pytest.raises(InvalidEmailAddressError): provider_from_address('notanemail.com') # Register a new provider try: providers.register_info('example', { "type": "generic", "imap": ("mail.example.net", 993), "smtp": ("smtp.example.net", 587), "auth": "password", "domains": ["example.com"], "mx_servers": ["mx.example.net"] }) assert provider_from_address('*****@*****.**') == 'example' finally: providers.reset() # Register a filter try: def my_filter(name, info): info['domains'].append('example.net') assert provider_from_address('*****@*****.**') == 'unknown' providers.register_info_filter('aol', my_filter) assert provider_from_address('*****@*****.**') == 'aol' finally: providers.reset()
def test_provider_resolution(): assert provider_from_address('*****@*****.**') == 'unknown' assert provider_from_address('*****@*****.**') == 'unknown' assert provider_from_address('*****@*****.**') == 'gmail' assert provider_from_address('*****@*****.**') == 'yahoo' assert provider_from_address('*****@*****.**') == 'yahoo' assert provider_from_address('*****@*****.**') == 'outlook' assert provider_from_address('*****@*****.**') == 'outlook' assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'eas' assert provider_from_address('*****@*****.**') == 'fastmail' assert provider_from_address('*****@*****.**') == 'fastmail' assert provider_from_address('*****@*****.**') == 'fastmail' assert provider_from_address('*****@*****.**') == 'icloud' assert provider_from_address('*****@*****.**') == 'icloud' assert provider_from_address('*****@*****.**') == 'gmx' assert provider_from_address('*****@*****.**') == 'gandi' assert provider_from_address('*****@*****.**') == 'gandi' assert provider_from_address('*****@*****.**') == 'eas' assert provider_from_address('*****@*****.**') == 'gmail' assert provider_from_address('*****@*****.**') == 'gmail' assert provider_from_address('*****@*****.**') == 'eas' assert provider_from_address('*****@*****.**') == 'eas' assert provider_from_address('*****@*****.**') == 'unknown' with pytest.raises(InvalidEmailAddressError): provider_from_address('notanemail') with pytest.raises(InvalidEmailAddressError): provider_from_address('not@anemail') with pytest.raises(InvalidEmailAddressError): provider_from_address('notanemail.com') try: # Registering a new provider assert provider_from_address('*****@*****.**') == 'unknown' providers.register_info( 'example', { "type": "generic", "imap": ("mail.example.net", 993), "smtp": ("smtp.example.net", 587), "auth": "password", "domains": ["example.com"], "mx_servers": ["mx.example.net"] }) assert provider_from_address('*****@*****.**') == 'example' # Registering some filters def aol_filter(info, provider, email): info['domains'].append('example.net') def wildcard_filter(info, provider, email): if provider == 'zimbra': info['domains'].append('example.org') assert provider_from_address('*****@*****.**') == 'unknown' assert provider_from_address('*****@*****.**') == 'unknown' providers.register_info_filter('aol', aol_filter) providers.register_info_filter(None, wildcard_filter) assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'zimbra' # Modifying provider info based on the email address def email_address_filter(info, provider, email): if email == '*****@*****.**': info['imap'] = ('imap2.example.com', 994) orig_imap = tuple(providers['yahoo']['imap']) assert (providers.lookup_info( 'yahoo', '*****@*****.**')['imap'] == orig_imap) assert (providers.lookup_info( 'yahoo', '*****@*****.**')['imap'] == orig_imap) providers.register_info_filter(None, email_address_filter) assert (providers.lookup_info( 'yahoo', '*****@*****.**')['imap'] == ('imap2.example.com', 994)) assert (providers.lookup_info( 'yahoo', '*****@*****.**')['imap'] == orig_imap) finally: providers.reset()
def test_provider_resolution(): assert provider_from_address('*****@*****.**') == 'unknown' assert provider_from_address('*****@*****.**') == 'unknown' assert provider_from_address('*****@*****.**') == 'gmail' assert provider_from_address('*****@*****.**') == 'yahoo' assert provider_from_address('*****@*****.**') == 'yahoo' assert provider_from_address('*****@*****.**') == 'outlook' assert provider_from_address('*****@*****.**') == 'outlook' assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'eas' assert provider_from_address('*****@*****.**') == 'fastmail' assert provider_from_address('*****@*****.**') == 'fastmail' assert provider_from_address('*****@*****.**') == 'fastmail' assert provider_from_address('*****@*****.**') == 'icloud' assert provider_from_address('*****@*****.**') == 'icloud' assert provider_from_address('*****@*****.**') == 'gmx' assert provider_from_address('*****@*****.**') == 'gandi' assert provider_from_address('*****@*****.**') == 'gandi' assert provider_from_address('*****@*****.**') == 'outlook' assert provider_from_address('*****@*****.**') == 'gmail' assert provider_from_address('*****@*****.**') == 'gmail' assert provider_from_address('*****@*****.**') == 'eas' assert provider_from_address('*****@*****.**') == 'eas' with pytest.raises(InvalidEmailAddressError): provider_from_address('notanemail') with pytest.raises(InvalidEmailAddressError): provider_from_address('not@anemail') with pytest.raises(InvalidEmailAddressError): provider_from_address('notanemail.com') try: # Registering a new provider assert provider_from_address('*****@*****.**') == 'unknown' providers.register_info('example', { "type": "generic", "imap": ("mail.example.net", 993), "smtp": ("smtp.example.net", 587), "auth": "password", "domains": ["example.com"], "mx_servers": ["mx.example.net"] }) assert provider_from_address('*****@*****.**') == 'example' # Registering some filters def aol_filter(info, provider, email): info['domains'].append('example.net') def wildcard_filter(info, provider, email): if provider == 'zimbra': info['domains'].append('example.org') assert provider_from_address('*****@*****.**') == 'unknown' assert provider_from_address('*****@*****.**') == 'unknown' providers.register_info_filter('aol', aol_filter) providers.register_info_filter(None, wildcard_filter) assert provider_from_address('*****@*****.**') == 'aol' assert provider_from_address('*****@*****.**') == 'zimbra' # Modifying provider info based on the email address def email_address_filter(info, provider, email): if email == '*****@*****.**': info['imap'] = ('imap2.example.com', 994) orig_imap = tuple(providers['yahoo']['imap']) assert (providers.lookup_info('yahoo', '*****@*****.**')['imap'] == orig_imap) assert (providers.lookup_info('yahoo', '*****@*****.**')['imap'] == orig_imap) providers.register_info_filter(None, email_address_filter) assert (providers.lookup_info('yahoo', '*****@*****.**')['imap'] == ('imap2.example.com', 994)) assert (providers.lookup_info('yahoo', '*****@*****.**')['imap'] == orig_imap) finally: providers.reset()
def test_provider_resolution(): assert provider_from_address("*****@*****.**") == "unknown" assert provider_from_address("*****@*****.**") == "unknown" assert provider_from_address("*****@*****.**") == "gmail" assert provider_from_address("*****@*****.**") == "yahoo" assert provider_from_address("*****@*****.**") == "yahoo" assert provider_from_address("*****@*****.**") == "outlook" assert provider_from_address("*****@*****.**") == "outlook" assert provider_from_address("*****@*****.**") == "aol" assert provider_from_address("*****@*****.**") == "aol" assert provider_from_address("*****@*****.**") == "aol" assert provider_from_address("*****@*****.**") == "eas" assert provider_from_address("*****@*****.**") == "fastmail" assert provider_from_address("*****@*****.**") == "fastmail" assert provider_from_address("*****@*****.**") == "fastmail" assert provider_from_address("*****@*****.**") == "icloud" assert provider_from_address("*****@*****.**") == "icloud" assert provider_from_address("*****@*****.**") == "gmx" assert provider_from_address("*****@*****.**") == "gandi" assert provider_from_address("*****@*****.**") == "gandi" assert provider_from_address("*****@*****.**") == "eas" assert provider_from_address("*****@*****.**") == "gmail" assert provider_from_address("*****@*****.**") == "gmail" assert provider_from_address("*****@*****.**") == "eas" assert provider_from_address("*****@*****.**") == "eas" assert provider_from_address("*****@*****.**") == "unknown" with pytest.raises(InvalidEmailAddressError): provider_from_address("notanemail") with pytest.raises(InvalidEmailAddressError): provider_from_address("not@anemail") with pytest.raises(InvalidEmailAddressError): provider_from_address("notanemail.com") try: # Registering a new provider assert provider_from_address("*****@*****.**") == "unknown" providers.register_info( "example", { "type": "generic", "imap": ("mail.example.net", 993), "smtp": ("smtp.example.net", 587), "auth": "password", "domains": ["example.com"], "mx_servers": ["mx.example.net"], }, ) assert provider_from_address("*****@*****.**") == "example" # Registering some filters def aol_filter(info, provider, email): info["domains"].append("example.net") def wildcard_filter(info, provider, email): if provider == "zimbra": info["domains"].append("example.org") assert provider_from_address("*****@*****.**") == "unknown" assert provider_from_address("*****@*****.**") == "unknown" providers.register_info_filter("aol", aol_filter) providers.register_info_filter(None, wildcard_filter) assert provider_from_address("*****@*****.**") == "aol" assert provider_from_address("*****@*****.**") == "zimbra" # Modifying provider info based on the email address def email_address_filter(info, provider, email): if email == "*****@*****.**": info["imap"] = ("imap2.example.com", 994) orig_imap = tuple(providers["yahoo"]["imap"]) assert providers.lookup_info("yahoo", "*****@*****.**")["imap"] == orig_imap assert providers.lookup_info("yahoo", "*****@*****.**")["imap"] == orig_imap providers.register_info_filter(None, email_address_filter) assert providers.lookup_info("yahoo", "*****@*****.**")["imap"] == ("imap2.example.com", 994) assert providers.lookup_info("yahoo", "*****@*****.**")["imap"] == orig_imap finally: providers.reset()