예제 #1
0
파일: test_edit.py 프로젝트: ralf57/taxi
    def test_previous_file_doesnt_autofill(self):
        config = self.default_config.copy()
        tmp_entries_dir = tempfile.mkdtemp()
        os.remove(self.entries_file)

        self.entries_file = os.path.join(tmp_entries_dir, '%m_%Y.txt')
        config['default']['file'] = self.entries_file

        with freeze_time('2014-01-21'):
            self.write_entries("""20/01/2014
alias_1 2 hello world

21/01/2014
alias_1 1 foo bar
""")

        with freeze_time('2014-02-21'):
            self.write_entries("""20/02/2014
alias_1 2 hello world
""")
            self.run_command('edit', args=['1'], config_options=config)

        with freeze_time('2014-01-21'):
            with open(expand_date(self.entries_file), 'r') as f:
                lines = f.readlines()

            self.assertNotIn('21/02/2014\n', lines)
예제 #2
0
파일: test_edit.py 프로젝트: jdrew1303/taxi
    def test_previous_file_doesnt_autofill(self):
        tmp_entries_dir = tempfile.mkdtemp()
        os.remove(self.entries_file)

        self.entries_file = os.path.join(tmp_entries_dir, '%m_%Y.txt')

        with self.settings({'default': {'file': self.entries_file}}):
            with freeze_time('2014-01-21'):
                self.write_entries("""20/01/2014
    alias_1 2 hello world

    21/01/2014
    alias_1 1 foo bar
    """)

            with freeze_time('2014-02-21'):
                self.write_entries("""20/02/2014
    alias_1 2 hello world
    """)
                self.run_command('edit', args=['1'])

            with freeze_time('2014-01-21'):
                with open(expand_date(self.entries_file), 'r') as f:
                    lines = f.readlines()

                self.assertNotIn('21/02/2014\n', lines)
예제 #3
0
파일: test_edit.py 프로젝트: ralf57/taxi
    def test_prefill_entries_add_to_bottom(self):
        config = self.default_config.copy()
        tmp_entries_dir = tempfile.mkdtemp()
        os.remove(self.entries_file)

        self.entries_file = os.path.join(tmp_entries_dir, '%m_%Y.txt')
        config['default']['file'] = self.entries_file

        with freeze_time('2014-01-21'):
            self.write_entries("""20/01/2014
alias_1 2 hello world

21/01/2014
alias_1 1 foo bar
""")

        with freeze_time('2014-02-21'):
            self.write_entries("""20/02/2014
alias_1 2 hello world
""")
            self.run_command('edit', config_options=config)

            with open(expand_date(self.entries_file), 'r') as f:
                lines = f.readlines()

            self.assertEqual('20/02/2014\n', lines[0])
            self.assertEqual('21/02/2014\n', lines[3])
예제 #4
0
파일: test_edit.py 프로젝트: jdrew1303/taxi
    def test_prefill_entries_add_to_bottom(self):
        tmp_entries_dir = tempfile.mkdtemp()
        os.remove(self.entries_file)

        self.entries_file = os.path.join(tmp_entries_dir, '%m_%Y.txt')

        with self.settings({'default': {'file': self.entries_file}}):
            with freeze_time('2014-01-21'):
                self.write_entries("""20/01/2014
    alias_1 2 hello world

    21/01/2014
    alias_1 1 foo bar
    """)

            with freeze_time('2014-02-21'):
                self.write_entries("""20/02/2014
    alias_1 2 hello world
    """)
                self.run_command('edit')

                with open(expand_date(self.entries_file), 'r') as f:
                    lines = f.readlines()

                self.assertEqual('20/02/2014\n', lines[0])
                self.assertEqual('21/02/2014\n', lines[3])
예제 #5
0
파일: __init__.py 프로젝트: ralf57/taxi
    def tearDown(self):
        backends_registry._entry_points = self.backends_original_entry_points
        entries_file = expand_date(self.entries_file)

        os.remove(self.config_file)
        if os.path.exists(entries_file):
            os.remove(entries_file)
        shutil.rmtree(self.taxi_dir)
예제 #6
0
    def tearDown(self):
        backends_registry._entry_points = self.backends_original_entry_points
        entries_file = expand_date(self.entries_file)

        os.remove(self.config_file)
        if os.path.exists(entries_file):
            os.remove(entries_file)
        shutil.rmtree(self.taxi_dir)
예제 #7
0
파일: __init__.py 프로젝트: ralf57/taxi
    def read_entries(self):
        with codecs.open(expand_date(self.entries_file), 'r', 'utf-8') as f:
            contents = f.read()

        return contents
예제 #8
0
파일: __init__.py 프로젝트: ralf57/taxi
 def write_entries(self, contents):
     with codecs.open(expand_date(self.entries_file), 'a', 'utf-8') as f:
         f.write(contents)
예제 #9
0
파일: conftest.py 프로젝트: sephii/taxi
 def expand(self, date):
     return self.tmpdir.join(expand_date(self.pattern, date))
예제 #10
0
파일: conftest.py 프로젝트: simonbru/taxi
 def expand(self, date):
     return self.tmpdir.join(expand_date(self.pattern, date))
예제 #11
0
    def read_entries(self):
        with codecs.open(expand_date(self.entries_file), 'r', 'utf-8') as f:
            contents = f.read()

        return contents
예제 #12
0
 def write_entries(self, contents):
     with codecs.open(expand_date(self.entries_file), 'a', 'utf-8') as f:
         f.write(contents)