Ejemplo n.º 1
0
 def test_200(self):
     """Session is successfully saved and then loaded (pickled and unpickled)"""
     tmp_pickle = './pickle.tmp'
     try:
         os.unlink(tmp_pickle)
     except OSError:
         pass
     s1 = session.Session(nodes, format_ids)
     u = str(uuid.uuid1())
     s1.set('rights-holder', u)
     s1.save(tmp_pickle)
     s2 = session.Session(nodes, format_ids)
     s2.load(tmp_pickle)
     self.assertEqual(s2.get('rights-holder'), u)
Ejemplo n.º 2
0
 def test_025(self):
     """Session parameters can be updated with set()"""
     s = session.Session(nodes, format_ids)
     s.set('verbose', False),
     s.set('rights-holder', 'test')
     self.assertEqual(s.get('verbose'), False)
     self.assertEqual(s.get('rights-holder'), 'test')
Ejemplo n.º 3
0
 def test_040(self):
     """Session parameters can be brought back to their defaults with reset()"""
     s = session.Session(nodes, format_ids)
     s.set('query', 'testquery'),
     self.assertEqual(s.get('query'), 'testquery')
     s.reset()
     self.assertEqual(s.get('query'), '*:*')
Ejemplo n.º 4
0
 def __init__(self):
     self._nodes = nodes.Nodes()
     self._format_ids = format_ids.FormatIDs()
     self._session = session.Session(self._nodes, self._format_ids)
     self._session.load(suppress_error=True)
     self._object_format_id_cache = None
     self._operation_queue = operation_queue.OperationQueue(self._session)
     self._operation_maker = operation_maker.OperationMaker(self._session)
Ejemplo n.º 5
0
 def test_140(self):
     """print_all_variables() is available and appears to work"""
     # capture stdout
     old = sys.stdout
     sys.stdout = StringIO.StringIO()
     # run print
     s = session.Session(nodes, format_ids)
     s.print_all_variables()
     # release stdout
     out = sys.stdout.getvalue()
     sys.stdout = old
     # validate
     self.assertTrue(len(out) > 100)
     self.assertTrue(type(out) is str)
Ejemplo n.º 6
0
 def test_035(self):
     """Setting valid CN is successful"""
     s = session.Session(nodes, format_ids)
     valid_cn = 'https://cn-unm-1.dataone.org/cn'
     s.set('cn-url', valid_cn)
     self.assertEqual(s.get('cn-url'), valid_cn)
Ejemplo n.º 7
0
 def test_030(self):
     """Setting invalid CN fails"""
     s = session.Session(nodes, format_ids)
     print 'Hit Enter on "Use anyway?" prompt'
     self.assertRaises(cli_exceptions.InvalidArguments, s.set, 'cn-url',
                       'test')
Ejemplo n.º 8
0
 def test_020(self):
     """After instatiation, the default session parameters are available via get()"""
     s = session.Session(nodes, format_ids)
     #self.assertEqual(s.get('pretty'), True)
     self.assertEqual(s.get('cn-url'), d1_common.const.URL_DATAONE_ROOT)
Ejemplo n.º 9
0
 def test_010(self):
     """The session object can be instantiated"""
     s = session.Session(nodes, format_ids)
     self.assertNotEquals(None, s, 'Could not instantiate session.')
Ejemplo n.º 10
0
 def test_130(self):
     """Session object exposes access control"""
     s = session.Session(nodes, format_ids)
     s.get_access_control().add_allowed_subject('newsubject', 'write')
Ejemplo n.º 11
0
 def test_120(self):
     """set_with_conversion() raises InvalidArguments on non-existing session parameter"""
     s = session.Session(nodes, format_ids)
     self.assertRaises(cli_exceptions.InvalidArguments,
                       s.set_with_conversion, 'bogus-value', '1')
Ejemplo n.º 12
0
 def test_110(self):
     """set_with_conversion() handles integer conversions"""
     s = session.Session(nodes, format_ids)
     self.assertEqual(s.get('verbose'), True)
     s.set_with_conversion('verbose', '1')
     self.assertEqual(s.get('verbose'), 1)
Ejemplo n.º 13
0
 def test_100(self):
     """set_with_conversion() handles None"""
     s = session.Session(nodes, format_ids)
     self.assertEqual(s.get('verbose'), True)
     s.set_with_conversion('verbose', 'None')
     self.assertEqual(s.get('verbose'), None)
Ejemplo n.º 14
0
 def test_050(self):
     """Getting an non-existing session parameter raises InvalidArguments"""
     s = session.Session(nodes, format_ids)
     self.assertRaises(cli_exceptions.InvalidArguments, s.get,
                       'bogus-value')