Revision 6ee6677e snf-pithos-app/pithos/api/test/accounts.py

b/snf-pithos-app/pithos/api/test/accounts.py
112 112
    def test_get_account_meta_until_invalid_date(self):
113 113
        self.update_account_meta({'quality': 'AAA'})
114 114
        meta = self.get_account_meta(until='-1')
115
        self.assertTrue('X-Account-Meta-Quality' in meta)
115
        self.assertTrue('Quality' in meta)
116 116

  
117 117

  
118 118
class AccountGet(PithosAPITest):
......
354 354

  
355 355
            meta.update(initial)
356 356
            account_meta = self.get_account_meta()
357
            (self.assertTrue('X-Account-Meta-%s' % k in account_meta) for
358
                k in meta.keys())
359
            (self.assertEqual(account_meta['X-Account-Meta-%s' % k], v) for
360
                k, v in meta.items())
357
            (self.assertTrue(k in account_meta) for k in meta.keys())
358
            (self.assertEqual(account_meta[k], v) for k, v in meta.items())
361 359

  
362 360
    def test_reset_meta(self):
363 361
        url = join_urls(self.pithos_path, self.user)
......
373 371
            self.assertEqual(r.status_code, 202)
374 372

  
375 373
            account_meta = self.get_account_meta()
376
            (self.assertTrue('X-Account-Meta-%s' % k in account_meta) for
377
                k in new_meta.keys())
378
            (self.assertEqual(account_meta['X-Account-Meta-%s' % k], v) for
379
                k, v in new_meta.items())
374
            (self.assertTrue(k in account_meta) for k in new_meta.keys())
375
            (self.assertEqual(account_meta[k], v) for k, v in new_meta.items())
380 376

  
381
            (self.assertTrue('X-Account-Meta-%s' % k not in account_meta) for
382
                k in meta.keys())
377
            (self.assertTrue(k not in account_meta) for k in meta.keys())
383 378

  
384 379
    def test_delete_meta(self):
385 380
        url = join_urls(self.pithos_path, self.user)
......
394 389

  
395 390
            account_meta = self.get_account_meta()
396 391

  
397
            (self.assertTrue('X-Account-Meta-%s' % k not in account_meta) for
398
                k in meta.keys())
392
            (self.assertTrue(k not in account_meta) for k in meta.keys())
399 393

  
400 394
    def test_set_account_groups(self):
401 395
        url = join_urls(self.pithos_path, self.user)
......
406 400
            self.assertEqual(r.status_code, 202)
407 401

  
408 402
            account_groups = self.get_account_groups()
409
            self.assertTrue(
410
                'X-Account-Group-Pithosdev' in self.get_account_groups())
411
            self.assertEqual(
412
                account_groups['X-Account-Group-Pithosdev'],
413
                ','.join(sorted(pithosdevs)))
403
            self.assertTrue('Pithosdev' in self.get_account_groups())
404
            self.assertEqual(account_groups['Pithosdev'],
405
                             ','.join(sorted(pithosdevs)))
414 406

  
415 407
            clientdevs = ['pkanavos', 'mvasilak']
416 408
            r = self.post('%s?update=' % url,
......
418 410
            self.assertEqual(r.status_code, 202)
419 411

  
420 412
            account_groups = self.get_account_groups()
421
            self.assertTrue(
422
                'X-Account-Group-Pithosdev' in account_groups)
423
            self.assertTrue(
424
                'X-Account-Group-Clientsdev' in account_groups)
425
            self.assertEqual(
426
                account_groups['X-Account-Group-Pithosdev'],
427
                ','.join(sorted(pithosdevs)))
428
            self.assertEqual(
429
                account_groups['X-Account-Group-Clientsdev'],
430
                ','.join(sorted(clientdevs)))
413
            self.assertTrue('Pithosdev' in account_groups)
414
            self.assertTrue('Clientsdev' in account_groups)
415
            self.assertEqual(account_groups['Pithosdev'],
416
                             ','.join(sorted(pithosdevs)))
417
            self.assertEqual(account_groups['Clientsdev'],
418
                             ','.join(sorted(clientdevs)))
431 419

  
432 420
            clientdevs = ['mvasilak']
433 421
            r = self.post('%s?update=' % url,
......
435 423
            self.assertEqual(r.status_code, 202)
436 424

  
437 425
            account_groups = self.get_account_groups()
438
            self.assertTrue(
439
                'X-Account-Group-Pithosdev' in account_groups)
440
            self.assertTrue(
441
                'X-Account-Group-Clientsdev' in account_groups)
442
            self.assertEqual(
443
                account_groups['X-Account-Group-Pithosdev'],
444
                ','.join(sorted(pithosdevs)))
445
            self.assertEqual(
446
                account_groups['X-Account-Group-Clientsdev'],
447
                ','.join(sorted(clientdevs)))
426
            self.assertTrue('Pithosdev' in account_groups)
427
            self.assertTrue('Clientsdev' in account_groups)
428
            self.assertEqual(account_groups['Pithosdev'],
429
                             ','.join(sorted(pithosdevs)))
430
            self.assertEqual(account_groups['Clientsdev'],
431
                             ','.join(sorted(clientdevs)))
448 432

  
449 433
    def test_reset_account_groups(self):
450 434
        url = join_urls(self.pithos_path, self.user)
......
463 447
            headers = dict(('HTTP_X_ACCOUNT_GROUP_%s' % k, ','.join(v))
464 448
                           for k, v in groups.iteritems())
465 449
            account_meta = self.get_account_meta()
466
            headers.update(dict(('HTTP_%s' % k.upper().replace('-', '_'), v)
467
                           for k, v in account_meta.iteritems()))
450
            headers.update(dict(('HTTP_X_ACCOUNT_META_%s' %
451
                                k.upper().replace('-', '_'), v) for
452
                                k, v in account_meta.iteritems()))
468 453
            r = self.post(url, **headers)
469 454
            self.assertEqual(r.status_code, 202)
470 455

  
471 456
            account_groups = self.get_account_groups()
472
            self.assertTrue(
473
                'X-Account-Group-Pithosdev' in account_groups)
474
            self.assertTrue(
475
                'X-Account-Group-Clientsdev' not in account_groups)
476
            self.assertEqual(
477
                account_groups['X-Account-Group-Pithosdev'],
478
                ','.join(sorted(groups['pithosdev'])))
457
            self.assertTrue('Pithosdev' in account_groups)
458
            self.assertTrue('Clientsdev' not in account_groups)
459
            self.assertEqual(account_groups['Pithosdev'],
460
                             ','.join(sorted(groups['pithosdev'])))
479 461

  
480 462
    def test_delete_account_groups(self):
481 463
        url = join_urls(self.pithos_path, self.user)
......
492 474
            self.assertEqual(r.status_code, 202)
493 475

  
494 476
            account_groups = self.get_account_groups()
495
            self.assertTrue(
496
                'X-Account-Group-Pithosdev' not in account_groups)
497
            self.assertTrue(
498
                'X-Account-Group-Clientsdev' not in account_groups)
477
            self.assertTrue('Pithosdev' not in account_groups)
478
            self.assertTrue('Clientsdev' not in account_groups)

Also available in: Unified diff