diff --git a/.gitignore b/.gitignore index f0da2a1..3eeac6b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ docs/_build build/ dist/ +.pytest_cache +__pycache__ diff --git a/mxsniff/providers.py b/mxsniff/providers.py index 57049a3..fd3da42 100644 --- a/mxsniff/providers.py +++ b/mxsniff/providers.py @@ -457,7 +457,6 @@ 'title': "Yahoo Small Business", }, 'yandex': {'mx': [ - 'mx.yandex.net', 'mx.yandex.ru', ], 'title': "Yandex", @@ -465,6 +464,12 @@ 'public': True, 'canonical_flags': {'lowercase': True}, }, + 'yandex-hosted': {'mx': [ + 'mx.yandex.net', + ], + 'title': "Yandex Mail for Domain", + 'canonical_flags': {'lowercase': True}, + }, 'yodns': {'mx': [ '*.yodns.com', ]}, diff --git a/runtests.sh b/runtests.sh index b6d04b2..4d2d5c5 100755 --- a/runtests.sh +++ b/runtests.sh @@ -1,3 +1,3 @@ #!/bin/sh -coverage run `which nosetests` +coverage run -m pytest "$@" coverage report -m diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_sniff.py b/tests/test_sniff.py new file mode 100644 index 0000000..74c69a0 --- /dev/null +++ b/tests/test_sniff.py @@ -0,0 +1,30 @@ +import unittest +from mxsniff import mxsniff + + +class MXSniffTestCase(unittest.TestCase): + def test_mxsniff(self): + result = mxsniff('google.com') + self.assertFalse(result['public']) + self.assertIn('google-apps', result['match']) + self.assertGreater(len(result['mx']), 0) + + result = mxsniff('gmail.com') + self.assertTrue(result['public']) + self.assertIn('google-gmail', result['match']) + self.assertEqual(len(result['mx']), 0) + + result = mxsniff('hasgeek.com') + self.assertFalse(result['public']) + self.assertIn('google-apps', result['match']) + self.assertGreater(len(result['mx']), 0) + + result = mxsniff('yandex.ru') + self.assertTrue(result['public']) + self.assertIn('yandex', result['match']) + self.assertEqual(len(result['mx']), 0) + + result = mxsniff('vayve.in') + self.assertFalse(result['public']) + self.assertIn('yandex-hosted', result['match']) + self.assertGreater(len(result['mx']), 0)