<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 07/11/2013 05:23 AM, Akshat Kakkar
wrote:<br>
</div>
<blockquote
cite="mid:1373534580.86817.YahooMailNeo@web193301.mail.sg3.yahoo.com"
type="cite">
<div style="color:#000; background-color:#fff; font-family:arial,
helvetica, sans-serif;font-size:12pt">
<div><br>
<span>The methods of read/write/update/delete of records in
the tables are written using SQLalchemy only and no direct
sql is used.</span></div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family:
arial,helvetica,sans-serif; background-color: transparent;
font-style: normal;"><br>
<span></span></div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family:
arial,helvetica,sans-serif; background-color: transparent;
font-style: normal;"><span>I have implemented the things on
the lines of trusts only. Similar to trusts, I am also
having RESTful APIs and unit tests for them are succesfully
written. </span><span><span>In test_backend_sql.py, it is
seen that no unit tests are defined for trusts. </span>So,
it's confusing for me to implement the unit test for my
backend sql code.</span></div>
</div>
</blockquote>
<br>
Yeah, trusts themselves are pretty simple as far as REST, and they
are exercised via the Token backend code as well as test_auth.py and
test_v3_auth.py.<br>
<br>
Look at the tests for identity and catalog, those should be a better
example to follow.<br>
<br>
<br>
<blockquote
cite="mid:1373534580.86817.YahooMailNeo@web193301.mail.sg3.yahoo.com"
type="cite">
<div style="color:#000; background-color:#fff; font-family:arial,
helvetica, sans-serif;font-size:12pt">
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family:
arial,helvetica,sans-serif; background-color: transparent;
font-style: normal;"><br>
<span></span></div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family:
arial,helvetica,sans-serif; background-color: transparent;
font-style: normal;"><span>I know I am confusing the things
and I apologise for that, but I am asking because of that
confusion only!<br>
</span></div>
<div><br>
</div>
<div style="font-family: arial, helvetica, sans-serif;
font-size: 12pt;">
<div style="font-family: times new roman, new york, times,
serif; font-size: 12pt;">
<div dir="ltr">
<hr size="1"> <font face="Arial" size="2"> <b><span
style="font-weight:bold;">From:</span></b> Adam
Young <a class="moz-txt-link-rfc2396E" href="mailto:ayoung@redhat.com"><ayoung@redhat.com></a><br>
<b><span style="font-weight: bold;">To:</span></b>
<a class="moz-txt-link-abbreviated" href="mailto:openstack-dev@lists.openstack.org">openstack-dev@lists.openstack.org</a> <br>
<b><span style="font-weight: bold;">Sent:</span></b>
Thursday, 11 July 2013 4:28 AM<br>
<b><span style="font-weight: bold;">Subject:</span></b>
Re: [openstack-dev] [Keystone] How to write unit tests
for db methods?<br>
</font> </div>
<div class="y_msg_container"><br>
<div id="yiv2318796423">
<div>
<div class="yiv2318796423moz-cite-prefix">On
07/10/2013 06:56 AM, Akshat Kakkar wrote:<br>
</div>
<blockquote type="cite">
<div
style="color:#000;background-color:#fff;font-family:arial,
helvetica, sans-serif;font-size:12pt;">I have
added 2 tables to keystone.</div>
</blockquote>
<br>
This should be done in a migration, and should be
tested using the test_db_update.py file.<br>
<br>
<blockquote type="cite">
<div
style="color:#000;background-color:#fff;font-family:arial,
helvetica, sans-serif;font-size:12pt;"> I have
methods which do the read/write/update/delete of
records in these tables. </div>
</blockquote>
PLease explain. We are not doing direct sql, but
rather using SQLalchemy.<br>
<br>
<br>
<blockquote type="cite">
<div
style="color:#000;background-color:#fff;font-family:arial,
helvetica, sans-serif;font-size:12pt;">I want to
write unit test for all this. These methods of
mine inherit from keystone.common.sql and hence
any call that these methods will make will go to
the db returned by keystone.common.sql when
creating a session. For writing a unit test this
db should be a test db and not the production db.
So, how can I have a session of test db? or is
there altogether a different way of writing the
unit test.<br>
</div>
</blockquote>
See test_backend_sql.py<br>
<blockquote type="cite">
<div
style="color:#000;background-color:#fff;font-family:arial,
helvetica, sans-serif;font-size:12pt;"><br>
<div><br>
</div>
<div style="font-family:arial, helvetica,
sans-serif;font-size:12pt;">
<div style="font-family:times new roman, new
york, times, serif;font-size:12pt;">
<div dir="ltr">
<hr size="1"> <font face="Arial" size="2">
<b><span style="font-weight:bold;">From:</span></b>
Dolph Mathews <a moz-do-not-send="true"
rel="nofollow"
class="yiv2318796423moz-txt-link-rfc2396E"
ymailto="mailto:dolph.mathews@gmail.com"
target="_blank"
href="mailto:dolph.mathews@gmail.com"><dolph.mathews@gmail.com></a><br>
<b><span style="font-weight:bold;">To:</span></b>
Akshat Kakkar <a moz-do-not-send="true"
rel="nofollow"
class="yiv2318796423moz-txt-link-rfc2396E"
ymailto="mailto:the_akshat@yahoo.co.in"
target="_blank"
href="mailto:the_akshat@yahoo.co.in"><the_akshat@yahoo.co.in></a>;
OpenStack Development Mailing List <a
moz-do-not-send="true" rel="nofollow"
class="yiv2318796423moz-txt-link-rfc2396E"
ymailto="mailto:openstack-dev@lists.openstack.org" target="_blank"
href="mailto:openstack-dev@lists.openstack.org"><openstack-dev@lists.openstack.org></a></font><font
face="Arial" size="2"><a
moz-do-not-send="true" rel="nofollow"
class="yiv2318796423moz-txt-link-rfc2396E"
ymailto="mailto:openstack-dev@lists.openstack.org" target="_blank"
href="mailto:openstack-dev@lists.openstack.org">see
</a> <br>
<b><span style="font-weight:bold;">Sent:</span></b>
Tuesday, 9 July 2013 7:39 PM<br>
<b><span style="font-weight:bold;">Subject:</span></b>
Re: [openstack-dev] [Keystone] How to
write unit tests for db methods?<br>
</font> </div>
<div class="yiv2318796423y_msg_container"><br>
<div id="yiv2318796423">
<div dir="ltr">I'm assuming you're
referring to testing backend drivers as
opposed to database migrations
(tests/test_sql_upgrade.py).
<div><br>
</div>
<div style="">Backend agnostic tests
land in tests/test_backend.py.
Backend-specific tests, overrides, etc
belong in tests/test_backend_sql.py,
tests/test_backend_kvs.py, etc.</div>
<div style=""><br>
</div>
<div style="">Generally, you can't
assume that keystone is backed by a
database, however, as it's entirely
possible to deploy without one.</div>
</div>
<div class="yiv2318796423gmail_extra"><br>
<br>
<div class="yiv2318796423gmail_quote">
On Tue, Jul 9, 2013 at 10:55 AM,
Akshat Kakkar <span dir="ltr"><<a
moz-do-not-send="true"
rel="nofollow"
ymailto="mailto:the_akshat@yahoo.co.in"
target="_blank"
href="mailto:the_akshat@yahoo.co.in">the_akshat@yahoo.co.in</a>></span>
wrote:<br>
<blockquote
class="yiv2318796423gmail_quote"
style="margin:0 0 0
.8ex;border-left:1px #ccc
solid;padding-left:1ex;">
<div>
<div
style="font-size:12pt;font-family:arial,
helvetica, sans-serif;">
<div>How to write unit tests in
keystone for the methods which
are directly calling the
backend db? I understand that
for testing purpose it should
be a *fake db*, but how to do
that in keystone?<br>
</div>
</div>
</div>
<br>
_______________________________________________<br>
OpenStack-dev mailing list<br>
<a moz-do-not-send="true"
rel="nofollow"
ymailto="mailto:OpenStack-dev@lists.openstack.org"
target="_blank"
href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a moz-do-not-send="true"
rel="nofollow" target="_blank"
href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div><br>
</div>
-Dolph </div>
</div>
<br>
<br>
</div>
</div>
</div>
</div>
<br>
<fieldset class="yiv2318796423mimeAttachmentHeader"></fieldset>
<br>
<pre>_______________________________________________
OpenStack-dev mailing list
<a moz-do-not-send="true" rel="nofollow" class="yiv2318796423moz-txt-link-abbreviated" ymailto="mailto:OpenStack-dev@lists.openstack.org" target="_blank" href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a>
<a moz-do-not-send="true" rel="nofollow" class="yiv2318796423moz-txt-link-freetext" target="_blank" href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a>
</pre>
</blockquote>
<br>
</div>
</div>
<br>
_______________________________________________<br>
OpenStack-dev mailing list<br>
<a moz-do-not-send="true"
ymailto="mailto:OpenStack-dev@lists.openstack.org"
href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a moz-do-not-send="true"
href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev"
target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br>
<br>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>