def test_SetInvalidType(self): """Test set() with invalid type.""" with TimestampRecord(self.__tmpfile) as obj: self.assertRaises(ValueError, obj.set, 'unstable', 'i386', 'SunOS5.11', "abcd") with TimestampRecord(self.__tmpfile) as obj: self.assertRaises(TypeError, obj.set, 'unstable', 'i386', 'SunOS5.11', 1)
def test_Many_obj(self): """Multiple pass test writing and retrieving data from a file using datetime obj.""" try: os.unlink(self.__tmpfile) except: pass with TimestampRecord(self.__tmpfile) as obj: [[[obj.set(c[0], c[1], c[2], self.__now) for c in b] for b in a] for a in self.__fixture] obj = TimestampRecord(self.__tmpfile) [[[self.assertEqual(self.__now.isoformat(),obj.get(c[0], c[1], c[2]).isoformat()) for c in b] for b in a] for a in self.__fixture]
def test_LastSuccessfulCheck_obj(self): """Single pass test writing and retrieving data from a file using datetime object.""" try: os.unlink(self.__tmpfile) except: pass with TimestampRecord(self.__tmpfile) as obj: obj.set('unstable', 'sparc', 'SunOS5.10', self.__now) obj = TimestampRecord(self.__tmpfile) self.assertEqual(self.__now.isoformat(), obj.get('unstable', 'sparc', 'SunOS5.10').isoformat())
def test_LastSuccessfulCheck_str(self): """Single pass test writing and retrieving data from a file using string date.""" try: os.unlink(self.__tmpfile) except: pass # With statement used to make sure data is saved to disk with TimestampRecord(self.__tmpfile) as obj: obj.set('unstable', 'sparc', 'SunOS5.10', self.__now.isoformat()) obj = TimestampRecord(self.__tmpfile) self.assertEqual(self.__now.isoformat(), obj.get('unstable', 'sparc', 'SunOS5.10').isoformat())
def test_Many_obj(self): """Multiple pass test writing and retrieving data from a file using datetime obj.""" try: os.unlink(self.__tmpfile) except: pass with TimestampRecord(self.__tmpfile) as obj: [[[obj.set(c[0], c[1], c[2], self.__now) for c in b] for b in a] for a in self.__fixture] obj = TimestampRecord(self.__tmpfile) [[[ self.assertEqual(self.__now.isoformat(), obj.get(c[0], c[1], c[2]).isoformat()) for c in b ] for b in a] for a in self.__fixture]
def test_Notified(self): with TimestampRecord(self.__tmpfile) as obj: obj.set('unstable', 'i386', 'SunOS5.10', datetime.datetime.now().replace(microsecond=0)) obj.notified('unstable', 'i386', 'SunOS5.10', '*****@*****.**') obj.notified('unstable', 'i386', 'SunOS5.10', '*****@*****.**') obj.set('unstable', 'sparc', 'SunOS5.10', datetime.datetime.now().replace(microsecond=0)) obj.notified('unstable', 'sparc', 'SunOS5.10', '*****@*****.**') obj.notified('unstable', 'sparc', 'SunOS5.10', '*****@*****.**') self.assertTrue( obj.is_notified('unstable', 'i386', 'SunOS5.10', '*****@*****.**')) self.assertTrue( obj.is_notified('unstable', 'i386', 'SunOS5.10', '*****@*****.**')) self.assertTrue( obj.is_notified('unstable', 'sparc', 'SunOS5.10', '*****@*****.**')) self.assertTrue( obj.is_notified('unstable', 'sparc', 'SunOS5.10', '*****@*****.**')) with TimestampRecord(self.__tmpfile) as obj: self.assertTrue( obj.is_notified('unstable', 'i386', 'SunOS5.10', '*****@*****.**')) self.assertTrue( obj.is_notified('unstable', 'i386', 'SunOS5.10', '*****@*****.**')) self.assertTrue( obj.is_notified('unstable', 'sparc', 'SunOS5.10', '*****@*****.**')) self.assertTrue( obj.is_notified('unstable', 'sparc', 'SunOS5.10', '*****@*****.**'))
def test_Notification(self): """Test notification for invalid catalog.""" # Create last successful test time stamp for catalog to be tested with TimestampRecord(self.__timestamp_file) as tsobj: tsobj.set('unstable', 'sparc', 'SunOS5.10', datetime.datetime(2013, 5, 17, 0, 0, 0)) with self.TCheckDBCatalogNotification( 'unstable', 'sparc', 'SunOS5.10', self.__timestamp_file, 'go/bin/gen-catalog-index', cattiming_class=TCatalogTiming) as test: self.assertFalse(test.check())