Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_unsupported_brand():
vin = Vin('200BL8EV9AX604020')
assert vin.manufacturer == 'UnsupportedBrand'
assert vin.country == 'Canada'
def test_validation():
with pytest.raises(ValidationError):
Vin('tooshort')
with pytest.raises(ValidationError):
Vin('AAAAAAAAAAAAAAAAO')
def test_renault():
vin = Vin('VF14SRAP451234567')
assert '%s' % vin
assert vin.wmi == 'VF1'
assert vin.manufacturer == 'Renault'
assert vin.vds == '4SRAP4'
assert vin.vis == '51234567'
assert vin.years == [2005]
assert vin.region_code == 'V'
assert vin.region == 'Europe'
assert vin.country_code == 'VF'
assert vin.country == 'France'
assert '%s' % vin.brand == 'Renault (Renault)'
details = vin.details
assert not details.engine
assert details.model
def test_opel():
vin = Vin('W0LPC6DB3CC123456')
assert '%s' % vin
assert vin.wmi == 'W0L'
assert vin.manufacturer == 'Opel/Vauxhall'
assert vin.vds == 'PC6DB3'
assert vin.vis == 'CC123456'
assert vin.years == [2012, 1982]
assert vin.region_code == 'W'
assert vin.region == 'Europe'
assert vin.country_code == 'W0'
assert vin.country == 'Germany/West Germany'
assert '%s' % vin.brand == 'Opel (Opel/Vauxhall)'
details = vin.details
assert details.model.code == 'P'
assert details.model.name == ['Astra J', 'Zafira C']
def test_lada():
vin = Vin('XTAGFK330JY144213')
assert '%s' % vin
assert vin.wmi == 'XTA'
assert vin.manufacturer == 'AvtoVAZ'
assert vin.vds == 'GFK330'
assert vin.vis == 'JY144213'
assert vin.years == [2018, 1988]
assert vin.region_code == 'X'
assert vin.region == 'Europe'
assert vin.country_code == 'XT'
assert vin.country == 'USSR/CIS'
assert vin.annotate() == OrderedDict([
('Country', 'USSR/CIS'),
('Manufacturer', 'AvtoVAZ'),
('Region', 'Europe'),
('Years', '2018, 1988'),
def test_bogus():
vin = Vin('VF1KG1PBE34488860')
details = vin.details
assert details.engine.code == ''
assert not details.engine
def test_nissan():
vin = Vin('5N1NJ01CXST000001')
assert '%s' % vin
assert vin.wmi == '5N1'
assert vin.manufacturer == 'Nissan'
assert vin.vds == 'NJ01CX'
assert vin.vis == 'ST000001'
assert vin.years == [1995]
assert vin.region_code == '5'
assert vin.region == 'North America'
assert vin.country_code == '5N'
assert vin.country == 'United States'
assert '%s' % vin.brand == 'Nissan (Nissan)'
details = vin.details
assert details.model.code == 'J'
assert details.model.name == 'Maxima'
def test_checksum():
assert Vin('1M8GDM9AXKP042788').verify_checksum()
# faked
assert not Vin('1M8GDM9AyKP042788').verify_checksum()
def test_basic():
# number faked
vin = Vin('JSA12345678901234')
assert vin.manufacturer == 'Suzuki'
assert not vin.manufacturer_is_small
# number faked
assert Vin('TM912345678901234').manufacturer_is_small
def test_validation():
with pytest.raises(ValidationError):
Vin('tooshort')
with pytest.raises(ValidationError):
Vin('AAAAAAAAAAAAAAAAO')