コード例 #1
0
ファイル: test_metadata.py プロジェクト: rainavishal1/saliweb
 def test_set(self):
     """Check _JobMetadata set methods and syncing"""
     m = _JobMetadata(['key1', 'key2', 'state'], ['value1', 'value2', 'foo'])
     self.assertEqual(m.needs_sync(), False)
     self.assertRaises(KeyError, m.__setitem__, 'nokey', 'bar')
     m['key1'] = 'value1'
     self.assertEqual(m.needs_sync(), False)
     m['key1'] = 'value2'
     self.assertEqual(m.needs_sync(), True)
     m.mark_synced()
     self.assertEqual(m.needs_sync(), False)
コード例 #2
0
 def test_set(self):
     """Check _JobMetadata set methods and syncing"""
     m = _JobMetadata(['key1', 'key2', 'state'],
                      ['value1', 'value2', 'foo'])
     self.assertEqual(m.needs_sync(), False)
     self.assertRaises(KeyError, m.__setitem__, 'nokey', 'bar')
     m['key1'] = 'value1'
     self.assertEqual(m.needs_sync(), False)
     m['key1'] = 'value2'
     self.assertEqual(m.needs_sync(), True)
     m.mark_synced()
     self.assertEqual(m.needs_sync(), False)
コード例 #3
0
ファイル: test_metadata.py プロジェクト: rainavishal1/saliweb
 def test_get(self):
     """Check _JobMetadata get methods"""
     m = _JobMetadata(['key1', 'key2', 'state'], ['value1', 'value2', 'foo'])
     self.assertEqual(m['key1'], 'value1')
     self.assertEqual(m.get('key1'), 'value1')
     self.assertEqual(m.get('nokey', 'bar'), 'bar')
     self.assertEqual(m.get('nokey'), None)
     self.assertRaises(KeyError, m.__getitem__, 'nokey')
     k = m.keys()
     k.sort()
     self.assertEqual(k, ['key1', 'key2'])
     v = m.values()
     v.sort()
     self.assertEqual(v, ['value1', 'value2'])
コード例 #4
0
 def test_get(self):
     """Check _JobMetadata get methods"""
     m = _JobMetadata(['key1', 'key2', 'state'],
                      ['value1', 'value2', 'foo'])
     self.assertEqual(m['key1'], 'value1')
     self.assertEqual(m.get('key1'), 'value1')
     self.assertEqual(m.get('nokey', 'bar'), 'bar')
     self.assertEqual(m.get('nokey'), None)
     self.assertRaises(KeyError, m.__getitem__, 'nokey')
     k = m.keys()
     k.sort()
     self.assertEqual(k, ['key1', 'key2'])
     v = m.values()
     v.sort()
     self.assertEqual(v, ['value1', 'value2'])
コード例 #5
0
 def test_init(self):
     """Check creation of _JobMetadata class"""
     m = _JobMetadata(['key1', 'key2', 'state'],
                      ['value1', 'value2', 'foo'])
     # state key should be removed
     self.assertEqual(len(m.keys()), 2)
コード例 #6
0
ファイル: test_metadata.py プロジェクト: rainavishal1/saliweb
 def test_init(self):
     """Check creation of _JobMetadata class"""
     m = _JobMetadata(['key1', 'key2', 'state'], ['value1', 'value2', 'foo'])
     # state key should be removed
     self.assertEqual(len(m.keys()), 2)