4 new revisions:
Revision: c05e100e7e3c
Branch: default
Author: Pekka Klärck
Date: Thu Jun 13 10:20:42 2013
Log: test_connectioncache: cleanup, test current_index is updated
http://code.google.com/p/robotframework/source/detail?r=c05e100e7e3c
Revision: 09e763943adf
Branch: default
Author: Pekka Klärck
Date: Thu Jun 13 10:54:09 2013
Log: ConnectionCache: assignable current_index...
http://code.google.com/p/robotframework/source/detail?r=09e763943adf
Revision: bbf2c4222163
Branch: default
Author: Pekka Klärck
Date: Thu Jun 13 10:58:32 2013
Log: ConnectionCache: added __nonzero__ to make it easier to check is
curre...
http://code.google.com/p/robotframework/source/detail?r=bbf2c4222163
Revision: d02d3a75fa58
Branch: default
Author: Pekka Klärck
Date: Thu Jun 13 11:14:21 2013
Log: ConnectionCache: cleanup. including removing attribute that was
not us...
http://code.google.com/p/robotframework/source/detail?r=d02d3a75fa58
==============================================================================
Revision: c05e100e7e3c
Branch: default
Author: Pekka Klärck
Date: Thu Jun 13 10:20:42 2013
Log: test_connectioncache: cleanup, test current_index is updated
http://code.google.com/p/robotframework/source/detail?r=c05e100e7e3c
Modified:
/utest/utils/test_connectioncache.py
=======================================
--- /utest/utils/test_connectioncache.py Mon Jun 10 01:48:09 2013
+++ /utest/utils/test_connectioncache.py Thu Jun 13 10:20:42 2013
@@ -1,7 +1,8 @@
import unittest
-import sys
-from robot.utils.asserts import *
+from robot.utils.asserts import (assert_equals, assert_false, assert_true,
+ assert_raises_with_msg)
+
from robot.utils import ConnectionCache
@@ -36,6 +37,7 @@
index = self.cache.register(conn)
assert_equals(index, 1)
assert_equals(self.cache.current, conn)
+ assert_equals(self.cache.current_index, 1)
assert_equals(self.cache._connections, [conn])
assert_equals(self.cache._aliases, {})
@@ -45,6 +47,7 @@
index = self.cache.register(conn)
assert_equals(index, i+1)
assert_equals(self.cache.current, conn)
+ assert_equals(self.cache.current_index, i+1)
assert_equals(self.cache._connections, conns)
def test_switch_with_index(self):
@@ -74,7 +77,7 @@
assert_equals(self.cache._connections, [conn])
assert_equals(self.cache._aliases, {'myconnection': 1})
- def test_register_multiple_with_alis(self):
+ def test_register_multiple_with_alias(self):
c1 = ConnectionMock(); c2 = ConnectionMock(); c3 = ConnectionMock()
for i, conn in enumerate([c1,c2,c3]):
index = self.cache.register(conn, 'c%d' % (i+1))
@@ -129,7 +132,7 @@
def _verify_initial_state(self):
assert_equals(self.cache.current, self.cache._no_current)
- assert_none(self.cache.current_index)
+ assert_equals(self.cache.current_index, None)
assert_equals(self.cache._connections, [])
assert_equals(self.cache._aliases, {})
==============================================================================
Revision: 09e763943adf
Branch: default
Author: Pekka Klärck
Date: Thu Jun 13 10:54:09 2013
Log: ConnectionCache: assignable current_index
Update issue 1474
Status: Done
Fixed with unit tests.
http://code.google.com/p/robotframework/source/detail?r=09e763943adf
Modified:
/src/robot/utils/connectioncache.py
/utest/utils/test_connectioncache.py
=======================================
--- /src/robot/utils/connectioncache.py Mon Jun 10 01:20:11 2013
+++ /src/robot/utils/connectioncache.py Thu Jun 13 10:54:09 2013
@@ -34,12 +34,19 @@
self._aliases = NormalizedDict()
self._no_current_msg = no_current_msg
- @property
- def current_index(self):
+ def _get_current_index(self):
if self.current is self._no_current:
return None
return self._connections.index(self.current) + 1
+ def _set_current_index(self, index):
+ if index is None:
+ self.current = self._no_current
+ else:
+ self.current = self._connections[index - 1]
+
+ current_index = property(_get_current_index, _set_current_index)
+
def register(self, connection, alias=None):
"""Registers given connection with optional alias and returns its
index.
=======================================
--- /utest/utils/test_connectioncache.py Thu Jun 13 10:20:42 2013
+++ /utest/utils/test_connectioncache.py Thu Jun 13 10:54:09 2013
@@ -1,7 +1,7 @@
import unittest
from robot.utils.asserts import (assert_equals, assert_false, assert_true,
- assert_raises_with_msg)
+ assert_raises, assert_raises_with_msg)
from robot.utils import ConnectionCache
@@ -50,6 +50,24 @@
assert_equals(self.cache.current_index, i+1)
assert_equals(self.cache._connections, conns)
+ def test_set_current_index(self):
+ self.cache.current_index = None
+ assert_equals(self.cache.current_index, None)
+ self.cache.register('a')
+ self.cache.register('b')
+ self.cache.current_index = 1
+ assert_equals(self.cache.current_index, 1)
+ assert_equals(self.cache.current, 'a')
+ self.cache.current_index = None
+ assert_equals(self.cache.current_index, None)
+ assert_equals(self.cache.current, self.cache._no_current)
+ self.cache.current_index = 2
+ assert_equals(self.cache.current_index, 2)
+ assert_equals(self.cache.current, 'b')
+
+ def test_set_invalid_index(self):
+ assert_raises(IndexError, setattr, self.cache, 'current_index', 1)
+
def test_switch_with_index(self):
self._register('a', 'b', 'c')
self._assert_current('c', 3)
==============================================================================
Revision: bbf2c4222163
Branch: default
Author: Pekka Klärck
Date: Thu Jun 13 10:58:32 2013
Log: ConnectionCache: added __nonzero__ to make it easier to check is
current active
http://code.google.com/p/robotframework/source/detail?r=bbf2c4222163
Modified:
/src/robot/utils/connectioncache.py
/utest/utils/test_connectioncache.py
=======================================
--- /src/robot/utils/connectioncache.py Thu Jun 13 10:54:09 2013
+++ /src/robot/utils/connectioncache.py Thu Jun 13 10:58:32 2013
@@ -105,6 +105,9 @@
self._connections = []
self._aliases = NormalizedDict()
+ def __nonzero__(self):
+ return self.current is not self._no_current
+
def _resolve_index_or_alias(self, index_or_alias):
try:
return self._resolve_alias(index_or_alias)
=======================================
--- /utest/utils/test_connectioncache.py Thu Jun 13 10:54:09 2013
+++ /utest/utils/test_connectioncache.py Thu Jun 13 10:58:32 2013
@@ -148,6 +148,17 @@
assert_false(conn.closed_by_close)
assert_false(conn.closed_by_exit)
+ def test_truthy(self):
+ assert_false(self.cache)
+ self.cache.register(None)
+ assert_true(self.cache)
+ self.cache.current_index = None
+ assert_false(self.cache)
+ self.cache.current_index = 1
+ assert_true(self.cache)
+ self.cache.empty_cache()
+ assert_false(self.cache)
+
def _verify_initial_state(self):
assert_equals(self.cache.current, self.cache._no_current)
assert_equals(self.cache.current_index, None)
==============================================================================
Revision: d02d3a75fa58
Branch: default
Author: Pekka Klärck
Date: Thu Jun 13 11:14:21 2013
Log: ConnectionCache: cleanup. including removing attribute that was
not used for anything. and hopefully nobody uses externally either....
http://code.google.com/p/robotframework/source/detail?r=d02d3a75fa58
Modified:
/src/robot/utils/connectioncache.py
=======================================
--- /src/robot/utils/connectioncache.py Thu Jun 13 10:58:32 2013
+++ /src/robot/utils/connectioncache.py Thu Jun 13 11:14:21 2013
@@ -32,18 +32,13 @@
self.current = self._no_current = NoConnection(no_current_msg)
self._connections = []
self._aliases = NormalizedDict()
- self._no_current_msg = no_current_msg
def _get_current_index(self):
- if self.current is self._no_current:
- return None
- return self._connections.index(self.current) + 1
+ return self._connections.index(self.current) + 1 if self else None
def _set_current_index(self, index):
- if index is None:
- self.current = self._no_current
- else:
- self.current = self._connections[index - 1]
+ self.current = self._connections[index - 1] \
+ if index is not None else self._no_current
current_index = property(_get_current_index, _set_current_index)
--
---
You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.