示例#1
0
    def test_leave_paired(self):
        task = Task('title2', 'detail2', estimate=10, price=10, status='PROGRESS', start_time=datetime(2012, 11,
                    11), team=Team.query.get(1))
        task.owner = User.query.get(2)
        task.partner = User.query.get(1)
        create_entity(task)

        rv = self.app.put('/leavetask/1')

        self.assertEquals(200, rv.status_code)
        self.assertEquals({
                          "object": {
                              "status": "PROGRESS",
                              "owner": {
                                  "gravater": "91f376c4b36912e5075b6170d312eab5",
                                  "name": "Bob"
                              },
                              "consuming": "1",
                              'priority': 100,
                              "time_slots": [
                                  {
                                      "partner": {
                                          "gravater": "91f376c4b36912e5075b6170d312eab5",
                                          "name": "Mike"
                                      },
                                      "start_time": "3 months ago",
                                      "consuming_hours": "1",
                                      "user": {
                                          "gravater": "91f376c4b36912e5075b6170d312eab5",
                                          "name": "Bob"
                                      },
                                      "bar_width": "100.00%"
                                  }
                              ],
                              "title": "title2",
                              "estimate": 10,
                              "partner": {
                              },
                              "price": 10,
                              "team": {
                                  'id':1,
                                  "color": "2a33d8",
                                  "name": "Log"
                              },
                              "id": 1,
                              'last_updated': 'just now',
                              'created_time': 'just now',
                              "detail": "detail2"
                          }
                          }, json.loads(rv.data))

        task = Task.query.get(1)
        self.assertIsNone(task.partner)
        self.assertEquals('PROGRESS', task.status)
        self.assertEquals(1, task.time_slots.count())
        self.assertEquals(datetime(2012, 11, 11, 1, 0, 0), task.start_time)
        self.assertEquals(3600, task.time_slots[0].consuming)
        self.assertEquals('Bob', task.time_slots[0].user.name)
        self.assertEquals('Mike', task.time_slots[0].partner.name)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    def test_leave_paired(self):
        task = Task('title2',
                    'detail2',
                    estimate=10,
                    price=10,
                    status='PROGRESS',
                    start_time=datetime(2012, 11, 11),
                    team=Team.query.get(1))
        task.owner = User.query.get(2)
        task.partner = User.query.get(1)
        create_entity(task)

        rv = self.app.put('/leavetask/1')

        self.assertEquals(200, rv.status_code)
        self.assertEquals(
            {
                "object": {
                    "status":
                    "PROGRESS",
                    "owner": {
                        "gravater": "91f376c4b36912e5075b6170d312eab5",
                        "name": "Bob"
                    },
                    "consuming":
                    "1",
                    'priority':
                    100,
                    "time_slots": [{
                        "partner": {
                            "gravater": "91f376c4b36912e5075b6170d312eab5",
                            "name": "Mike"
                        },
                        "start_time": "3 months ago",
                        "consuming_hours": "1",
                        "user": {
                            "gravater": "91f376c4b36912e5075b6170d312eab5",
                            "name": "Bob"
                        },
                        "bar_width": "100.00%"
                    }],
                    "title":
                    "title2",
                    "estimate":
                    10,
                    "partner": {},
                    "price":
                    10,
                    "team": {
                        'id': 1,
                        "color": "2a33d8",
                        "name": "Log"
                    },
                    "id":
                    1,
                    'last_updated':
                    'just now',
                    'created_time':
                    'just now',
                    "detail":
                    "detail2"
                }
            }, json.loads(rv.data))

        task = Task.query.get(1)
        self.assertIsNone(task.partner)
        self.assertEquals('PROGRESS', task.status)
        self.assertEquals(1, task.time_slots.count())
        self.assertEquals(datetime(2012, 11, 11, 1, 0, 0), task.start_time)
        self.assertEquals(3600, task.time_slots[0].consuming)
        self.assertEquals('Bob', task.time_slots[0].user.name)
        self.assertEquals('Mike', task.time_slots[0].partner.name)
