def setUp(self):
     self.TOTAL_COLLECTION_BAGS_VALUE = 5
     self.rasflPersistentStoreDict = RasflPersistentStoreDict("GI01SUMO-00001")
class TestRasflPersistentStoreDict(MiUnitTest):
    def setUp(self):
        self.TOTAL_COLLECTION_BAGS_VALUE = 5
        self.rasflPersistentStoreDict = RasflPersistentStoreDict("GI01SUMO-00001")

    def tearDown(self):
        self.rasflPersistentStoreDict.clear() # NOTE: This technically assumes the delete functionality works.

    def test_initialize_success(self):
        self.assertFalse(self.rasflPersistentStoreDict.isInitialized())
        totalCollectionBags = self.TOTAL_COLLECTION_BAGS_VALUE
        self.assertIs(type(totalCollectionBags), int)
        self.rasflPersistentStoreDict.initialize(totalCollectionBags)
        self.assertTrue(self.rasflPersistentStoreDict.isInitialized())

    def test_initialize_fail_badType(self):
        totalCollectionBags = u"this will fail"
        self.assertIsNot(type(totalCollectionBags), int)
        with self.assertRaises(TypeError) as contextManager:
            self.rasflPersistentStoreDict.initialize(totalCollectionBags)
        self.assertEqual(contextManager.exception.args[0], "totalCollectionBags must be of type 'int'.")

    def test_initialize_fail_alreadyInitialized(self):
        self.test_initialize_success()
        totalCollectionBags = self.TOTAL_COLLECTION_BAGS_VALUE
        self.assertIs(type(totalCollectionBags), int)
        with self.assertRaises(Exception) as contextManager:
            self.rasflPersistentStoreDict.initialize(totalCollectionBags)
        self.assertEqual(contextManager.exception.args[0], "Already initialized.")

    def test_useCollectionBag_mixed(self):
        self.test_initialize_success()
        # Success Test
        for x in range(0, self.TOTAL_COLLECTION_BAGS_VALUE):
            self.assertTrue(self.rasflPersistentStoreDict.canUseCollectionBag())
            self.rasflPersistentStoreDict.useCollectionBag()
        # Fail Test
        self.assertFalse(self.rasflPersistentStoreDict.canUseCollectionBag())
        with self.assertRaises(Exception) as contextManager:
            self.rasflPersistentStoreDict.useCollectionBag()
        self.assertEqual(contextManager.exception.args[0], "No bags available for use.")

    def test_canUseCollectionBag_fail_notInitialized(self):
        self.assertFalse(self.rasflPersistentStoreDict.isInitialized())
        with self.assertRaises(Exception) as contextManager:
            self.rasflPersistentStoreDict.canUseCollectionBag()
        self.assertEqual(contextManager.exception.args[0], "Not initialized.")

    def test_useCollectionBag_fail_notInitialized(self):
        self.assertFalse(self.rasflPersistentStoreDict.isInitialized())
        with self.assertRaises(Exception) as contextManager:
            self.rasflPersistentStoreDict.useCollectionBag()
        self.assertEqual(contextManager.exception.args[0], "Not initialized.")