Repository: opensistemas-hub/osbrain
Pull request #70 (2017-03-10 11:57:27)

Remove ready method from agent, since it is the same than ping
I noticed than `Agent.ready()` and `Agent.ping()` were basically doing the same thing.

codecov[bot]: # [Codecov](https://codecov.io/gh/opensistemas-hub/osbrain/pull/70?src=pr&el=h1) Report
> Merging [#70](https://codecov.io/gh/opensistemas-hub/osbrain/pull/70?src=pr&el=desc) into [master](https://codecov.io/gh/opensistemas-hub/osbrain/commit/338b8b488bc9d1a0b6df366550535f3919b1272e?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.


```diff
@@            Coverage Diff             @@
##           master      #70      +/-   ##
==========================================
- Coverage   95.88%   95.87%   -0.01%     
==========================================
  Files           7        7              
  Lines         875      873       -2     
  Branches      124      124              
==========================================
- Hits          839      837       -2     
  Misses         26       26              
  Partials       10       10
```


| [Impacted Files](https://codecov.io/gh/opensistemas-hub/osbrain/pull/70?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [osbrain/agent.py](https://codecov.io/gh/opensistemas-hub/osbrain/compare/338b8b488bc9d1a0b6df366550535f3919b1272e...62e6bba7446239ef1f4eaa9ed86ab086eb7118bb?src=pr&el=tree#diff-b3NicmFpbi9hZ2VudC5weQ==) | `92.85% <ø> (-0.04%)` | :x: |
| [osbrain/nameserver.py](https://codecov.io/gh/opensistemas-hub/osbrain/compare/338b8b488bc9d1a0b6df366550535f3919b1272e...62e6bba7446239ef1f4eaa9ed86ab086eb7118bb?src=pr&el=tree#diff-b3NicmFpbi9uYW1lc2VydmVyLnB5) | `97.29% <100%> (ø)` | :white_check_mark: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/opensistemas-hub/osbrain/pull/70?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/opensistemas-hub/osbrain/pull/70?src=pr&el=footer). Last update [338b8b4...62e6bba](https://codecov.io/gh/opensistemas-hub/osbrain/compare/338b8b488bc9d1a0b6df366550535f3919b1272e...62e6bba7446239ef1f4eaa9ed86ab086eb7118bb?el=footer&src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
Flood1993: It makes definetely more sense. I rebased my branch with the changes ^^
Peque: @Flood1993 looks good now. Feel free to merge. :+1:

Consider squashing. :wink:

Patch:
diff --git a/osbrain/agent.py b/osbrain/agent.py
index 652b61d..e32e589 100644
--- a/osbrain/agent.py
+++ b/osbrain/agent.py
@@ -400,12 +400,6 @@ class Agent():
         """
         return list(self._timer.keys())
 
-    def ping(self):
-        """
-        A simple ping method (for testing purposes).
-        """
-        return 'pong'
-
     def raise_exception(self):
         """
         Raise an exception (for testing purposes).
@@ -1233,12 +1227,12 @@ class Agent():
                 continue
             self.socket[address].close()
 
-    def ready(self):
+    def ping(self):
         """
         A test method to check the readiness of the agent. Used for testing
         purposes, where timing is very important. Do not remove.
         """
-        return 'OK'
+        return 'pong'
 
 
 class AgentProcess(multiprocessing.Process):
diff --git a/osbrain/proxy.py b/osbrain/proxy.py
index 85c4506..e894d1a 100644
--- a/osbrain/proxy.py
+++ b/osbrain/proxy.py
@@ -90,7 +90,7 @@ class Proxy(Pyro4.core.Proxy):
             exception.
         """
         try:
-            self.ready()
+            self.unsafe.ping()
         except Exception:
             if time.time() - time0 < timeout:
                 return False
@@ -172,8 +172,7 @@ class Proxy(Pyro4.core.Proxy):
         """
         return (methodname in self._pyroMethods and
                 not methodname.startswith('_') and
-                methodname not in ('ready', 'run', 'get_attr', 'kill',
-                                   'safe_call'))
+                methodname not in ('run', 'get_attr', 'kill', 'safe_call'))
 
     def _remote_call(self, methodname, args, kwargs, flags, objectId):
         """


Test patch:
diff --git a/osbrain/tests/test_agent.py b/osbrain/tests/test_agent.py
index 0f4b8ff..998b832 100644
--- a/osbrain/tests/test_agent.py
+++ b/osbrain/tests/test_agent.py
@@ -50,7 +50,7 @@ def test_early_agent_proxy(nsaddr):
     # Locate agent now
     a0 = Proxy('a0', timeout=3.)
     # Just check agent is ready
-    assert a0.ready() == 'OK'
+    assert a0.unsafe.ping() == 'pong'
 
 
 def test_agent_loopback(nsaddr):
diff --git a/osbrain/tests/test_nameserver.py b/osbrain/tests/test_nameserver.py
index bcab5b7..7186288 100644
--- a/osbrain/tests/test_nameserver.py
+++ b/osbrain/tests/test_nameserver.py
@@ -22,7 +22,7 @@ from common import nsproxy  # pragma: no flakes
 
 def test_nameserver_ping(nsproxy):
     """
-    Ping name server.
+    Simple name server ping test.
     """
     assert nsproxy.ping() == 'pong'
 
diff --git a/osbrain/tests/test_proxy.py b/osbrain/tests/test_proxy.py
index 753f5ae..98422d8 100644
--- a/osbrain/tests/test_proxy.py
+++ b/osbrain/tests/test_proxy.py
@@ -111,7 +111,7 @@ def test_agent_proxy_initialization_timeout(nsproxy):
     is not ready after a number of seconds.
     """
     class InitTimeoutProxy(Proxy):
-        def ready(self):
+        def ping(self):
             time.sleep(0.1)
             raise TimeoutError()