示例#7
0
    def test_paired_to_done(self):
        task = Task('title2',
                    'detail2',
                    estimate=10,
                    price=10,
                    status='PROGRESS',
                    start_time=datetime(2012, 11, 11),
                    team=Team.query.get(1))
        task.owner = User.query.get(1)
        task.partner = User.query.get(2)
        task.start_time = datetime(2012, 11, 11, 1, 0, 0)
        task.time_slots.append(TimeSlot(task.start_time, 3600, task.owner))
        create_entity(task)

        when(miami.utils).now().thenReturn(datetime(2012, 11, 11, 2, 0, 0))
        rv = self.app.put('/tasks/DONE/1')

        self.assertEquals(200, rv.status_code)
        self.assertEquals(
            {
                'object': {
                    'detail':
                    'detail2',
                    'estimate':
                    10,
                    'id':
                    1,
                    'last_updated':
                    'just now',
                    'created_time':
                    'just now',
                    'owner': {},
                    'partner': {},
                    'price':
                    10,
                    'status':
                    'DONE',
                    "consuming":
                    "2",
                    'priority':
                    100,
                    "time_slots": [{
                        "partner": {},
                        "start_time": "3 months ago",
                        "consuming_hours": "1",
                        "user": {
                            "gravater": "91f376c4b36912e5075b6170d312eab5",
                            "name": "Mike"
                        },
                        "bar_width": "50.00%"
                    }, {
                        "partner": {
                            "gravater": "91f376c4b36912e5075b6170d312eab5",
                            "name": "Bob"
                        },
                        "start_time": "3 months ago",
                        "consuming_hours": "1",
                        "user": {
                            "gravater": "91f376c4b36912e5075b6170d312eab5",
                            "name": "Mike"
                        },
                        "bar_width": "50.00%"
                    }],
                    'team': {
                        'id': 1,
                        'color': '2a33d8',
                        'name': 'Log'
                    },
                    'title':
                    'title2'
                }
            }, json.loads(rv.data))

        task = Task.query.get(1)
        self.assertIsNone(task.partner)
        self.assertIsNone(task.owner)
        self.assertEquals('DONE', task.status)
        self.assertEquals(2, task.time_slots.count())
        self.assertEquals(3600, task.time_slots[0].consuming)
        self.assertEquals('Mike', task.time_slots[0].user.name)
        self.assertIsNone(task.time_slots[0].partner)
        self.assertEquals(3600, task.time_slots[1].consuming)
        self.assertEquals('Mike', task.time_slots[1].user.name)
        self.assertEquals('Bob', task.time_slots[1].partner.name)
示例#8
0
    def test_paired_to_done(self):
        task = Task('title2', 'detail2', estimate=10, price=10, status='PROGRESS', start_time=datetime(2012, 11,
                    11), team=Team.query.get(1))
        task.owner = User.query.get(1)
        task.partner = User.query.get(2)
        task.start_time = datetime(2012, 11, 11, 1, 0, 0)
        task.time_slots.append(TimeSlot(task.start_time, 3600, task.owner))
        create_entity(task)

        when(miami.utils).now().thenReturn(datetime(2012, 11, 11, 2, 0, 0))
        rv = self.app.put('/tasks/DONE/1')

        self.assertEquals(200, rv.status_code)
        self.assertEquals({'object': {'detail': 'detail2',
                                      'estimate': 10,
                                      'id': 1,
                                      'last_updated': 'just now',
                                      'created_time': 'just now',
                                      'owner': {},
                                      'partner': {},
                                      'price': 10,
                                      'status': 'DONE',
                                      "consuming": "2",
                                      'priority': 100,
                                      "time_slots": [
                                      {
                                          "partner": {},
                                          "start_time": "3 months ago",
                                          "consuming_hours": "1",
                                          "user": {
                                              "gravater": "91f376c4b36912e5075b6170d312eab5",
                                              "name": "Mike"
                                          },
                                          "bar_width": "50.00%"
                                      },
                                          {
                                              "partner": {
                                                  "gravater": "91f376c4b36912e5075b6170d312eab5",
                                                  "name": "Bob"
                                              },
                                              "start_time": "3 months ago",
                                              "consuming_hours": "1",
                                              "user": {
                                                  "gravater": "91f376c4b36912e5075b6170d312eab5",
                                                  "name": "Mike"
                                              },
                                              "bar_width": "50.00%"
                                          }
                                      ],
                                      'team': {'id':1, 'color': '2a33d8', 'name': 'Log'},
                                      'title': 'title2'}}, json.loads(rv.data))

        task = Task.query.get(1)
        self.assertIsNone(task.partner)
        self.assertIsNone(task.owner)
        self.assertEquals('DONE', task.status)
        self.assertEquals(2, task.time_slots.count())
        self.assertEquals(3600, task.time_slots[0].consuming)
        self.assertEquals('Mike', task.time_slots[0].user.name)
        self.assertIsNone(task.time_slots[0].partner)
        self.assertEquals(3600, task.time_slots[1].consuming)
        self.assertEquals('Mike', task.time_slots[1].user.name)
        self.assertEquals('Bob', task.time_slots[1].partner.name)