Hi Ruben, Did a little debugging for you...
1) Run your unit tests $ tox -epy34 congress.tests.datasources.test_magnum ... File "/Users/tim/opencode/congress/congress/tests/datasources/test_magnum_driver.py", line 3, in <module> from congress.datasources import magnum_driver File "/Users/tim/opencode/congress/congress/datasources/magnum_driver.py", line 51 self.magnum = magnum_client.Client(session=session) ^ IndentationError: unexpected indent The IndenetationError says you haven't lined up the code correctly. Python is sensitive to whitespace. I fixed this. 2) Run unit tests again. $ tox -epy34 congress.tests.datasources.test_magnum .. File "/Users/tim/opencode/congress/congress/datasources/magnum_driver.py", line 1, in <module> from magnumclient import client as magnum_client Here the problem is that the package magnumclient doesn't exist. You need to add the python-magnumclient to the file requirements.txt. I fixed this for you as well. 3) Run unit tests again $ tox -epy34 congress.tests.datasources.test_magnum Forgot to capture the output this time, but there was a test failure. I went ahead and uncommented the two translators that you wrote because they seemed to be doing the right thing; that required combining your two unit tests into 1. 4) Run unit tests again $ tox -epy34 congress.tests.datasources.test_magnum Traceback (most recent call last): File "/Users/tim/opencode/congress/congress/tests/datasources/test_magnum_driver.py", line 97, in test_cluster_template_update_from_datasource self.assertEqual(self.driver.state, expected) File "/Users/tim/opencode/congress/.tox/py34/lib/python3.4/site-packages/testtools/testcase.py", line 411, in assertEqual self.assertThat(observed, matcher, message) File "/Users/tim/opencode/congress/.tox/py34/lib/python3.4/site-packages/testtools/testcase.py", line 498, in assertThat raise mismatch_error testtools.matchers._impl.MismatchError: !=: reference = {'cluster': {('None', 'k8s-cluster', 'None', 1, 1, 'CREATE_FAILED')}, 'cluster_template': {('None', 'k8s-cluster-template', 'None', 'None')}} reference = {'cluster': {('f88cb9c7-1e5d-42cb-b0dc-d9c3d0872ddf', 'k8s-cluster', 'testkey', 1, 1, 'CREATE_FAILED')}, 'cluster_template': {('3ddeaf4f-af3d-4534-9558-59bf28b1578b', 'k8s-cluster-template', 'kubernetes', 'flannel')}} actual = {'cluster': {('None', 'k8s-cluster', 'None', 1, 1, 'CREATE_FAILED')}, 'cluster_template': {('None', 'k8s-cluster-template', 'None', 'None')}} What's happening here is that the output of the translator does not match what the test says the output should be. The problem is that there's a mismatch between the keys in the data that you've mocked out (e.g. mock_cluster_template) and the fieldnames in the translator (e.g. cluster_template_translator). In the translator below you say the field names are 'id', 'name', 'COE', and 'Network_driver'. In the data you mocked out, the closest field names I can see are 'uuid', 'name', 'coe', and 'network_driver'. So fieldname 'name' matches the mocked out data, but the other field names do not. (Field names are case sensitive.) So if you change it so the fieldnames and the mock-data match, your unit test should pass. cluster_template_translator = { 'translation-type': 'HDICT', 'table-name': CLUSTER_TEMPLATE, 'selector-type': 'DICT_SELECTOR', 'field-translators': ({'fieldname': 'id', 'translator': value_trans}, {'fieldname': 'name', 'translator': value_trans}, {'fieldname': 'COE', 'translator': value_trans}, {'fieldname': 'Network_driver', 'translator': value_trans})} 5) Of course, just because the unit tests pass doesn't mean the driver is correct. The translator fieldnames need to match the actual data that magnum returns when you ask for the clusters and cluster_templates. One option is to read through the python-magnumclient code to see what fields it returns; the other is to run the commands yourself from the commandline to see what they return; another is to look at the Congress logs when the magnum driver is running (with debug=True in /etc/congress/congress.conf). 6) I pushed all my changes as a revision on top of one of your commits. We always include the code and the unit tests as one commit. So now there's 1 commit that you can download to your local machine and continue editing. Or you can just look at the code in gerrit and make changes to your code manually. https://review.openstack.org/#/c/397150/ To download, the safest thing is to create a new branch and apply the changes on top of that branch. You can also skip the 'git checkout' step if you want to apply the changes on top of the ones you already have, resolve conflicts, and then squash all the commits together. $ cd /path/to/congress $ git checkout origin/master -b <pick-a-new-name> $ git fetch https://git.openstack.org/openstack/congress refs/changes/50/397150/4 && git cherry-pick FETCH_HEAD Hope that helps, Tim On Mon, Nov 14, 2016 at 10:02 AM Adrian Otto <adrian.o...@rackspace.com> wrote: > Ruben, > > I found the following two reviews: > > https://review.openstack.org/397150 Magnum_driver for congress > https://review.openstack.org/397151 Test for magnum_driver > > Are these what you are referring to, or is it something else? > > Thanks, > > Adrian > > > > On Nov 14, 2016, at 4:13 AM, Ruben <r.manganiel...@studenti.unisa.it> > wrote: > > > > Hi everybody, > > I've added the magnum_driver code, that I'm trying to write for > congress, to review. > > I think that I've made some errors. > > > > I hope in your help. > > Ruben > > > > > __________________________________________________________________________ > > OpenStack Development Mailing List (not for usage questions) > > Unsubscribe: > openstack-dev-requ...@lists.openstack.org?subject:unsubscribe > > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev > > > __________________________________________________________________________ > OpenStack Development Mailing List (not for usage questions) > Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev >
__________________________________________________________________________ OpenStack Development Mailing List (not for usage questions) Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev