예제 #1
0
파일: test_project.py 프로젝트: gitmob/pitz
class TestFromPitzdir(unittest.TestCase):

    def setUp(self):

        self.p = Project(pathname='/tmp')
        self.p.to_yaml_file()
        self.p.to_pickle()

    def tearDown(self):

        for f in glob.glob('/tmp/*.yaml'):
            os.unlink(f)

        if os.path.isfile('/tmp/project.pickle'):
            os.unlink('/tmp/project.pickle')

    def test_fresh_pickle(self):
        """
        Verify we use the pickle when we can.
        """

        p = Project.from_pitzdir('/tmp')
        assert p.loaded_from == 'pickle', p.loaded_from

    def test_stale_pickle(self):
        """
        Verify we use the yaml files when the pickle is too old.
        """

        stat = os.stat('/tmp/project.pickle')

        os.utime('/tmp/project.pickle',
            (stat.st_atime-1, stat.st_mtime-1))

        print("pickle file: %s"
            % os.stat('/tmp/project.pickle').st_mtime)

        print("newest yaml file: %s"
            % max([os.stat(f).st_mtime for f in glob.glob('/tmp/*.yaml')]))

        p = Project.from_pitzdir('/tmp')
        assert p.loaded_from == 'yaml', p.loaded_from

    def test_from_yaml_files(self):
        """
        Verify we can use the yaml files when no pickle exists.
        """

        os.unlink('/tmp/project.pickle')

        p = Project.from_pitzdir('/tmp')
        assert p.loaded_from == 'yaml', p.loaded_from
예제 #2
0
파일: pitzsetup.py 프로젝트: gitmob/pitz
def pitz_setup():

    """
    Start a new project
    """

    p = optparse.OptionParser()

    p.epilog = "Set up pitz"

    p.add_option('--version', action='store_true',
        help='show pitz version')

    options, args = p.parse_args()

    if options.version:
        print_version()
        return

    dir = os.path.basename(os.getcwd())

    project_name = raw_input(
        "Project name (hit ENTER for %s): " % dir).strip()

    if not project_name:
        project_name = dir

    pitzdir = mk_pitzdir()

    proj = Project(pathname=pitzdir, title=project_name)
    proj.to_yaml_file()

    Status.setup_defaults(proj)

    pw_name = pwd.getpwuid(os.getuid()).pw_name

    name = raw_input("Your name (hit ENTER for %s): " % pw_name).strip()

    if not name:
        name = pw_name

    person = Person(proj, title=name)

    proj.save_entities_to_yaml_files()
    print("All done!")
    print("Run pitz-add-task to add a task, or run pitz-help for help.")
예제 #3
0
파일: test_project.py 프로젝트: gitmob/pitz
def test_to_yaml_file_2(o):

    p = Project("Bogus")
    p.to_yaml_file()
예제 #4
0
파일: test_project.py 프로젝트: gitmob/pitz
def test_to_yaml_file_1(m1, m2):

    p = Project("Bogus")
    p.to_yaml_file('bogus-pathname')