Example #1
0
    def setUp(self):
        self.create_prod('PACKING-TEFLON 3/16X', True, '4721', 10)
        self.create_prod('RUBBER LINED CLAMP', False, '13302', 0)

        self.p1 = {
            'IMMFGC': 'A/P',
            'Part Number': '4721',
            'IMDESC': 'PACKING-TEFLON 3/16X',
            'IMSUOM': 'EA',
            'List': D('27.13'),
            'Dealer': D('23.26'),
            'Your Price': D('25.00')
        }

        self.p2 = {
            'IMMFGC': 'ABA',
            'Part Number': '13302',
            'IMDESC': 'RUBBER LINED CLAMP',
            'IMSUOM': 'EA',
            'List': D('1.8'),
            'Dealer': D('0.83'),
            'Your Price': D('55.00')
        }

        self.db = DBHandler(self.partner, D(0))
Example #2
0
 def test_createNewStockRecordNewPartnerProductWithStock_NotRaiseIntegrityError(
         self):
     partner = Partner.objects.create(name='AnotherPartner')
     db = DBHandler(partner, D(0))
     sr1, created = db.update_by_part_number(self.p1['Part Number'],
                                             self.p1['Your Price'],
                                             self.p1['List'],
                                             self.p1['Dealer'])
     self.assertTrue(created)
     self.assertEqual(sr1.partner.name, 'AnotherPartner')
Example #3
0
 def test_updateProductWithStockWithIncrease_returnsTrue(self):
     db = DBHandler(self.partner, D(30))
     sr1, _ = db.update_by_part_number(self.p1['Part Number'],
                                       self.p1['Your Price'],
                                       self.p1['List'], self.p1['Dealer'])
     self.assertEqual(sr1.price_excl_tax, D(32.50))
Example #4
0
class TestIntegrationUpdatePartNumber(test.TestCase):
    # Auxiliar method
    def create_prod(self, title, hasStock, part_number, num_stock):
        p = Product.objects.create(product_class=self.pc, title=title)
        self.part_number.save_value(p, part_number)
        if hasStock:
            StockRecord.objects.create(product=p,
                                       partner=self.partner,
                                       partner_sku=part_number,
                                       price_excl_tax=D('0.00'),
                                       num_in_stock=num_stock)

    @classmethod
    def setUpTestData(cls):
        cls.pc = ProductClass.objects.create(name='Subcomponent')
        cls.partner = Partner.objects.create(name='NewPrice')
        cls.part_number = ProductAttribute.objects.create(
            product_class=cls.pc,
            name='Part number',
            code='PN',
            required=True,
            type=ProductAttribute.TEXT)

    def setUp(self):
        self.create_prod('PACKING-TEFLON 3/16X', True, '4721', 10)
        self.create_prod('RUBBER LINED CLAMP', False, '13302', 0)

        self.p1 = {
            'IMMFGC': 'A/P',
            'Part Number': '4721',
            'IMDESC': 'PACKING-TEFLON 3/16X',
            'IMSUOM': 'EA',
            'List': D('27.13'),
            'Dealer': D('23.26'),
            'Your Price': D('25.00')
        }

        self.p2 = {
            'IMMFGC': 'ABA',
            'Part Number': '13302',
            'IMDESC': 'RUBBER LINED CLAMP',
            'IMSUOM': 'EA',
            'List': D('1.8'),
            'Dealer': D('0.83'),
            'Your Price': D('55.00')
        }

        self.db = DBHandler(self.partner, D(0))

    def test_updateProductWithStock_returnsTrue(self):
        sr1, _ = self.db.update_by_part_number(self.p1['Part Number'],
                                               self.p1['Your Price'],
                                               self.p1['List'],
                                               self.p1['Dealer'])
        self.assertEqual(sr1.price_excl_tax, D(25.00))

    def test_updateProductWithoutStock_returnsTrue(self):
        sr2, _ = self.db.update_by_part_number(self.p2['Part Number'],
                                               self.p2['Your Price'],
                                               self.p2['List'],
                                               self.p2['Dealer'])
        self.assertEqual(sr2.price_excl_tax, D(55.00))

    def test_updateProductWithoutStockWithIncrease_returnsTrue(self):
        db = DBHandler(self.partner, D(30))
        sr2, _ = db.update_by_part_number(self.p2['Part Number'],
                                          self.p2['Your Price'],
                                          self.p2['List'], self.p2['Dealer'])
        self.assertEqual(sr2.price_excl_tax, D(71.50))

    def test_createNewStockRecordNewPartnerProductWithStock_NotRaiseIntegrityError(
            self):
        partner = Partner.objects.create(name='AnotherPartner')
        db = DBHandler(partner, D(0))
        sr1, created = db.update_by_part_number(self.p1['Part Number'],
                                                self.p1['Your Price'],
                                                self.p1['List'],
                                                self.p1['Dealer'])
        self.assertTrue(created)
        self.assertEqual(sr1.partner.name, 'AnotherPartner')

    def test_updateProductWithStockWithIncrease_returnsTrue(self):
        db = DBHandler(self.partner, D(30))
        sr1, _ = db.update_by_part_number(self.p1['Part Number'],
                                          self.p1['Your Price'],
                                          self.p1['List'], self.p1['Dealer'])
        self.assertEqual(sr1.price_excl_tax, D(32.50))

    def test_updateProductWithStockNumStockPrevious_returnsTrue(self):
        sr1, _ = self.db.update_by_part_number(self.p1['Part Number'],
                                               self.p1['Your Price'],
                                               self.p1['List'],
                                               self.p1['Dealer'])
        self.assertEqual(sr1.num_in_stock, 10)

    def test_updateProductWithStockNumStockZero_returnsTrue(self):
        self.create_prod('PACKING-TEFLON', True, '4722', 0)
        self.p1['Part Number'] = '4722'
        sr1, c = self.db.update_by_part_number(self.p1['Part Number'],
                                               self.p1['Your Price'],
                                               self.p1['List'],
                                               self.p1['Dealer'])
        self.assertFalse(c)
        self.assertEqual(sr1.num_in_stock, 1000)
Example #5
0
 def test_decrease_amount_returnsTrue(self):
     db = DBHandler(None, D(-30))
     new_value = db.adjust_by_percent(D(55.00))
     self.assertEqual(new_value, D(38.50))
Example #6
0
 def test_zero_amount_returnsTrue(self):
     db = DBHandler(None, D(0))
     new_value = db.adjust_by_percent(D(55.00))
     self.assertEqual(new_value, D(55))