def test_link(self): from pyconcepticon.commands import link with self.assertRaises(ParserError): link(Mock(args=['.'])) def nattr(p, attr): return len(nfilter([getattr(i, attr, None) for i in read_all(p)])) test = self.tmp_path('test.tsv') copy(Path(__file__).parent.joinpath('fixtures', 'conceptlist.tsv'), test) self.assertEqual(nattr(test, 'CONCEPTICON_GLOSS'), 0) link(Mock(args=[test])) self.assertEqual(nattr(test, 'CONCEPTICON_GLOSS'), 1)
def test_link(self): from pyconcepticon.commands import link with self.assertRaises(ParserError): link(Mock(args=['.'], data=None)) def nattr(p, attr): return len(nfilter([getattr(i, attr, None) for i in read_all(p)])) test = self.tmp_path('test.tsv') copy(self.fixture_path('conceptlist.tsv'), test) self.assertEqual(nattr(test, 'CONCEPTICON_GLOSS'), 0) link(Mock(args=[test], data=None)) self.assertEqual(nattr(test, 'CONCEPTICON_GLOSS'), 1) copy(self.fixture_path('conceptlist2.tsv'), test) with capture(link, Mock(args=[test], data=None)) as out: self.assertIn('unknown CONCEPTICON_GLOSS', out) self.assertIn('mismatch', out)
def test_link(mocker, fixturedir, tmpdir, capsys): from pyconcepticon.commands import link with pytest.raises(ParserError): link(mocker.Mock(args=['.'], repos=None)) def nattr(p, attr): return len(nfilter([getattr(i, attr, None) for i in read_all(str(p))])) test = tmpdir.join('test.tsv') copy(fixturedir.joinpath('conceptlist.tsv'), str(test)) assert nattr(test, 'CONCEPTICON_GLOSS') == 0 link(mocker.Mock(args=[str(test)], repos=None)) assert nattr(test, 'CONCEPTICON_GLOSS') == 1 copy(fixturedir.joinpath('conceptlist2.tsv'), str(test)) link(mocker.Mock(args=[str(test)], repos=None)) out, err = capsys.readouterr() assert 'unknown CONCEPTICON_GLOSS' in out assert 'mismatch' in out