assert oid != OID((1, 3, 6, 1, 4, 0)) assert repr(oid) == "OID('1.3.6.1.2.1.0')" assert str(oid) == '1.3.6.1.2.1.0' @pytest.mark.unit @pytest.mark.parametrize( 'value, expected_tuple', [ pytest.param((1, 3, 6, 1, 2, 1, 0), (1, 3, 6, 1, 2, 1, 0), id='tuple'), pytest.param('1.3.6.1.2.1.0', (1, 3, 6, 1, 2, 1, 0), id='string'), pytest.param((1, '3', 6, '1', 2, 1, '0'), (1, 3, 6, 1, 2, 1, 0), id='mixed-tuple'), pytest.param('.1.3.6.1.2.1.0', (1, 3, 6, 1, 2, 1, 0), id='string-with-leading-dot'), pytest.param(ObjectName((1, 3, 6, 1, 2, 1, 0)), (1, 3, 6, 1, 2, 1, 0), id='object-name-tuple'), pytest.param(ObjectName('1.3.6.1.2.1.0'), (1, 3, 6, 1, 2, 1, 0), id='object-name-string'), pytest.param( lambda controller: ObjectIdentity( (1, 3, 6, 1, 2, 1, 0)).resolveWithMib(controller), (1, 3, 6, 1, 2, 1, 0), id='resolved-object-identity', ), pytest.param( lambda controller: ObjectType(ObjectIdentity( (1, 3, 6, 1, 2, 1, 0))).resolveWithMib(controller), (1, 3, 6, 1, 2, 1, 0), id='resolved-object-type', ),
# type: () -> None oid = OID((1, 3, 6, 1, 2, 1, 0)) assert oid.as_tuple() == (1, 3, 6, 1, 2, 1, 0) assert repr(oid) == "OID('1.3.6.1.2.1.0')" assert str(oid) == '1.3.6.1.2.1.0' @pytest.mark.unit @pytest.mark.parametrize( 'value, expected_tuple', [ pytest.param((1, 3, 6, 1, 2, 1, 0), (1, 3, 6, 1, 2, 1, 0), id='tuple'), pytest.param('1.3.6.1.2.1.0', (1, 3, 6, 1, 2, 1, 0), id='string'), pytest.param((1, '3', 6, '1', 2, 1, '0'), (1, 3, 6, 1, 2, 1, 0), id='mixed-tuple'), pytest.param('.1.3.6.1.2.1.0', (1, 3, 6, 1, 2, 1, 0), id='string-with-leading-dot'), pytest.param(ObjectName((1, 3, 6, 1, 2, 1, 0)), (1, 3, 6, 1, 2, 1, 0), id='object-name-tuple'), pytest.param(ObjectName('1.3.6.1.2.1.0'), (1, 3, 6, 1, 2, 1, 0), id='object-name-string'), pytest.param( lambda controller: ObjectIdentity((1, 3, 6, 1, 2, 1, 0)).resolveWithMib(controller), (1, 3, 6, 1, 2, 1, 0), id='resolved-object-identity', ), pytest.param( lambda controller: ObjectType(ObjectIdentity((1, 3, 6, 1, 2, 1, 0))).resolveWithMib(controller), (1, 3, 6, 1, 2, 1, 0), id='resolved-object-type', ), ], ) def test_oid_parse_valid(value, expected_tuple): # type: (Any, Tuple[int, ...]) -> None