Ejemplo n.º 1
0
class ManagerTestCase(TestCase):
    """
    Test case for the inventory manager class.
    """
    def setUp(self):
        # add test models
        call_command('syncdb', interactive=False, verbosity=0)
        super(TestCase, self)._pre_setup()

        # create user
        admins = getattr(settings, 'ADMINS',
                         (('Micah Carrick', '*****@*****.**'), ))
        name = admins[0][0].split(" ", 1)
        self.user = User(username="******",
                         first_name=name[0],
                         last_name=name[1],
                         email=admins[0][1])
        self.user.save()
        self.in_stock = StockStatus(name="In Stock")
        self.in_stock.save()

    def tearDown(self):
        self.user.delete()

    def test_add_to_inventory(self):
        manager = InventoryManager(self.user)

        # create an inventory item
        product = TestProduct(name="Widget A")
        product.save()
        item = InventoryItem(sku="1234",
                             content_object=product,
                             stock_status=self.in_stock)
        item.save()

        # add item
        line_items = [
            ("1234", 10, 5.00),
        ]
        manager.add_to_inventory(line_items, Transaction.TYPE_RECIEVED)
        item = InventoryItem.objects.get(sku="1234")
        self.assertTrue(item)
        self.assertEquals(item.qty, 10)

        line_items = [
            ("1234", 2, 7.00),
        ]
        manager.add_to_inventory(line_items, Transaction.TYPE_RECIEVED)
        item = InventoryItem.objects.get(sku="1234")
        self.assertEquals(item.qty, 12)
Ejemplo n.º 2
0
    def setUp(self):
        # add test models
        call_command('syncdb', interactive=False, verbosity=0)
        super(TestCase, self)._pre_setup()

        # create user
        admins = getattr(settings, 'ADMINS',
                         (('Micah Carrick', '*****@*****.**'), ))
        name = admins[0][0].split(" ", 1)
        self.user = User(username="******",
                         first_name=name[0],
                         last_name=name[1],
                         email=admins[0][1])
        self.user.save()
        self.in_stock = StockStatus(name="In Stock")
        self.in_stock.save()
Ejemplo n.º 3
0
class ManagerTestCase(TestCase):
    """
    Test case for the inventory manager class.
    """

    def setUp(self):
        # add test models
        call_command('syncdb', interactive=False, verbosity=0)
        super(TestCase, self)._pre_setup()

        # create user
        admins = getattr(settings, 'ADMINS', (('Micah Carrick', '*****@*****.**'),))
        name = admins[0][0].split(" ", 1)
        self.user = User(username="******", first_name=name[0], last_name=name[1],
                         email=admins[0][1])
        self.user.save()
        self.in_stock = StockStatus(name="In Stock")
        self.in_stock.save()

    def tearDown(self):
        self.user.delete()

    def test_add_to_inventory(self):
        manager = InventoryManager(self.user)

        # create an inventory item
        product = TestProduct(name="Widget A")
        product.save()
        item = InventoryItem(sku="1234", content_object=product,
                             stock_status=self.in_stock)
        item.save()

        # add item
        line_items = [("1234", 10, 5.00), ]
        manager.add_to_inventory(line_items, Transaction.TYPE_RECIEVED)
        item = InventoryItem.objects.get(sku="1234")
        self.assertTrue(item)
        self.assertEquals(item.qty, 10)

        line_items = [("1234", 2, 7.00), ]
        manager.add_to_inventory(line_items, Transaction.TYPE_RECIEVED)
        item = InventoryItem.objects.get(sku="1234")
        self.assertEquals(item.qty, 12)
Ejemplo n.º 4
0
 def setUp(self):
     # add test models
     call_command('syncdb', interactive=False, verbosity=0)
     super(TestCase, self)._pre_setup()
     
     # create user
     admins = getattr(settings, 'ADMINS', (('Micah Carrick', '*****@*****.**'),))
     name = admins[0][0].split(" ", 1)
     self.user = User(username="******", first_name=name[0], last_name=name[1], 
                      email=admins[0][1])
     self.user.save()
     self.in_stock = StockStatus(name="In Stock")
     self.in_stock.save()