view profilemanager/tests/test.py @ 46:df1b2e48dddb

handle hashing for clones only if they are added to profiles.ini
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 06 May 2010 19:05:28 -0700
parents 8eb997fd6e79
children 09a2666999fa
line wrap: on
line source

#!/usr/bin/env python

import os
from profilemanager import ProfileManager

# Get the path to the test profiles.ini file:
from pkg_resources import resource_filename
profiles_dir = os.path.join('tests', 'profiles')
path = os.path.join(profiles_dir, 'profiles.ini')
profiles = resource_filename('profilemanager', path)
profiles_dir = resource_filename('profilemanager', profiles_dir)
assert os.path.exists(profiles), '%s does not exist' % profiles
assert os.path.exists(profiles_dir), '%s does not exist' % profiles_dir

# Instatiate a ProfileManager:
manager = ProfileManager(profiles)

# Remove any profiles that didn't get cleaned up:
profiles_dict = manager.profiles_dict()
for profile in profiles_dict:
  manager.remove(profile)
assert os.listdir(profiles_dir) == ['profiles.ini'], 'profiles_dir isnt empty except profiles.ini'
assert file(profiles).read().strip() == '[General]', 'profiles.ini isnt nearly empty'
    
# Create a new profile:
profiledir = manager.new('testprofile')
assert profiledir.endswith('.testprofile'), 'profiledir should end with testprofile, instead it is %s' % profiledir
assert manager.list() == ['testprofile']

# Clone the profile:
manager.clone('testprofile', 'cloneprofile')
assert sorted(manager.list()) == ['cloneprofile', 'testprofile']
manager.remove('cloneprofile')

# Cleanup:
manager.remove('testprofile')
assert manager.list() == []