示例#1
0
 def test_list_products(self):
     products = [self._build_fake_product(111256, 'dolphines!')]
     return_value = MockSprintlyResponse(status_code=200,
                                         reason='OK',
                                         json=products)
     self._mock_session_for(self._products, 'get', return_value)
     self.assertEqual(products, self._products.list_products())
示例#2
0
 def test_get_product(self):
     product = self._build_fake_product(222, 'whales!')
     return_value = MockSprintlyResponse(status_code=200,
                                         reason='OK',
                                         json=product)
     self._mock_session_for(self._products, 'get', return_value)
     self.assertDictEqual(product, self._products.get_product(222))
示例#3
0
 def test_get_items_sends_assigned_to_when_valid(self):
     return_value = MockSprintlyResponse(status_code=200,
                                         reason='OK',
                                         json={})
     sut = self._mock_session_for(self._items, 'get', return_value)
     self._items.get_items(item_type='task',
                           item_status='in-progress',
                           assigned_to=11)
     expected = {'type': 'task', 'status': 'in-progress', 'assigned_to': 11}
     actual = sut.call_args_list[0][1]['params']
     self.assertDictEqual(expected, actual)
示例#4
0
 def test_delete_product_ok(self):
     product_name = 'drop-this'
     return_value = MockSprintlyResponse(status_code=200,
                                         reason='OK',
                                         json={
                                             'admin': True,
                                             'archived': False,
                                             'id': 3,
                                             'name': product_name
                                         })
     self._mock_session_for(self._products, 'delete', return_value)
     self.assertDictEqual(return_value.json,
                          self._products.delete_product(product_name))
示例#5
0
 def test_add_product_ok(self):
     product_name = 'shinny-new-product'
     return_value = MockSprintlyResponse(status_code=200,
                                         reason='OK',
                                         json={
                                             'admin': True,
                                             'archived': False,
                                             'id': 3,
                                             'name': product_name
                                         })
     self._mock_session_for(self._products, 'post', return_value)
     self.assertDictEqual(return_value.json,
                          self._products.add_product(product_name))
示例#6
0
    def test_delete_product_no_paying_account(self):
        return_value = MockSprintlyResponse(status_code=403,
                                            reason='FORBIDDEN',
                                            json={
                                                'code':
                                                403,
                                                'message':
                                                'You do not own an account.'
                                            })
        self._mock_session_for(self._products, 'delete', return_value)

        with self.assertRaises(SprintlyUnauthorizedError) as cm:
            self._products.delete_product(333)
        self.assertEqual('403 - FORBIDDEN', cm.exception.message)