Example #1
0
 def test_cart_load(self):
     """A loaded cart is not empty"""
     with mock.patch('juicer.common.Constants') as constants:
         constants.CART_LOCATION = './'
         constants.USER_CONFIG = './config'
         cart = juicer.cart.Cart(name='cart', autoload=True)
         self.assertEqual(cart.repos(), ['test'])
         self.assertEqual(cart.is_empty(), False)
         self.assertEqual(cart.items()[0].name, 'empty-0.1-1.noarch.rpm')
Example #2
0
    def test_cart_update(self):
        """Cart can be updated"""
        with nested(
                mock.patch('juicer.common.Constants'),
                mock.patch('pymongo.MongoClient')) as (
                    constants,
                    MongoClient):

            # Override constants.
            constants.CART_LOCATION = './'
            constants.USER_CONFIG = './config'

            cart = juicer.cart.Cart(name='test-cart',
                                    description={'test-repo': ['share/juicer/empty-0.1-1.noarch.rpm']})
            cart.update([['test-repo', 'share/juicer/empty-0.1-1.noarch.rpm']])
            self.assertEqual(cart.items()[0].name, 'empty-0.1-1.noarch.rpm')
            cart.delete()
            self.assertFalse(os.path.exists(cart.cart_file))