Ejemplo n.º 1
0
    def test_13_group_list(self):
        postparams = '%s=1' % json.dumps({})
        res = self.app.post('/api/action/group_list', params=postparams)
        res_obj = json.loads(res.body)
        assert_dicts_equal_ignoring_ordering(
            res_obj,
            {
                'result': [
                    'david',
                    'roger'
                    ],
                'help': 'Returns a list of groups',
                'success': True
            })

        #Get all fields
        postparams = '%s=1' % json.dumps({'all_fields':True})
        res = self.app.post('/api/action/group_list', params=postparams)
        res_obj = json.loads(res.body)

        assert res_obj['success'] == True
        assert res_obj['result'][0]['name'] == 'david'
        assert res_obj['result'][0]['display_name'] == 'Dave\'s books'
        assert res_obj['result'][0]['packages'] == 2
        assert res_obj['result'][1]['name'] == 'roger'
        assert res_obj['result'][1]['packages'] == 1
        assert 'id' in res_obj['result'][0]
        assert 'revision_id' in res_obj['result'][0]
        assert 'state' in res_obj['result'][0]
Ejemplo n.º 2
0
    def test_13_group_list(self):
        postparams = '%s=1' % json.dumps({})
        res = self.app.post('/api/action/group_list', params=postparams)
        res_obj = json.loads(res.body)
        assert_dicts_equal_ignoring_ordering(
            res_obj, {
                'result': ['david', 'roger'],
                'help': 'Returns a list of groups',
                'success': True
            })

        #Get all fields
        postparams = '%s=1' % json.dumps({'all_fields': True})
        res = self.app.post('/api/action/group_list', params=postparams)
        res_obj = json.loads(res.body)

        assert res_obj['success'] == True
        assert res_obj['result'][0]['name'] == 'david'
        assert res_obj['result'][0]['display_name'] == 'Dave\'s books'
        assert res_obj['result'][0]['packages'] == 2
        assert res_obj['result'][1]['name'] == 'roger'
        assert res_obj['result'][1]['packages'] == 1
        assert 'id' in res_obj['result'][0]
        assert 'revision_id' in res_obj['result'][0]
        assert 'state' in res_obj['result'][0]
Ejemplo n.º 3
0
 def test_06_tag_list(self):
     postparams = '%s=1' % json.dumps({})
     res = self.app.post('/api/action/tag_list', params=postparams)
     assert_dicts_equal_ignoring_ordering(
         json.loads(res.body),
         {'help': 'Returns a list of tags',
          'success': True,
          'result': ['russian', 'tolstoy']})
     #Get all fields
     postparams = '%s=1' % json.dumps({'all_fields':True})
     res = self.app.post('/api/action/tag_list', params=postparams)
     res_obj = json.loads(res.body)
     pprint(res_obj)
     assert res_obj['success'] == True
     if res_obj['result'][0]['name'] == 'russian':
         russian_index = 0
         tolstoy_index = 1
     else:
         russian_index = 1
         tolstoy_index = 0
     assert res_obj['result'][russian_index]['name'] == 'russian'
     assert len(res_obj['result'][russian_index]['packages']) - \
            len(res_obj['result'][tolstoy_index]['packages']) == 1
     assert res_obj['result'][tolstoy_index]['name'] == 'tolstoy'
     assert 'id' in res_obj['result'][0]
     assert 'id' in res_obj['result'][1]
Ejemplo n.º 4
0
 def test_01_package_list(self):
     postparams = '%s=1' % json.dumps({})
     res = self.app.post('/api/action/package_list', params=postparams)
     assert_dicts_equal_ignoring_ordering(
         json.loads(res.body),
         {"help": "Lists packages by name or id",
          "success": True,
          "result": ["annakarenina", "warandpeace"]})
Ejemplo n.º 5
0
 def test_01_package_list(self):
     postparams = '%s=1' % json.dumps({})
     res = self.app.post('/api/action/package_list', params=postparams)
     assert_dicts_equal_ignoring_ordering(
         json.loads(res.body), {
             "help": "Lists packages by name or id",
             "success": True,
             "result": ["annakarenina", "warandpeace"]
         })
