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')
def test_init(): obj = CodelistCode(*arguments()) assert obj.data == { 'Code': 'tender', 'Title': 'Tender', 'Description': '…' } assert obj.extension_name is None
def test_getitem(): obj = CodelistCode(*arguments()) assert obj['Code'] == 'tender' with pytest.raises(KeyError) as excinfo: obj['nonexistent'] assert str(excinfo.value) == "'nonexistent'"
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', }), ]
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
def test_repr(): obj = CodelistCode(*arguments()) assert repr( obj ) == "CodelistCode(data={'Code': 'tender', 'Title': 'Tender', 'Description': '…'})"
def test_len(): obj = CodelistCode(*arguments()) assert len(obj) == 3
def test_iter(): obj = CodelistCode(*arguments()) for i, item in enumerate(obj): pass assert i == 2
def test_setitem(): obj = CodelistCode(*arguments()) obj['Extension'] = 'OCDS Core' assert obj['Extension'] == 'OCDS Core'
def test_get(): obj = CodelistCode(*arguments()) assert obj.get('Code') == 'tender' assert obj.get('nonexistent', 'default') == 'default'
def test_eq_dict(): args = arguments() obj = CodelistCode(*args) assert obj == args[0]
def test_eq(): obj = CodelistCode(*arguments()) assert obj == CodelistCode(*arguments())