Example #1
0
 def test_cart_save_empty(self):
     """An empty cart will not be saved"""
     with mock.patch('juicer.common.Constants') as constants:
         constants.CART_LOCATION = './'
         constants.USER_CONFIG = './config'
         cart = juicer.cart.Cart(name='test-cart',
                                 description={'test-repo': []})
         cart.save(force=True)
         self.assertFalse(os.path.exists(cart.cart_file))
Example #2
0
    def test_cart_save_delete(self):
        """Cart can be saved and deleted"""
        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']})

            # We can save the cart and a file is created locally.
            cart.save(force=True)
            self.assertTrue(os.path.exists(cart.cart_file))
            # We can delete the cart and the file no longer exists.
            cart.delete()
            self.assertFalse(os.path.exists(cart.cart_file))