Example #1
0
class TestProvider:

    prov = ISBNProvider(None)

    def test_reg_pub_separation(self):
        r1 = RegistrantRule('0000000', '0000001', 1)
        r2 = RegistrantRule('0000002', '0000003', 2)
        assert self.prov._registrant_publication('00000000',
                                                 [r1, r2]) == ('0', '0000000')
        assert self.prov._registrant_publication('00000010',
                                                 [r1, r2]) == ('0', '0000010')
        assert self.prov._registrant_publication('00000019',
                                                 [r1, r2]) == ('0', '0000019')
        assert self.prov._registrant_publication('00000020',
                                                 [r1, r2]) == ('00', '000020')
        assert self.prov._registrant_publication('00000030',
                                                 [r1, r2]) == ('00', '000030')
        assert self.prov._registrant_publication('00000031',
                                                 [r1, r2]) == ('00', '000031')
        assert self.prov._registrant_publication('00000039',
                                                 [r1, r2]) == ('00', '000039')

    def test_rule_not_found(self):
        with pytest.raises(Exception):
            r = RegistrantRule('0000000', '0000001', 1)
            self.prov._registrant_publication('0000002', [r])
Example #2
0
class TestProvider:

    prov = ISBNProvider(None)

    def test_reg_pub_separation(self):
        r1 = RegistrantRule("0000000", "0000001", 1)
        r2 = RegistrantRule("0000002", "0000003", 2)
        assert self.prov._registrant_publication("00000000", [r1, r2]) == (
            "0",
            "0000000",
        )
        assert self.prov._registrant_publication("00000010", [r1, r2]) == (
            "0",
            "0000010",
        )
        assert self.prov._registrant_publication("00000019", [r1, r2]) == (
            "0",
            "0000019",
        )
        assert self.prov._registrant_publication("00000020", [r1, r2]) == (
            "00",
            "000020",
        )
        assert self.prov._registrant_publication("00000030", [r1, r2]) == (
            "00",
            "000030",
        )
        assert self.prov._registrant_publication("00000031", [r1, r2]) == (
            "00",
            "000031",
        )
        assert self.prov._registrant_publication("00000039", [r1, r2]) == (
            "00",
            "000039",
        )

    def test_rule_not_found(self):
        with pytest.raises(Exception):
            r = RegistrantRule("0000000", "0000001", 1)
            self.prov._registrant_publication("0000002", [r])
Example #3
0
 def setUp(self):
     self.prov = ISBNProvider(None)