예제 #1
0
def test_callnumber_raises_error_using_unittype_kwarg():
    """Calls to the ``callnumber`` factory should raise an
    InvalidCallNumberStringError when the given call number string does
    not match any of the Unit types given, when a specific type list is
    provided via the ``unittypes`` kwarg.
    """
    types = [FactoryTestType, AnotherFactoryTestType]
    with pytest.raises(e.InvalidCallNumberStringError):
        f.callnumber('AA 0 AA 0', unittypes=types)
예제 #2
0
def test_callnumber_sets_correct_options_using_useropts_kwarg():
    """Calls to the ``callnumber`` factory should utilize a set of
    custom options when one is provided via the ``useropts`` kwarg.
    """
    opts = {'test_option': False}
    types = [FactoryTestType]
    default = f.callnumber('AA 0', unittypes=types)
    custom = f.callnumber('AA 0', useropts=opts, unittypes=types)
    assert default.test_option is True and custom.test_option is False
예제 #3
0
def test_callnumber_selects_correct_type_using_unittype_kwarg():
    """Calls to the ``callnumber`` factory should return the correct
    Unit type when a specific type list is provided via the
    ``unittypes`` kwarg.
    """
    types = [FactoryTestType, AnotherFactoryTestType]
    assert f.callnumber('AA 0', unittypes=types) == FactoryTestType('AA 0')
예제 #4
0
def test_callnumber_sets_unitname_using_name_kwarg():
    """Calls to the ``callnumber`` factory should generate a Unit
    object with a ``name`` attribute matching the value passed to the
    ``name`` kwarg.
    """
    types = [FactoryTestType]
    custom = f.callnumber('AA 0', name='test_unit', unittypes=types)
    assert custom.name == 'test_unit'