Beispiel #1
0
 def setUp(self):
     self.entry = CategoryEntry(
         name="letters",
         entries=[
             BaseEntry(l, v, "0{}-11".format(9 - v), i)
             for l, v, i in zip("abc", (1, 5, 3), (7, 1, 3))
         ])
Beispiel #2
0
class SortBaseEntriesTestCase(unittest.TestCase):
    def setUp(self):
        self.entry = CategoryEntry(
            name="letters",
            entries=[
                BaseEntry(l, v, "0{}-11".format(9 - v), i)
                for l, v, i in zip("abc", (1, 5, 3), (7, 1, 3))
            ])

    def test_sort_by_name(self):
        # don't let trailing whitespaces of category name row being cleaned up
        self.assertEqual(
            self.entry.string(entry_sort="name"), "\
Letters                9.00          " + """
  A                    1.00 08-11   7
  B                    5.00 04-11   1
  C                    3.00 06-11   3""")

    def test_sort_by_value(self):
        self.assertEqual(
            self.entry.string(entry_sort="value"), "\
Letters                9.00          " + """
  A                    1.00 08-11   7
  C                    3.00 06-11   3
  B                    5.00 04-11   1""")

    def test_sort_by_date(self):
        self.assertEqual(
            self.entry.string(entry_sort="date"), "\
Letters                9.00          " + """
  B                    5.00 04-11   1
  C                    3.00 06-11   3
  A                    1.00 08-11   7""")

    def test_sort_by_eid(self):
        self.assertEqual(
            self.entry.string(entry_sort="eid"), "\
Letters                9.00          " + """
  B                    5.00 04-11   1
  C                    3.00 06-11   3
  A                    1.00 08-11   7""")
Beispiel #3
0
class CategoryEntryTestCase(unittest.TestCase):
    def setUp(self):
        self.entry = CategoryEntry(name="gifts")

    def test_name(self):
        self.assertEqual(self.entry.name, "gifts")

    def test_value(self):
        self.assertEqual(self.entry.value, 0.0)

    def test_str(self):
        self.assertEqual(
            self.entry.string(), "Gifts".ljust(CategoryEntry.NAME_LENGTH) +
            " " + "0.00".rjust(BaseEntry.VALUE_LENGTH) + " " +
            BaseEntry.DATE_LENGTH * " " +
            (BaseEntry.EID_LENGTH + 1) * " " if BaseEntry.SHOW_EID else "")
Beispiel #4
0
 def setUp(self):
     self.listing = Listing()
     self.category_name = "Groceries"
     self.listing.add_entry(CategoryEntry(name=self.category_name))
Beispiel #5
0
 def setUpClass(cls):
     cls.entry = CategoryEntry(name="This is quite a LOOONG Category",
                               entries=[BaseEntry("entry", -100, "08-13")])
Beispiel #6
0
 def setUp(self):
     self.entry = CategoryEntry(name="gifts")