예제 #1
0
 def test_expiry_passed(self):
     base = next(self.base_locators(1))
     signature = next(self.signatures(1))
     dt1980 = datetime.datetime(1980, 1, 1)
     dt2000 = datetime.datetime(2000, 2, 2)
     dt2080 = datetime.datetime(2080, 3, 3)
     locator = KeepLocator(base)
     self.assertFalse(locator.permission_expired())
     self.assertFalse(locator.permission_expired(dt1980))
     self.assertFalse(locator.permission_expired(dt2080))
     # Timestamped to 1987-01-05 18:48:32.
     locator = KeepLocator('{}+A{}@20000000'.format(base, signature))
     self.assertTrue(locator.permission_expired())
     self.assertTrue(locator.permission_expired(dt2000))
     self.assertFalse(locator.permission_expired(dt1980))
예제 #2
0
 def test_expiry_passed(self):
     base = next(self.base_locators(1))
     signature = next(self.signatures(1))
     dt1980 = datetime.datetime(1980, 1, 1)
     dt2000 = datetime.datetime(2000, 2, 2)
     dt2080 = datetime.datetime(2080, 3, 3)
     locator = KeepLocator(base)
     self.assertFalse(locator.permission_expired())
     self.assertFalse(locator.permission_expired(dt1980))
     self.assertFalse(locator.permission_expired(dt2080))
     # Timestamped to 1987-01-05 18:48:32.
     locator = KeepLocator('{}+A{}@20000000'.format(base, signature))
     self.assertTrue(locator.permission_expired())
     self.assertTrue(locator.permission_expired(dt2000))
     self.assertFalse(locator.permission_expired(dt1980))
예제 #3
0
    def reader_for(self, coll_name, **kwargs):
        stream = []
        segments = []
        n = 0
        for d in self.manifest_for(coll_name).split():
            try:
                k = KeepLocator(d)
                segments.append(Range(n, n, k.size))
                stream.append(Range(d, n, k.size))
                n += k.size
            except ValueError:
                pass

        blockmanager = arvados.arvfile._BlockManager(self.keep_client())
        blockmanager.prefetch_enabled = False
        col = Collection(keep_client=self.keep_client(),
                         block_manager=blockmanager)
        af = ArvadosFile(col, "test", stream=stream, segments=segments)
        return ArvadosFileReader(af, **kwargs)
예제 #4
0
 def test_multiple_locator_hints_accepted(self):
     base = next(self.base_locators(1))
     for loc_hints in itertools.permutations(['Kab1cd', 'Kef2gh',
                                              'Kij3kl']):
         locator = '+'.join((base, ) + loc_hints)
         self.assertEqual(locator, str(KeepLocator(locator)))
예제 #5
0
 def test_unknown_hints_accepted(self):
     base = next(self.base_locators(1))
     for weirdhint in ['Zfoo', 'Ybar234', 'Xa@b_c-372', 'W99']:
         locator = '+'.join([base, weirdhint])
         self.assertEqual(locator, str(KeepLocator(locator)))
예제 #6
0
 def test_good_locators_returned(self):
     for hint_gens in [(), (self.sizes(), ),
                       (self.sizes(), self.perm_hints())]:
         for loc_data in itertools.izip(self.checksums(), *hint_gens):
             locator = '+'.join(loc_data)
             self.assertEqual(locator, str(KeepLocator(locator)))
예제 #7
0
 def test_str_type(self):
     base = next(self.base_locators(1))
     locator = KeepLocator(base)
     self.assertEqual(type(''), type(locator.__str__()))