예제 #1
0
    def test_url_protocol_fix():
        bad_url = 'flickr.com'
        tls_support_cache = {}
        result = CleanupFunctions.cleanup_url(bad_url, tls_support_cache)
        expected = "'https://flickr.com'"

        bad_http = 'neverssl.com'
        result_http = CleanupFunctions.cleanup_url(bad_http, tls_support_cache)
        expected_http = "'http://neverssl.com'"
        assert result == expected
        assert result_http == expected_http
예제 #2
0
    def test_url_protocol_fix():
        bad_url = "flickr.com"
        tls_support_cache = {}
        result = CleanupFunctions.cleanup_url(bad_url, tls_support_cache)
        expected = "'https://flickr.com'"

        bad_http = "neverssl.com"
        TlsTest.test_tls_supported = MagicMock(return_value=False)
        result_http = CleanupFunctions.cleanup_url(bad_http, tls_support_cache)
        expected_http = "'http://neverssl.com'"
        assert result == expected
        assert result_http == expected_http
예제 #3
0
    def test_tag_blacklist():
        tags = [
            {
                "name": "cc0"
            },
            {
                "name": " cc0"
            },
            {
                "name": "valid",
                "accuracy": 0.99
            },
            {
                "name": "valid_no_accuracy"
            },
            {
                "name": "garbage:=metacrap",
            },
        ]
        result = str(CleanupFunctions.cleanup_tags(tags))
        expected = str(
            Json([{
                "name": "valid",
                "accuracy": 0.99
            }, {
                "name": "valid_no_accuracy"
            }]))

        assert result == expected
예제 #4
0
    def test_tag_blacklist():
        tags = [
            {
                'name': 'cc0'
            },
            {
                'name': ' cc0'
            },
            {
                'name': 'valid',
                'accuracy': 0.99
            },
            {
                'name': 'valid_no_accuracy'
            },
            {
                'name': 'garbage:=metacrap',
            }
        ]
        result = str(CleanupFunctions.cleanup_tags(tags))
        expected = str(Json([
            {'name': 'valid', 'accuracy': 0.99},
            {'name': 'valid_no_accuracy'}
        ]))

        assert result == expected
예제 #5
0
 def test_tag_no_update():
     tags = [
         {
             'name': 'valid',
             'accuracy': 0.92
         }
     ]
     result = CleanupFunctions.cleanup_tags(tags)
     assert result is None
예제 #6
0
 def test_accuracy_filter():
     tags = [{
         'name': 'inaccurate',
         'accuracy': 0.5
     }, {
         'name': 'accurate',
         'accuracy': 0.999
     }]
     result = str(CleanupFunctions.cleanup_tags(tags))
     expected = str(Json([{'name': 'accurate', 'accuracy': 0.999}]))
     assert result == expected
예제 #7
0
 def test_accuracy_filter():
     tags = [
         {
             "name": "inaccurate",
             "accuracy": 0.5
         },
         {
             "name": "accurate",
             "accuracy": 0.999
         },
     ]
     result = str(CleanupFunctions.cleanup_tags(tags))
     expected = str(Json([{"name": "accurate", "accuracy": 0.999}]))
     assert result == expected
예제 #8
0
 def test_tag_no_update():
     tags = [{"name": "valid", "accuracy": 0.92}]
     result = CleanupFunctions.cleanup_tags(tags)
     assert result is None