Merge lp:~teknico/juju-gui/get-service-tests-in-py-env into lp:juju-gui/experimental

Proposed by Nicola Larosa
Status: Merged
Merged at revision: 492
Proposed branch: lp:~teknico/juju-gui/get-service-tests-in-py-env
Merge into: lp:juju-gui/experimental
Diff against target: 84 lines (+51/-1)
3 files modified
app/store/env/go.js (+1/-1)
app/store/env/python.js (+13/-0)
test/test_env_python.js (+37/-0)
To merge this branch: bzr merge lp:~teknico/juju-gui/get-service-tests-in-py-env
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+156805@code.launchpad.net

Description of the change

Add tests to the Py env get_service.

Add tests and a doc comment to get_service in the Python environment.

https://codereview.appspot.com/8307043/

To post a comment you must log in.
Revision history for this message
Nicola Larosa (teknico) wrote :
Download full text (4.0 KiB)

Reviewers: mp+156805_code.launchpad.net,

Message:
Please take a look.

Description:
Add tests to the Py env get_service.

Add tests and a doc comment to get_service in the Python environment.

https://code.launchpad.net/~teknico/juju-gui/get-service-tests-in-py-env/+merge/156805

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/8307043/

Affected files:
   A [revision details]
   M app/store/env/go.js
   M app/store/env/python.js
   M test/test_env_python.js

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: test/test_env_python.js
=== modified file 'test/test_env_python.js'
--- test/test_env_python.js 2013-04-02 23:30:12 +0000
+++ test/test_env_python.js 2013-04-03 11:12:24 +0000
@@ -121,6 +121,43 @@
          request_id: msg.request_id});
      });

+ it('successfully gets service configuration', function() {
+ var result, service_name;
+ var expected = {
+ 'config': {'cfg_key': 'cfg_val'},
+ 'constraints': {'cstr_key': 'cstr_val'}
+ };
+ env.get_service('mysql', function(data) {
+ service_name = data.service_name;
+ result = data.result;
+ });
+ msg = conn.last_message();
+ conn.msg({
+ request_id: msg.request_id,
+ service_name: 'mysql',
+ result: expected
+ });
+ assert.equal(service_name, 'mysql');
+ assert.deepEqual(expected, result);
+ });
+
+ it('handles failed get service', function() {
+ var service_name;
+ var err;
+ env.get_service('yoursql', function(data) {
+ service_name = data.service_name;
+ err = data.err;
+ });
+ msg = conn.last_message();
+ conn.msg({
+ request_id: msg.request_id,
+ service_name: 'yoursql',
+ err: 'service "yoursql" not found'
+ });
+ assert.equal(service_name, 'yoursql');
+ assert.equal(err, 'service "yoursql" not found');
+ });
+
      it('successfully adds a relation', function(done) {
        var endpoints, result;
        endpointA = ['mysql', {name: 'database'}];

Index: app/store/env/go.js
=== modified file 'app/store/env/go.js'
--- app/store/env/go.js 2013-04-02 23:30:12 +0000
+++ app/store/env/go.js 2013-04-03 11:12:24 +0000
@@ -640,7 +640,7 @@
       * operation is performed. It will receive an object containing:
       * err - a string describing the problem (if an error occurred),
       * service_name - the name of the service,
- * results: an object containing all of the configuration data for
+ * result: an object containing all of the configuration data for
       * the service.
       * @return {undefined} Sends a message to the server only.
       */

Index: app/store/env/python.js
=== modified file 'app/store/env/python.js'
--- app/store/env/python.js 2013-04-02 23:30:12 +0000
+++ app/store/env/python.js 2013-04-03 11:12:24 +0000
@@ -203,...

Read more...

Revision history for this message
Jeff Pihach (hatch) wrote :
Revision history for this message
Richard Harding (rharding) wrote :
491. By Nicola Larosa

Merge from trunk.

Revision history for this message
Nicola Larosa (teknico) wrote :

*** Submitted:

Add tests to the Py env get_service.

Add tests and a doc comment to get_service in the Python environment.

R=jeff.pihach, rharding
CC=
https://codereview.appspot.com/8307043

https://codereview.appspot.com/8307043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/store/env/go.js'
2--- app/store/env/go.js 2013-04-02 23:30:12 +0000
3+++ app/store/env/go.js 2013-04-03 16:48:23 +0000
4@@ -640,7 +640,7 @@
5 * operation is performed. It will receive an object containing:
6 * err - a string describing the problem (if an error occurred),
7 * service_name - the name of the service,
8- * results: an object containing all of the configuration data for
9+ * result: an object containing all of the configuration data for
10 * the service.
11 * @return {undefined} Sends a message to the server only.
12 */
13
14=== modified file 'app/store/env/python.js'
15--- app/store/env/python.js 2013-04-02 23:30:12 +0000
16+++ app/store/env/python.js 2013-04-03 16:48:23 +0000
17@@ -203,6 +203,19 @@
18 this._send_rpc({op: 'get_charm', charm_url: charmURL}, callback);
19 },
20
21+ /**
22+ Get the configuration for the given service.
23+
24+ @method get_service
25+ @param {String} service_name The service name.
26+ @param {Function} callback A callable that must be called once the
27+ operation is performed. It will receive an object containing:
28+ err - a string describing the problem (if an error occurred),
29+ service_name - the name of the service,
30+ result: an object containing all of the configuration data for
31+ the service.
32+ @return {undefined} Sends a message to the server only.
33+ */
34 get_service: function(service_name, callback) {
35 this._send_rpc(
36 {'op': 'get_service', 'service_name': service_name}, callback);
37
38=== modified file 'test/test_env_python.js'
39--- test/test_env_python.js 2013-04-02 23:30:12 +0000
40+++ test/test_env_python.js 2013-04-03 16:48:23 +0000
41@@ -121,6 +121,43 @@
42 request_id: msg.request_id});
43 });
44
45+ it('successfully gets service configuration', function() {
46+ var result, service_name;
47+ var expected = {
48+ 'config': {'cfg_key': 'cfg_val'},
49+ 'constraints': {'cstr_key': 'cstr_val'}
50+ };
51+ env.get_service('mysql', function(data) {
52+ service_name = data.service_name;
53+ result = data.result;
54+ });
55+ msg = conn.last_message();
56+ conn.msg({
57+ request_id: msg.request_id,
58+ service_name: 'mysql',
59+ result: expected
60+ });
61+ assert.equal(service_name, 'mysql');
62+ assert.deepEqual(expected, result);
63+ });
64+
65+ it('handles failed get service', function() {
66+ var service_name;
67+ var err;
68+ env.get_service('yoursql', function(data) {
69+ service_name = data.service_name;
70+ err = data.err;
71+ });
72+ msg = conn.last_message();
73+ conn.msg({
74+ request_id: msg.request_id,
75+ service_name: 'yoursql',
76+ err: 'service "yoursql" not found'
77+ });
78+ assert.equal(service_name, 'yoursql');
79+ assert.equal(err, 'service "yoursql" not found');
80+ });
81+
82 it('successfully adds a relation', function(done) {
83 var endpoints, result;
84 endpointA = ['mysql', {name: 'database'}];

Subscribers

People subscribed via source and target branches