def test_is_valid(self):
        for test in TEST_DATA:
            v = Vin(test['VIN'])
            print("Testing: %s" % test['VIN'])
            assert_equals(v.is_valid, True)

        vin = '1' * 17
        v = Vin(vin)
        print("Testing: %s" % vin)
        assert_equals(v.is_valid, False)
Exemple #2
0
 def test_decode_brazil_new_cars(self):
     """
     In Brazil we have this special case that need to be covered in relation
     to the year of production.
     """
     v = Vin('9BWKB45U7BP112137')
     self.assertEqual(v.year, 2011)
 def test_is_pre_2010(self):
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print("Testing: %s" % test['VIN'])
         if test['YEAR'] < 2010:
             assert_true(v.is_pre_2010)
         else:
             assert_true(not v.is_pre_2010)
Exemple #4
0
def decodeButton():
    vin_input = text_VIN.get('1.0', tk.END)[:17]

    if len(vin_input) != 17:
        messagebox.showwarning(
            "Invalid VIN length",
            "Sorry, the length of the VIN you have input is wrong. Please check!"
        )

    else:

        # Capitalization:
        vin = vin_input.upper()

        try:
            # Parse VIN
            v = Vin(vin)

            year = v.year
            country = v.country
            region = v.region.capitalize()
            manufacturer = v.manufacturer
            make = v.make

            # Differentiate Year:
            if year < 2000:
                year = year + 30

            # Sections
            text_WMI.delete('1.0', tk.END)
            text_WMI.insert('1.0', vin[:3])

            text_VDS.delete('1.0', tk.END)
            text_VDS.insert('1.0', vin[3:9])

            text_SPN.delete('1.0', tk.END)
            text_SPN.insert('1.0', vin[11:])

            # Parameters
            text_region.delete('1.0', tk.END)
            text_region.insert('1.0', region)

            text_country.delete('1.0', tk.END)
            text_country.insert('1.0', country)

            text_manufacturer.delete('1.0', tk.END)
            text_manufacturer.insert('1.0', manufacturer)

            text_make.delete('1.0', tk.END)
            text_make.insert('1.0', make)

            text_year.delete('1.0', tk.END)
            text_year.insert('1.0', year)

        except:
            messagebox.showwarning(
                "Invalid VIN",
                "Sorry, the VIN you input is invalid. Please check!")
 def test_make(self):
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print("Testing: %s, %s" % (test['VIN'], v.make))
         assert_equals(v.make, test['MAKE'])
         if 'NETWORK_OK' in os.environ:
             # Verify that our decoded make is the same as NHTSA's.
             n = nhtsa_decode(test['VIN'])
             if n['ErrorCode'][0] == '0':
                 assert_equals(v.make.upper(), n['Make'])
             # Avoid swamping nhtsa server when cache empty.
             # FIXME: Using requests_cache throttling would be better, wouldn't slow down cache full case.
             sleep(0.05)
 def test_year(self):
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print("Testing: %s - %s" % (test['VIN'], v.year))
         assert_equals(v.year, test['YEAR'])
 def test_wmi(self):
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print("Testing: %s" % test['VIN'])
         assert_equals(v.wmi, test['WMI'])
 def test_vsn(self):
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print("Testing: %s" % test['VIN'])
         assert_equals(v.vsn, test['SEQUENTIAL_NUMBER'])
 def test_vds(self):
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print("Testing: %s" % test['VIN'])
         assert_equals(v.vds, test['VDS'])
 def test_region(self):
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print("Testing: %s" % test['VIN'])
         assert_equals(v.region, test['REGION'])
 def test_less_than_500_per_year(self):  # no tests yet..
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print("Testing: %s" % test['VIN'])
         assert_equals(v.less_than_500_built_per_year,
                       test['FEWER_THAN_500_PER_YEAR'])
 def test_country(self):
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print("Testing: %s" % test['VIN'])
         assert_equals(v.country, test['COUNTRY'])
 def test_is_valid(self):
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print "Testing: %s" % test['VIN']
         assert_equals(v.is_valid, True)
 def test_vis(self):
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print "Testing: %s" % test['VIN']
         assert_equals(v.vis, test['VIS'])
Exemple #15
0
 def test_manufacturer(self):
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print 'Testing: %s' % test['VIN']
         assert_true(test['MAKE'] in v.make)
Exemple #16
0
 def test_is_valid(self):
     for test in TEST_DATA:
         v = Vin(test['VIN'])
         print "Testing: %s" % test['VIN']
         assert_equals(v.is_valid(), True)