Пример #1
0
def test_pop():
    obj = CodelistCode(*arguments())

    assert obj.pop('Code', 'default') == 'tender'

    assert obj.pop('Code', 'default') == 'default'

    with pytest.raises(KeyError) as excinfo:
        obj['Code']

    assert str(excinfo.value) == "'Code'"
def test_getitem():
    obj = fixture()

    assert obj[0] == CodelistCode(
        {
            'Code': 'open',
            'Title': 'Open',
            'Description': 'All interested suppliers may submit a tender.',
        }, 'OCDS Core')
Пример #3
0
def test_init():
    obj = CodelistCode(*arguments())

    assert obj.data == {
        'Code': 'tender',
        'Title': 'Tender',
        'Description': '…'
    }
    assert obj.extension_name is None
Пример #4
0
def test_getitem():
    obj = CodelistCode(*arguments())

    assert obj['Code'] == 'tender'

    with pytest.raises(KeyError) as excinfo:
        obj['nonexistent']

    assert str(excinfo.value) == "'nonexistent'"
Пример #5
0
def test_init_extension_name():
    obj = CodelistCode(*arguments('OCDS Core'))

    assert obj.data == {
        'Code': 'tender',
        'Title': 'Tender',
        'Description': '…'
    }
    assert obj.extension_name == 'OCDS Core'
def test_extend():
    obj = fixture()
    obj.extend(csv.DictReader(StringIO('Code\nother')), 'Other')
    obj.extend(csv.DictReader(StringIO('Code\nanother')))

    assert obj.rows == [
        CodelistCode(
            {
                'Code': 'open',
                'Title': 'Open',
                'Description': 'All interested suppliers may submit a tender.',
            }, 'OCDS Core'),
        CodelistCode(
            {
                'Code':
                'selective',
                'Title':
                'Selective',
                'Description':
                'Only qualified suppliers are invited to submit a tender.',
            }, 'OCDS Core'),
        CodelistCode(
            {
                'Code':
                'limited',
                'Title':
                'Limited',
                'Description':
                'The procuring entity contacts a number of suppliers of its choice.',
            }, 'OCDS Core'),
        CodelistCode(
            {
                'Code':
                'direct',
                'Title':
                'Direct',
                'Description':
                'The contract is awarded to a single supplier without competition.',
            }, 'OCDS Core'),
        CodelistCode({
            'Code': 'other',
        }, 'Other'),
        CodelistCode({
            'Code': 'another',
        }),
    ]
Пример #7
0
def test_repr_extension_name():
    obj = CodelistCode(*arguments('OCDS Core'))

    assert repr(
        obj
    ) == "CodelistCode(data={'Code': 'tender', 'Title': 'Tender', 'Description': '…'}, extension_name='OCDS Core')"  # noqa: E501
Пример #8
0
def test_repr():
    obj = CodelistCode(*arguments())

    assert repr(
        obj
    ) == "CodelistCode(data={'Code': 'tender', 'Title': 'Tender', 'Description': '…'})"
Пример #9
0
def test_len():
    obj = CodelistCode(*arguments())

    assert len(obj) == 3
Пример #10
0
def test_iter():
    obj = CodelistCode(*arguments())
    for i, item in enumerate(obj):
        pass

    assert i == 2
Пример #11
0
def test_setitem():
    obj = CodelistCode(*arguments())
    obj['Extension'] = 'OCDS Core'

    assert obj['Extension'] == 'OCDS Core'
Пример #12
0
def test_get():
    obj = CodelistCode(*arguments())

    assert obj.get('Code') == 'tender'

    assert obj.get('nonexistent', 'default') == 'default'
Пример #13
0
def test_eq_dict():
    args = arguments()
    obj = CodelistCode(*args)

    assert obj == args[0]
Пример #14
0
def test_eq():
    obj = CodelistCode(*arguments())

    assert obj == CodelistCode(*arguments())