Пример #1
0
 def test_team_toJSON(self):
     team = Team('Log')
     team.id = 1
     self.assertEquals({
         'id': 1,
         'name': 'Log',
         'color': '2a33d8'
     }, team.toJSON())
Пример #2
0
    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())
Пример #3
0
 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)
Пример #4
0
    def test_load_task(self):
        create_entity(Task('title2', 'detail2', status='READY', price=10, team=Team.query.get(1)))
        create_entity(Task('title1', 'detail1', status='READY', price=10, team=Team('Refresh')))
        rv = self.app.get('/tasks/READY')

        self.assertEquals(200, rv.status_code)

        self.assertEquals({
                          "objects": [
                              {
                                  "title": "title2",
                                  "price": 10,
                                  "detail": "detail2",
                                  "status":'READY',
                                  "owner": {},
                                  "partner": {},
                                  "team": {
                                      'id':1,
                                      "color": "2a33d8",
                                      "name": "Log"
                                  },
                                  'time_slots': [],
                                  'consuming': '0',
                                  'priority': 100,
                                  "estimate": 0,
                                  'last_updated': 'just now',
                                  'created_time': 'just now',
                                  "id": 1
                              }
                          ]
                          }, json.loads(rv.data))
Пример #5
0
 def setUp(self):
     self.app = miami.app.test_client()
     miami.init_db()
     team = Team('Log')
     team.members.append(User('Mike'))
     create_entity(team)
     create_entity(Category('BUG'))
     when(miami.utils).now().thenReturn(datetime(2012, 11, 11, 1, 0, 0))
     self.login('Mike', '')
Пример #6
0
    def test_join_team(self):
        self.create_entity(Team('Log'))

        rv = self.app.put('/teams/join/1')

        self.assertEquals(200,rv.status_code)

        mike = User.query.get(1)
        self.assertEquals(1,mike.teams.count())
        self.assertEquals(Team.query.get(1),mike.teams[0])
Пример #7
0
    def test_leave_team(self):
        team =Team('Log')
        team.members.append(User.query.get(1))
        self.create_entity(team)

        rv = self.app.put('/teams/leave/1')

        self.assertEquals(200,rv.status_code)

        mike = User.query.get(1)
        self.assertEquals(0,mike.teams.count())
Пример #8
0
    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())
Пример #9
0
 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))
Пример #10
0
#-*- 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))
Пример #11
0
 def test_team_toJSON(self):
     team = Team('Log')
     team.id = 1
     self.assertEquals({'id':1, 'name': 'Log', 'color': '2a33d8'}, team.toJSON())