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"))
  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())
  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")])
  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"))
  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())
  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())
  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))
  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")])
  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())
  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))