[test][rfct] exchange unittest with pytest
-from tests.base import TestCase, assets, main # pylint: disable=unused-import
+# -*- coding: utf-8 -*-
from ocrd_models import OcrdAgent
-# pylint: disable=no-member
-class TestOcrdAgent(TestCase):
- def test_basic1(self):
+def test_init_role_no_name():
ag = OcrdAgent(role='FOO')
- self.assertEqual(ag.role, 'FOO')
- self.assertEqual(ag.name, None)
- self.assertEqual(str(ag), '<OcrdAgent [type=---, othertype=---, role=FOO, otherrole=---, name=---]/>')
+ assert 'FOO' == ag.role
+ assert None == ag.name
- def test_basic2(self):
+
+def test_init_role_as_string():
+ ag = OcrdAgent(role='FOO')
+ expected = '<OcrdAgent [type=---, othertype=---, role=FOO, otherrole=---, name=---]/>'
+ assert expected == str(ag)
+
+
+def test_init_otherrole_and_othertype():
ag = OcrdAgent(otherrole='BAR', othertype='x')
- self.assertEqual(ag.role, 'OTHER')
- self.assertEqual(ag.otherrole, 'BAR')
- self.assertEqual(ag.othertype, 'x')
+ assert 'OTHER' == ag.role
+ assert 'BAR' == ag.otherrole
+ assert 'x' == ag.othertype
- def test_basic3(self):
- ag = OcrdAgent(name='foobar')
- self.assertEqual(ag.name, 'foobar')
- ag.name = 'barfoo'
- self.assertEqual(ag.name, 'barfoo')
- def test_basic4(self):
+def test_init_othertype():
ag = OcrdAgent(othertype='foobar')
- self.assertEqual(ag.type, 'OTHER')
- # print(ag)
+ assert 'OTHER' == ag.type
+
-if __name__ == '__main__':
- main()
+def test_set_name():
+ ag = OcrdAgent(name='foobar')
+ assert 'foobar' == ag.name
+ ag.name = 'barfoo'
+ assert 'barfoo' == ag.name
