def test_user_toJSON(self): user = User('Mike') self.assertEquals( { 'name': 'Mike', 'gravater': '91f376c4b36912e5075b6170d312eab5' }, user.toJSON())
def setUp(self): self.app = miami.app.test_client() miami.init_db() team = Team('Log') team.members.append(User('Mike')) team.members.append(User('Bob')) create_entity(team) when(miami.utils).now().thenReturn(datetime(2012, 11, 11, 1, 0, 0)) self.login('Mike', '')
def test_create_task_noteam(self): create_entity(User('Bob')) self.logout() self.login('Bob', '') rv = self.app.post('/tasks', data='{"title":"title1","detail":"detail1"}') self.assertEquals(403, rv.status_code)
def setUp(self): BaseTestCase.setUp(self) when(miami.utils).now().thenReturn(datetime(2012, 11, 5, 9, 0, 0)) team = Team('Miami') team.members.append(User('Bob')) team.members.append(User.query.get(1)) task = Task('title1', 'detail', status='DONE', price=2, estimate=4, team=team, ready_time=datetime(2012, 11, 1, 10, 0, 0)) ts = TimeSlot(datetime(2012, 11, 1, 10, 0, 0), 3600, User.query.get(1)) task.time_slots.append(ts) self.create_entity(task) task = Task('title2', 'detai2', status='NEW', price=2, estimate=4, team=team, ready_time=datetime(2012, 11, 1, 10, 0, 0)) ts = TimeSlot(datetime(2012, 11, 2, 10, 0, 0), 3600, User.query.get(1), partner=User.query.get(2)) task.time_slots.append(ts) self.create_entity(task)
def test_ready_to_progress_noauth(self): task = Task('title2', 'detail2', estimate=10, price=10, status='PROGRESS', start_time=datetime(2012, 11, 11)) mike = User.query.get(1) task.owner = mike task.time_slots.append(TimeSlot(task.start_time, 20, mike)) create_entity(task) create_entity(User('Bob')) self.logout() self.login('Bob', '') rv = self.app.put('/tasks/PROGRESS/1') self.assertEquals(401, rv.status_code)
def test_not_allow_multi_paired(self): create_entity(User('Bob')) create_entity(User('Martin')) task = Task('title1', 'detail1', estimate=10, price=10, status='PROGRESS', start_time=datetime(2012, 11, 11)) task.partner = User.query.get(1) task.owner = User.query.get(2) create_entity(task) task = Task('title2', 'detail2', estimate=10, price=10, status='READY', start_time=datetime(2012, 11, 11)) task.owner = User.query.get(3) create_entity(task) rv = self.app.put('/jointask/2') self.assertEquals(403, rv.status_code)
def test_multi_timeslots(self): create_entity(User('Bob')) task = Task('title2', 'detail2', estimate=10, price=10, status='PROGRESS', start_time=datetime(2012, 11, 11), team=Team.query.get(1)) task.time_slots.append(TimeSlot(task.start_time, 3600, User.query.get(1))) task.owner = User.query.get(2) create_entity(task) self.logout() self.login('Bob', '') rv = self.app.put('/tasks/READY/1') self.assertEquals(200, rv.status_code) task = Task.query.get(1) self.assertEquals('READY', task.status) self.assertEquals(7200, task.consuming) self.assertEquals(1, task.time_slots[0].user.id) self.assertEquals(2, task.time_slots[1].user.id)
def test_not_allow_to_progress(self): create_entity(User('Bob')) task = Task('title1', 'detail1', estimate=10, price=10, status='PROGRESS', start_time=datetime(2012, 11, 11)) task.partner = User.query.get(1) task.owner = User.query.get(2) create_entity(task) create_entity( Task('title2', 'detail2', estimate=10, price=10, status='READY', start_time=datetime(2012, 11, 11))) rv = self.app.put('/tasks/PROGRESS/2') self.assertEquals(403, rv.status_code)
def test_task_toJSON(self): team = Team('Log') team.id = 1 task = Task('title1', 'detail', status='DONE', price=1, estimate=4, team=team) task.id = 1 task.owner = User('Mike') self.assertEquals( { 'id': 1, 'title': 'title1', 'detail': 'detail', 'status': 'DONE', 'price': 1, 'estimate': 4, 'priority': 100, 'time_slots': [], 'consuming': '0', 'created_time': 'just now', 'last_updated': 'just now', 'team': { 'name': 'Log', 'color': '2a33d8', 'id': 1 }, 'owner': { 'name': 'Mike', 'gravater': '91f376c4b36912e5075b6170d312eab5' }, 'partner': {} }, task.toJSON())
def setUp(self): miami.init_db() team = Team('Log') team.members.append(User('Mike')) create_entity(team) when(miami.utils).now().thenReturn(datetime(2012, 11, 11, 23, 0, 0))
def setUp(self): self.app = miami.app.test_client() miami.init_db() create_entity(User('Mike'))
#-*- coding:utf-8 -*- import os os.environ['MIAMI_ENV'] = 'dev' import miami from miami.models import User, Team, Task, TimeSlot, Burning, Category from miami import db from datetime import timedelta miami.init_db() team = Team('Log') team.members.append(User('yachuan.chen', email='*****@*****.**')) team.members.append(User('yue.zhang', email='*****@*****.**')) team.members.append(User('peng.yuan', email='*****@*****.**')) db.session.add(team) db.session.add(Category(u'功能')) db.session.add(Category('Bug')) db.session.add(Category('Test')) db.session.commit() task = Task('title1', 'detail', status='DONE', price=1, estimate=4, team=Team.query.get(1), start_time=miami.utils.get_last_monday().replace(hour=10), ready_time=miami.utils.get_last_monday().replace(hour=10)) ts = TimeSlot(miami.utils.get_last_monday().replace(hour=10), 7200, User.query.get(1)) task.time_slots.append(ts) task.categories.append(Category.query.get(1))
def test_user_toJSON(self): user = User('Mike') self.assertEquals({'name': 'Mike', 'gravater': '91f376c4b36912e5075b6170d312eab5'}, user.toJSON())