Ejemplo n.º 6
0
    def test_06_tag_list(self):
        postparams = '%s=1' % json.dumps({})
        res = self.app.post('/api/action/tag_list', params=postparams)
        assert_dicts_equal_ignoring_ordering(
            json.loads(res.body), {
                'help': 'Returns a list of tags',
                'success': True,
                'result': ['russian', 'tolstoy', u'Flexible \u30a1']
            })
        #Get all fields
        postparams = '%s=1' % json.dumps({'all_fields': True})
        res = self.app.post('/api/action/tag_list', params=postparams)
        res_obj = json.loads(res.body)
        pprint(res_obj)
        assert res_obj['success'] == True

        names = [
            res_obj['result'][i]['name']
            for i in xrange(len(res_obj['result']))
        ]
        russian_index = names.index('russian')
        tolstoy_index = names.index('tolstoy')
        flexible_index = names.index(u'Flexible \u30a1')

        assert res_obj['result'][russian_index]['name'] == 'russian'
        assert res_obj['result'][tolstoy_index]['name'] == 'tolstoy'

        # The "moo" package may part of the retrieved packages, depending
        # upon whether this test is run in isolation from the rest of the
        # test suite or not.
        number_of_russian_packages = len(
            res_obj['result'][russian_index]
            ['packages'])  # warandpeace, annakarenina (moo?)
        number_of_tolstoy_packages = len(
            res_obj['result'][tolstoy_index]['packages'])  # annakarenina
        number_of_flexible_packages = len(
            res_obj['result'][flexible_index]
            ['packages'])  # warandpeace, annakarenina (moo?)

        # Assert we have the correct number of packages, independantly of
        # whether the "moo" package may exist or not.
        assert number_of_russian_packages - number_of_tolstoy_packages == 1
        assert number_of_flexible_packages == (number_of_russian_packages -
                                               number_of_tolstoy_packages) + 1

        assert 'id' in res_obj['result'][0]
        assert 'id' in res_obj['result'][1]
        assert 'id' in res_obj['result'][2]
Ejemplo n.º 7
0
    def test_06_tag_list(self):
        postparams = '%s=1' % json.dumps({})
        res = self.app.post('/api/action/tag_list', params=postparams)
        assert_dicts_equal_ignoring_ordering(
            json.loads(res.body),
            {'help': 'Returns a list of tags',
             'success': True,
             'result': ['russian', 'tolstoy', u'Flexible \u30a1']})
        #Get all fields
        postparams = '%s=1' % json.dumps({'all_fields':True})
        res = self.app.post('/api/action/tag_list', params=postparams)
        res_obj = json.loads(res.body)
        pprint(res_obj)
        assert res_obj['success'] == True

        names = [ res_obj['result'][i]['name'] for i in xrange(len(res_obj['result'])) ]
        russian_index = names.index('russian')
        tolstoy_index = names.index('tolstoy')
        flexible_index = names.index(u'Flexible \u30a1')

        assert res_obj['result'][russian_index]['name'] == 'russian'
        assert res_obj['result'][tolstoy_index]['name'] == 'tolstoy'

        # The "moo" package may part of the retrieved packages, depending
        # upon whether this test is run in isolation from the rest of the
        # test suite or not.
        number_of_russian_packages = len(res_obj['result'][russian_index]['packages'])   # warandpeace, annakarenina (moo?)
        number_of_tolstoy_packages = len(res_obj['result'][tolstoy_index]['packages'])   # annakarenina
        number_of_flexible_packages = len(res_obj['result'][flexible_index]['packages']) # warandpeace, annakarenina (moo?)
        
        # Assert we have the correct number of packages, independantly of
        # whether the "moo" package may exist or not.
        assert number_of_russian_packages - number_of_tolstoy_packages == 1
        assert number_of_flexible_packages == (number_of_russian_packages - number_of_tolstoy_packages) + 1

        assert 'id' in res_obj['result'][0]
        assert 'id' in res_obj['result'][1]
        assert 'id' in res_obj['result'][2]