def test_users_have_independent_clocks(self): admin_clock = ClockFeature(self.admin) employee_clock = ClockFeature(self.employee) admin_clock.start_clock() with self.assertRaises(ClockFeature.UnstartedClock): employee_clock.stop_clock() employee_clock.start_clock() employee_clock.stop_clock() admin_clock.stop_clock()
def stop_clock(self): clock = ClockFeature(self.current_user) try: clock.stop_clock() except ClockFeature.UnstartedClock: self.error_message('Clock was not started') return redirect('/clock')
def start_clock(self): clock = ClockFeature(self.current_user) try: clock.start_clock() except ClockFeature.ClockAlreadyStarted: self.error_message('Clock was already started') return redirect('/clock')
def get(self): clock_feature = ClockFeature(self.current_user) clock_is_open = clock_feature.clock_is_open() clocks = clock_feature.get_clocks().limit(20) now = datetime.now() return render_template('dashboard/clock.html', **locals())
def setUp(self): self.clock = ClockFeature(self.employee)