예제 #1
0
    def testRunEnterDaysLessThanOne(self):
        schedulefiledata = FileTester.read_file(
            FileTester.test_enter_lessthan1
        )
        tempschedulefile = FileTester.write_to_temp_file(
            FileTester.test_enter_lessthan1,
            schedulefiledata
        )
        schedulefile = ScheduleFile(tempschedulefile)

        templedgerfile = FileTester.create_temp_file('')
        ledgerfile = LedgerFile(templedgerfile)

        scheduler = Scheduler(ledgerfile, schedulefile)
        scheduler.run()

        ledgerfile.write_file()
        schedulefile.write_file()

        schedulefile_actual = FileTester.read_file(tempschedulefile)
        schedulefile_expected = FileTester.read_file(
            FileTester.test_enter_lessthan1
        )

        os.remove(templedgerfile)
        os.remove(tempschedulefile)

        self.assertEqual(
            schedulefile_expected,
            schedulefile_actual
        )
예제 #2
0
 def test_parsed_file_unchanged_via_write(self):
     """file output after parsing should be identical to input"""
     expected = FileTester.read_file(FileTester.testfile)
     tempfile = FileTester.copy_to_temp_file(FileTester.testfile)
     ledgerfile = LedgerFile(tempfile)
     ledgerfile.write_file()
     actual = FileTester.read_file(tempfile)
     remove(tempfile)
     self.assertEqual(expected, actual)
예제 #3
0
 def test_already_sorted_file_unchanged(self):
     """file output after sorting is identical to sorted input"""
     expected = FileTester.read_file(FileTester.sortedfile)
     tempfile = FileTester.copy_to_temp_file(FileTester.sortedfile)
     ledgerfile = LedgerFile(tempfile)
     ledgerfile.sort()
     ledgerfile.write_file()
     actual = FileTester.read_file(tempfile)
     remove(tempfile)
     self.assertEqual(expected, actual)
예제 #4
0
 def test_sorting(self):
     """test sorting"""
     expected = FileTester.read_file(FileTester.alpha_sortedfile)
     tempfile = FileTester.copy_to_temp_file(
         FileTester.alpha_unsortedfile
     )
     ledgerfile = LedgerFile(tempfile)
     ledgerfile.sort()
     ledgerfile.write_file()
     actual = FileTester.read_file(tempfile)
     remove(tempfile)
     self.assertEqual(expected, actual)
예제 #5
0
 def test_parsed_file_unchanged_via_print(self):
     """file output after parsing should be identical to input"""
     expected = FileTester.read_file(FileTester.testfile)
     ledgerfile = LedgerFile(FileTester.testfile)
     ledgerfile.print_file()
     self.redirect.seek(0)
     self.assertEqual(expected, self.redirect.read())
     self.assertIsNone(ledgerfile.get_reconciliation_account())
예제 #6
0
    def run_it(self, before_date, after_date, schedule, enter_days=7):
        schedulefiledata = self.get_schedule_file(
            util.get_date_string(before_date),
            schedule,
            enter_days
        )
        tempschedulefile = FileTester.write_to_temp_file(
            FileTester.testdir + 'run_it_schedule_file',
            schedulefiledata
        )
        schedulefile = ScheduleFile(tempschedulefile)

        templedgerfile = FileTester.write_to_temp_file(
            FileTester.testdir + 'run_it_ledger_file',
            ''
        )
        ledgerfile = LedgerFile(templedgerfile)

        scheduler = Scheduler(ledgerfile, schedulefile)
        scheduler.run()

        ledgerfile.write_file()
        schedulefile.write_file()

        schedulefile_actual = FileTester.read_file(tempschedulefile)

        schedulefile_expected = self.get_schedule_file(
            util.get_date_string(after_date),
            schedule,
            enter_days
        )

        os.remove(templedgerfile)
        os.remove(tempschedulefile)

        self.assertEqual(schedulefile_expected, schedulefile_actual)