<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/10/2013 06:56 AM, Akshat Kakkar
wrote:<br>
</div>
<blockquote
cite="mid:1373453762.70307.YahooMailNeo@web193305.mail.sg3.yahoo.com"
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
cite="mid:1373453762.70307.YahooMailNeo@web193305.mail.sg3.yahoo.com"
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
cite="mid:1373453762.70307.YahooMailNeo@web193305.mail.sg3.yahoo.com"
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
cite="mid:1373453762.70307.YahooMailNeo@web193305.mail.sg3.yahoo.com"
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 class="moz-txt-link-rfc2396E" href="mailto:dolph.mathews@gmail.com"><dolph.mathews@gmail.com></a><br>
<b><span style="font-weight: bold;">To:</span></b>
Akshat Kakkar <a class="moz-txt-link-rfc2396E" href="mailto:the_akshat@yahoo.co.in"><the_akshat@yahoo.co.in></a>; OpenStack
Development Mailing List
<a class="moz-txt-link-rfc2396E" href="mailto:openstack-dev@lists.openstack.org"><openstack-dev@lists.openstack.org></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="y_msg_container"><br>
<div id="yiv7580928963">
<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="yiv7580928963gmail_extra"><br>
<br>
<div class="yiv7580928963gmail_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="yiv7580928963gmail_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="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
OpenStack-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a>
<a class="moz-txt-link-freetext" 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>
</body>
</html>