~ubuntu-branches/ubuntu/saucy/python-ceilometerclient/saucy

« back to all changes in this revision

Viewing changes to tests/v2/test_options.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Yolanda Robla
  • Date: 2013-07-04 07:13:11 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130704071311-jmbr0fvce4fhtp79
Tags: 1.0.1-0ubuntu1
[ Chuck Short ]
* New upstream release. 
* debian/control: 
  - Dropped python-unittest2, python-nose.
  - Added python-coverage, python-fixtures, python-subunit,
    python-testtools, python-testrepository, python-d2to1,
    python-pbr
  - Dropped duplicate python-setuptools-git
  - Dropped pep8.
* debian/rules: Convert testsuite to use testr.

[ Yolanda Robla ]
* debian/tests: added autopkg tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
#    License for the specific language governing permissions and limitations
12
12
#    under the License.
13
13
 
14
 
import unittest
15
 
 
16
14
from ceilometerclient.v2 import options
17
 
 
18
 
 
19
 
class BuildUrlTest(unittest.TestCase):
 
15
from tests import utils
 
16
 
 
17
 
 
18
class BuildUrlTest(utils.BaseTestCase):
20
19
 
21
20
    def test_one(self):
22
21
        url = options.build_url('/', [{'field': 'this',
42
41
        self.assertEqual(url, '/?q.op=&q.value=43&q.field=this')
43
42
 
44
43
 
45
 
class CliTest(unittest.TestCase):
 
44
class CliTest(utils.BaseTestCase):
46
45
 
47
46
    def test_one(self):
48
47
        ar = options.cli_to_array('this<=34')
49
 
        self.assertEqual(ar, [{'field': 'this','op': 'le','value': '34'}])
 
48
        self.assertEqual(ar, [{'field': 'this', 'op': 'le', 'value': '34'}])
50
49
 
51
50
    def test_two(self):
52
51
        ar = options.cli_to_array('this<=34;that!=foo')
53
 
        self.assertEqual(ar, [{'field': 'this','op': 'le','value': '34'},
54
 
                              {'field': 'that','op': 'ne','value': 'foo'}])
 
52
        self.assertEqual(ar, [{'field': 'this', 'op': 'le', 'value': '34'},
 
53
                              {'field': 'that', 'op': 'ne', 'value': 'foo'}])
55
54
 
56
55
    def test_negative(self):
57
56
        ar = options.cli_to_array('this>=-783')
58
 
        self.assertEqual(ar, [{'field': 'this','op': 'ge','value': '-783'}])
 
57
        self.assertEqual(ar, [{'field': 'this', 'op': 'ge', 'value': '-783'}])
59
58
 
60
59
    def test_float(self):
61
60
        ar = options.cli_to_array('this<=283.347')
62
 
        self.assertEqual(ar, [{'field': 'this','op': 'le','value': '283.347'}])
 
61
        self.assertEqual(ar, [{'field': 'this',
 
62
                               'op': 'le', 'value': '283.347'}])
63
63
 
64
64
    def test_invalid_seperator(self):
65
 
        self.assertRaises(ValueError, options.cli_to_array, 'this=2.4,fooo=doof')
 
65
        self.assertRaises(ValueError, options.cli_to_array,
 
66
                          'this=2.4,fooo=doof')
66
67
 
67
68
    def test_invalid_operator(self):
68
 
        self.assertRaises(ValueError, options.cli_to_array, 'this=2.4;fooo-doof')
 
69
        self.assertRaises(ValueError, options.cli_to_array,
 
70
                          'this=2.4;fooo-doof')
69
71
 
70
72
    def test_with_dot(self):
71
73
        ar = options.cli_to_array('metadata.this<=34')
72
 
        self.assertEqual(ar, [{'field': 'metadata.this','op': 'le','value': '34'}])
 
74
        self.assertEqual(ar, [{'field': 'metadata.this',
 
75
                               'op': 'le', 'value': '34'}])