test_utils.py 880 Bytes
Newer Older
1
# Copyright (C) 2011 Lukas Lalinsky
2
# Distributed under the MIT license, see the LICENSE file for details.
3

4
from nose.tools import assert_equals, assert_raises, assert_true, assert_false
5
from acoustid.utils import singular, is_uuid, provider, is_foreignid
6 7 8 9 10 11


def test_singular():
    assert_equals('artist', singular('artists'))
    assert_equals('release', singular('releases'))
    assert_equals('city', singular('cities'))
12
    assert_raises(ValueError, singular, 'city')
13

14 15 16 17 18

def test_is_uuid():
    assert_true(is_uuid('83fdc319-b05e-4edc-9371-f7ff09fc642e'))
    assert_false(is_uuid('83fdc319-b05e-4edc-9371-xxxxxxxxxxxx'))

19

20 21 22 23 24 25 26
def test_is_foreignid():
    assert_true(is_foreignid('abc:123'))
    assert_true(is_foreignid('foo:123'))
    assert_false(is_foreignid('ABC:83'))
    assert_false(is_foreignid('83'))


27 28
def test_provider():
    assert_equals('foo', provider('foo')())