Beispiel #1
0
 def test_set_spe(self):
     for spid in GOOD:
         pid = Pid(spid)
         t, p, e = 1, 'foo', 'bar'
         pid.target = t
         pid.product = p
         pid.extension = e
         expected = '%s_%05d_%s.%s' % (spid, t, p, e)
         assert pid.pid == expected
Beispiel #2
0
 def test_copy_unparsed(self):
     for spid in GOOD:
         # create invalid, unparsed pid
         pid = Pid('_' + spid, parse=False)
         # copy it
         copy = pid.copy()
         # now parse it, expecting ValueError
         with self.assertRaises(ValueError):
             copy.parsed
Beispiel #3
0
 def test_destroy(self):
     for pid in GOOD:
         d = DestroyPid(pid)
         for p in d.insert_character():
             with self.assertRaises(ValueError):
                 Pid(p).parsed
         for p in d.delete_character():
             with self.assertRaises(ValueError):
                 Pid(p).parsed
         for p in d.mod_letter():
             with self.assertRaises(ValueError):
                 Pid(p).parsed
Beispiel #4
0
 def test_tpe(self):
     for spid in GOOD:
         t, p, e = 927, 'baz', 'quux'
         pid = Pid('%s_%05d_%s.%s' % (spid, t, p, e))
         assert pid.target == t, 'target wrong'
         assert pid.product == p, 'product wrong'
         assert pid.extension == e, 'extension wrong'
Beispiel #5
0
 def test_timestamp(self):
     for pid in GOOD:
         dt = Pid(pid).timestamp
         assert dt.year == 2000, 'year wrong'
         assert dt.month == 1, 'month wrong'
         assert dt.day == 1, 'day wrong'
         assert dt.hour == 12, 'hour wrong'
         assert dt.minute == 34, 'minute wrong'
         assert dt.second == 56, 'second wrong'
Beispiel #6
0
 def test_day_prefix(self):
     assert Pid(GOOD_V2).day_prefix == 'D20000101'
Beispiel #7
0
 def test_instrument(self):
     assert Pid(GOOD_V2).instrument == 1
Beispiel #8
0
 def test_day_prefix(self):
     assert Pid(GOOD_V1).day_prefix == 'IFCB1_2000_001'
Beispiel #9
0
 def test_copy(self):
     for spid in GOOD:
         pid = Pid(spid)
         copy = pid.copy()
         assert pid == copy
Beispiel #10
0
 def test_two_targets(self):
     for spid in GOOD:
         with self.assertRaises(ValueError):
             # does not fail, returns target '00001'
             Pid(spid + '_00001_00007').parsed
Beispiel #11
0
 def test_two_extensions(self):
     for spid in GOOD:
         with self.assertRaises(ValueError):
             # does not fail, returns extension 'foo'
             Pid(spid + '.foo.bar').parsed
Beispiel #12
0
 def test_with_target(self):
     for spid in GOOD:
         pid = Pid(spid)
         target = 27
         expected = spid + '_%05d' % 27
         assert pid.with_target(target) == expected
Beispiel #13
0
 def test_set_extension(self):
     for spid in GOOD:
         pid, extension = Pid(spid), 'foo'
         pid.extension = extension
         assert pid.pid == '%s.%s' % (spid, extension)
Beispiel #14
0
 def test_set_product(self):
     for spid in GOOD:
         pid, product = Pid(spid), 'foo'
         pid.product = product
         assert pid.pid == '%s_%s' % (spid, product)
Beispiel #15
0
 def test_set_target(self):
     for spid in GOOD:
         pid, target = Pid(spid), 7
         pid.target = target
         assert pid.pid == '%s_%05d' % (spid, target)
Beispiel #16
0
 def test_extension(self):
     for spid in GOOD:
         extension = 'bar'
         pid = Pid('%s.%s' % (spid, extension))
         assert pid.extension == extension
Beispiel #17
0
 def test_product(self):
     for spid in GOOD:
         product = 'foo'
         pid = Pid('%s_%s' % (spid, product))
         assert pid.product == product
Beispiel #18
0
 def test_schema_version(self):
     assert Pid(GOOD_V1).schema_version == 1, 'expected schema version 1'
     assert Pid(GOOD_V2).schema_version == 2, 'expected schema version 2'
Beispiel #19
0
 def test_unparse(self):
     for pid in GOOD:
         assert ids.unparse(Pid(pid).parsed) == pid
Beispiel #20
0
 def test_target(self):
     for spid in GOOD:
         target = 27
         pid = Pid('%s_%05d' % (spid, target))
         assert pid.target == target
Beispiel #21
0
 def test_target(self):
     target = 123
     target_string = '%05d' % target
     for pid in GOOD:
         target_pid = '%s_%s' % (pid, target_string)
         assert Pid(target_pid).target == target, 'target wrong'
Beispiel #22
0
 def test_eq(self):
     for spid in GOOD:
         assert Pid(spid) == Pid(spid)
         assert Pid(spid) == spid
Beispiel #23
0
 def test_pathname(self):
     path_prefixes = ['\\foo\\bar\\', 'C:\\foo\\bar\\', '/foo/bar/']
     for pid in GOOD:
         for pp in path_prefixes:
             Pid(pp + pid).parsed
Beispiel #24
0
 def test_ne(self):
     for spid in GOOD:
         diff = spid + '.foo'
         assert Pid(spid) != Pid(diff)
         assert Pid(spid) != diff
Beispiel #25
0
 def __init__(self, pid):
     self.pid = Pid(pid)
Beispiel #26
0
 def test_two_products(self):
     for spid in GOOD:
         with self.assertRaises(ValueError):
             # does not fail, returns product 'foo_bar'
             Pid(spid + '_foo_bar').parsed