def setUpClass(self):
     os.mkdir(TMP_PATH)
     self.mana = ProfileManager(TMP_PATH)
     self.mana.config = VMCConfig(VMC_CFG)
 def setUpClass(self):
     os.mkdir(TMP_PATH)
     self.mana = ProfileManager(TMP_PATH)
     self.mana.config = VMCConfig(VMC_CFG)
class TestProfileManager(unittest.TestCase):
    """Test for L{vmc.common.profiles.ProfileManager} functionality"""
    # XXX: We have 0 coverage on all operations that depend on a device
    # edit_profile, load_profile
    
    def setUpClass(self):
        os.mkdir(TMP_PATH)
        self.mana = ProfileManager(TMP_PATH)
        self.mana.config = VMCConfig(VMC_CFG)
    
    def tearDownClass(self):
        shutil.rmtree(TMP_PATH)
        self.mana = None
    
    def test_add_and_delete_profile_in_use(self):
        """
        Test that adding a profile works
        
        Test also that deleting the active profile raises an exception
        """
        profdict = dict(profile_name='profile-test',
                        username='******',
                        password='******',
                        connection='3GONLY',
                        apn='ac.vodafone.es',
                        dialer_profile='default',
                        staticdns=False,
                        dns1=None,
                        dns2=None)
        
        profile = self.mana.create_profile(profdict['profile_name'], profdict)
        self.mana.add_profile(profile)
        profiles = self.mana.get_profile_list()
        self.assertIn(profile, profiles)
        self.assertRaises(ProfileInUseError, self.mana.delete_profile, profile)
    
    def test_add_and_delete_profile_not_in_use(self):
        """
        Test that adding a profile works
        
        Test also that deleting a profile not active works
        """
        profdict = dict(profile_name='profile-test2',
                        username='******',
                        password='******',
                        connection='GPRSONLY',
                        apn='ac.vodafone.es',
                        dialer_profile='default',
                        staticdns=False,
                        dns1=None,
                        dns2=None)
        
        profile = self.mana.create_profile(profdict['profile_name'], profdict)
        self.mana.add_profile(profile)
        profiles = self.mana.get_profile_list()
        self.assertIn(profile, profiles)
        self.mana.delete_profile(profile)
        profiles2 = self.mana.get_profile_list()
        self.assertNotIn(profile, profiles2)
        
class TestProfileManager(unittest.TestCase):
    """Test for L{vmc.common.profiles.ProfileManager} functionality"""

    # XXX: We have 0 coverage on all operations that depend on a device
    # edit_profile, load_profile

    def setUpClass(self):
        os.mkdir(TMP_PATH)
        self.mana = ProfileManager(TMP_PATH)
        self.mana.config = VMCConfig(VMC_CFG)

    def tearDownClass(self):
        shutil.rmtree(TMP_PATH)
        self.mana = None

    def test_add_and_delete_profile_in_use(self):
        """
        Test that adding a profile works
        
        Test also that deleting the active profile raises an exception
        """
        profdict = dict(profile_name='profile-test',
                        username='******',
                        password='******',
                        connection='3GONLY',
                        apn='ac.vodafone.es',
                        dialer_profile='default',
                        staticdns=False,
                        dns1=None,
                        dns2=None)

        profile = self.mana.create_profile(profdict['profile_name'], profdict)
        self.mana.add_profile(profile)
        profiles = self.mana.get_profile_list()
        self.assertIn(profile, profiles)
        self.assertRaises(ProfileInUseError, self.mana.delete_profile, profile)

    def test_add_and_delete_profile_not_in_use(self):
        """
        Test that adding a profile works
        
        Test also that deleting a profile not active works
        """
        profdict = dict(profile_name='profile-test2',
                        username='******',
                        password='******',
                        connection='GPRSONLY',
                        apn='ac.vodafone.es',
                        dialer_profile='default',
                        staticdns=False,
                        dns1=None,
                        dns2=None)

        profile = self.mana.create_profile(profdict['profile_name'], profdict)
        self.mana.add_profile(profile)
        profiles = self.mana.get_profile_list()
        self.assertIn(profile, profiles)
        self.mana.delete_profile(profile)
        profiles2 = self.mana.get_profile_list()
        self.assertNotIn(profile, profiles2)