Sprtch / despinassy

🗄️ Database Schema collection and shared library repository
MIT License
0 stars 0 forks source link

CSV import update the name of Parts in the database with already existing barcode #21

Open tperale opened 3 years ago

tperale commented 3 years ago

Right now I only check for parts with the same name and barcode. But if a part in the importing csv has a already existing barcode but not a matching name I should just update the name of that part.

This test should pass

    def test_csv_re_import_with_name_update(self):
        self.assertEqual(Part.query.count(), 0)
        csv1 = io.StringIO("name,barcode\nhello,world\nfoo,bar\n123,456\n")
        Part._import_csv_content(csv1)
        self.assertEqual(Part.query.count(), 3)
        csv2 = io.StringIO("name,barcode\nhello2,world\nfoo,bar\n")
        Part._import_csv_content(csv2)
        self.assertEqual(Part.query.filter(Part.hidden == False).count(), 2)
        self.assertEqual(Part.query.count(), 3)