Exemple #1
0
def test_diff_insert():
    """Inserting two different useragents will pass"""
    first_ua = UserAgent(ua_string=u"Something/5.0", ua_human_name=u"foo")
    first_ua.save()
    try:
        other_ua = UserAgent(ua_string=u"SomethingElse/5.0", ua_human_name=u"baz")
        other_ua.save()
    except IntegrityError:
        False
    True
Exemple #2
0
def test_diff_insert():
    """Inserting two different useragents will pass"""
    first_ua = UserAgent(ua_string=u"Something/5.0", ua_human_name=u"foo")
    first_ua.save()
    try:
        other_ua = UserAgent(ua_string=u"SomethingElse/5.0",
                             ua_human_name=u"baz")
        other_ua.save()
    except IntegrityError:
        False
    True
Exemple #3
0
def test_unique_human_name_insert():
    """Inserting two human names that are not unique should fail"""
    first_ua = UserAgent(ua_string=u"Mozilla/5.0", ua_human_name=u"foo")
    first_ua.save()

    try:
        other_ua = UserAgent(ua_string=u"Something/5.0",ua_human_name=u"foo")
        other_ua.save()
    except IntegrityError:
        False
    True
Exemple #4
0
def test_unique_human_name_insert():
    """Inserting two human names that are not unique should fail"""
    first_ua = UserAgent(ua_string=u"Mozilla/5.0", ua_human_name=u"foo")
    first_ua.save()

    try:
        other_ua = UserAgent(ua_string=u"Something/5.0", ua_human_name=u"foo")
        other_ua.save()
    except IntegrityError:
        False
    True
Exemple #5
0
def test_unique_insert():
    """Inserting two of the same useragents will fail duplicate key"""
    first_ua = UserAgent(ua_string=u"Something/5.0")
    first_ua.save()

    try:
        other_ua = UserAgent(ua_string=u"Something/5.0")
        other_ua.save()
    except IntegrityError:
        False

    True
Exemple #6
0
def test_length_rightlength():
    """Strings 250 chars or less should pass without warning"""
    super_long_ua = u"b" * 250

    with warnings.catch_warnings():
        warnings.simplefilter('error', MySQLdb.Warning)
        try:
            ua = UserAgent(ua_string=super_long_ua)
            ua.save()
        except:
            False
    True
Exemple #7
0
def test_length_toolong():
    """Strings longer than 250 characters will be truncated, raise warning"""
    super_long_ua = u"a" * 251

    with warnings.catch_warnings():
        warnings.simplefilter('error', MySQLdb.Warning)
        try:
            ua = UserAgent(ua_string=super_long_ua)
            ua.save()
        except:
            True
    False
Exemple #8
0
def test_unique_insert():
    """Inserting two of the same useragents will fail duplicate key"""
    first_ua = UserAgent(ua_string=u"Something/5.0")
    first_ua.save()

    try:
        other_ua = UserAgent(ua_string=u"Something/5.0")
        other_ua.save()
    except IntegrityError:
        False

    True
Exemple #9
0
def test_length_rightlength():
    """Strings 250 chars or less should pass without warning"""
    super_long_ua = u"b" * 250

    with warnings.catch_warnings():
        warnings.simplefilter('error', MySQLdb.Warning)
        try:
            ua = UserAgent(ua_string=super_long_ua)
            ua.save()
        except:
            False
    True
Exemple #10
0
def test_length_toolong():
    """Strings longer than 250 characters will be truncated, raise warning"""
    super_long_ua = u"a" * 251

    with warnings.catch_warnings():
        warnings.simplefilter('error', MySQLdb.Warning)
        try:
            ua = UserAgent(ua_string=super_long_ua)
            ua.save()
        except:
            True
    False