def test_save_file(self):
     text = os.urandom(2000)
     path = '/tmp/file.foo'
     
     save_file(path, text)
     
     fobj = open(path, 'r')
     data = fobj.read()
     fobj.close()
     
     self.assertEqual(text, data)
     os.unlink(path)
Пример #2
0
    def test_save_file(self):
        text = os.urandom(2000)
        path = '/tmp/file.foo'

        save_file(path, text)

        fobj = open(path, 'r')
        data = fobj.read()
        fobj.close()

        self.assertEqual(text, data)
        os.unlink(path)
Пример #3
0
    touch(consts.PAP_PROFILE)
    print "create skelaton and do setup: touch run"
    # This makes not save LOCK file if dialer_profiles have not been correctly created.
    if not os.path.exists(consts.CHAP_PROFILE) or \
            not os.path.exists(consts.DEFAULT_PROFILE) or \
            not os.path.exists(consts.PAP_PROFILE):

        print " Error creating dialer profile."
        message = _(
            'ERROR creating dialer_profile. You should restart the application.'
        )
        dialogs.open_warning_dialog(message, "")
        raise SystemExit()

    from vmc.common import plugin
    save_file(LOCK, str(plugin.VERSION))


def populate_dbs():
    """
    Populates the different databases
    """
    try:
        # only will succeed on development
        vf_networks = __import__('resources/extra/vf_networks')
        xx_networks = __import__('resources/extra/xx_networks')
    except ImportError:
        try:
            # this fails on feisty but not on gutsy
            vf_networks = __import__(
                os.path.join(consts.EXTRA_DIR, 'vf_networks'))
from vmc.common.config import VMCConfig
from vmc.common.exceptions import ProfileInUseError

from vmc.utils.utilities import save_file

TMP_PATH = '/tmp/profiles.foo'

TEMPLATE = """
[profile]
name = profile-test
last_device =
updater =
"""

VMC_CFG = '/tmp/vmc.cfg'
save_file(VMC_CFG, TEMPLATE)

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
    
from vmc.common.config import VMCConfig
from vmc.common.exceptions import ProfileInUseError

from vmc.utils.utilities import save_file

TMP_PATH = '/tmp/profiles.foo'

TEMPLATE = """
[profile]
name = profile-test
last_device =
updater =
"""

VMC_CFG = '/tmp/vmc.cfg'
save_file(VMC_CFG, TEMPLATE)


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)
Пример #6
0
    touch(consts.CHAP_PROFILE)
    touch(consts.DEFAULT_PROFILE)
    touch(consts.PAP_PROFILE)
    print "create skelaton and do setup: touch run"
    # This makes not save LOCK file if dialer_profiles have not been correctly created.
    if not os.path.exists(consts.CHAP_PROFILE) or \
            not os.path.exists(consts.DEFAULT_PROFILE) or \
            not os.path.exists(consts.PAP_PROFILE):
       
        print " Error creating dialer profile."
        message = _('ERROR creating dialer_profile. You should restart the application.')
        dialogs.open_warning_dialog(message, "")
        raise SystemExit()
    
    from vmc.common import plugin
    save_file(LOCK, str(plugin.VERSION))
    
def populate_dbs():
    """
    Populates the different databases
    """
    try:
        # only will succeed on development 
        vf_networks = __import__('resources/extra/vf_networks')
        xx_networks = __import__('resources/extra/xx_networks')
    except ImportError:
        try:
            # this fails on feisty but not on gutsy
            vf_networks = __import__(os.path.join(consts.EXTRA_DIR, 'vf_networks'))
            xx_networks = __import__(os.path.join(consts.EXTRA_DIR, 'xx_networks'))
        except ImportError: