コード例 #1
0
  def test_remove(self):
    activityRepo = ActivitiesRepository()

    activityRepo.add(Activity(1, datetime(2014, 11, 21, 12, 30), "test1"))
    activityRepo.add(Activity(2, datetime(1999, 9, 15, 19, 25), "test2"))
    activityRepo.add(Activity(3, datetime(2015, 1, 31, 2, 10), "test3"))
    self.assertEqual(activityRepo.remove(3), Activity(3, datetime(2015, 1, 31, 2, 10), "test3"))
コード例 #2
0
  def test_getActivitiesList(self):
    activityRepo = ActivitiesRepository()
    cont = ActivitiesController(activityRepo, PersonsActivitiesRepo(), UndoRedoController())

    cont.addActivity(datetime(2014, 11, 21, 12, 30), "test1")
    cont.addActivity(datetime(1999, 9, 15, 19, 25), "test2")
    cont.addActivity(datetime(2015, 1, 31, 2, 10), "test3")

    self.assertEqual(cont.getActivitiesList(), activityRepo.getAll())
コード例 #3
0
  def test_getActivitiesBetweenDates(self):
    activityRepo = ActivitiesRepository()
    cont = ActivitiesController(activityRepo, PersonsActivitiesRepo(), UndoRedoController())

    cont.addActivity(datetime(2014, 11, 21, 12, 30), "test1")
    cont.addActivity(datetime(1999, 9, 15, 19, 25), "test2")
    cont.addActivity(datetime(2015, 1, 31, 2, 10), "test3")

    self.assertEqual(cont.getActivitiesBetweenDates(date(2012, 1, 31), date(2017, 1, 31)), [Activity(1, datetime(2014, 11, 21, 12, 30), "test1"),
                                                                                            Activity(3, datetime(2015, 1, 31, 2, 10), "test3")])
コード例 #4
0
  def test_update(self):
    activityRepo = ActivitiesRepository()
    cont = ActivitiesController(activityRepo, PersonsActivitiesRepo(), UndoRedoController())

    cont.addActivity(datetime(2014, 11, 21, 12, 30), "test1")
    cont.addActivity(datetime(1999, 9, 15, 19, 25), "test2")

    cont.update(1, datetime(2015, 1, 31, 2, 10), "test3")

    self.assertEqual(cont.findActivityById(1), Activity(1, datetime(2015, 1, 31, 2, 10), "test3"))
コード例 #5
0
  def test_removeActivity(self):
    activityRepo = ActivitiesRepository()
    cont = ActivitiesController(activityRepo, PersonsActivitiesRepo(), UndoRedoController())

    cont.addActivity(datetime(2014, 11, 21, 12, 30), "test1")
    cont.addActivity(datetime(1999, 9, 15, 19, 25), "test2")
    cont.addActivity(datetime(2015, 1, 31, 2, 10), "test3")

    ac = cont.findActivityById(2)
    cont.removeActivity(2)

    self.assertNotIn(ac, cont.getActivitiesList())
コード例 #6
0
  def test_addActivity(self):
    activityRepo = ActivitiesRepository()
    cont = ActivitiesController(activityRepo, PersonsActivitiesRepo(), UndoRedoController())

    cont.addActivity(datetime(2014, 11, 21, 12, 30), "test1")

    self.assertIn(cont.findActivityById(1), cont.getActivitiesList())
コード例 #7
0
  def test_findActivityById(self):
    activityRepo = ActivitiesRepository()
    cont = ActivitiesController(activityRepo, PersonsActivitiesRepo(), UndoRedoController())

    cont.addActivity(datetime(2014, 11, 21, 12, 30), "test1")

    self.assertEqual(cont.findActivityById(1), activityRepo.findById(1))
コード例 #8
0
  def test_getAll(self):
    activityRepo = ActivitiesRepository()

    activityRepo.add(Activity(1, datetime(2014, 11, 21, 12, 30), "test1"))
    activityRepo.add(Activity(2, datetime(1999, 9, 15, 19, 25), "test2"))
    activityRepo.add(Activity(3, datetime(2015, 1, 31, 2, 10), "test3"))
    activityRepo.add(Activity(4, datetime(2015, 1, 31, 12, 36), "test4"))

    self.assertEqual(activityRepo.getAll(), [Activity(1, datetime(2014, 11, 21, 12, 30), "test1"),
                                             Activity(2, datetime(1999, 9, 15, 19, 25), "test2"),
                                             Activity(3, datetime(2015, 1, 31, 2, 10), "test3"),
                                             Activity(4, datetime(2015, 1, 31, 12, 36), "test4")])
コード例 #9
0
  def test_add(self):
    activityRepo = ActivitiesRepository()

    activityRepo.add(Activity(1, datetime(2014, 11, 21, 12, 30), "test1"))
    self.assertIn(Activity(1, datetime(2014, 11, 21, 12, 30), "test1"), activityRepo.getAll())
コード例 #10
0
  def test_findById(self):
    activityRepo = ActivitiesRepository()

    activityRepo.add(Activity(1, datetime(2014, 11, 21, 12, 30), "test1"))
    self.assertEqual(activityRepo.findById(1), Activity(1, datetime(2014, 11, 21, 12, 30), "test1"))
    self.assertIsNone(activityRepo.findById(3))