<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 06/22/2015 10:13 PM, Sajeesh Cimson
      Sasi wrote:<br>
    </div>
    <blockquote
      cite="mid:08B59792F3F22F449DE8F6390F7587EF3F51B98E@CERNXCHG72.cern.ch"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <div style="direction: ltr;font-family: Tahoma;color:
        #000000;font-size: 10pt;"><br>
        <br>
        <div style="font-family: Times New Roman; color: #000000;
          font-size: 16px">
          <hr tabindex="-1">
          <div style="direction: ltr;" id="divRpF832402"><font
              color="#000000" face="Tahoma" size="2"><b>From:</b> Adam
              Young [<a class="moz-txt-link-abbreviated" href="mailto:ayoung@redhat.com">ayoung@redhat.com</a>]<br>
              <b>Sent:</b> 23 June 2015 00:01:48<br>
              <b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:openstack-dev@lists.openstack.org">openstack-dev@lists.openstack.org</a><br>
              <b>Subject:</b> Re: [openstack-dev] [nova][keystone] Nova
              calls to Keystone<br>
            </font><br>
          </div>
          <div>
            <div class="moz-cite-prefix">On 06/20/2015 02:46 PM, Sajeesh
              Cimson Sasi wrote:<br>
            </div>
            <blockquote type="cite">
              <style id="owaParaStyle" type="text/css">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
BODY {direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;}P {margin-top:0;margin-bottom:0;}BODY {scrollbar-base-color:undefined;scrollbar-highlight-color:undefined;scrollbar-darkshadow-color:undefined;scrollbar-track-color:undefined;scrollbar-arrow-color:undefined}BODY {scrollbar-base-color:undefined;scrollbar-highlight-color:undefined;scrollbar-darkshadow-color:undefined;scrollbar-track-color:undefined;scrollbar-arrow-color:undefined}BODY {scrollbar-base-color:undefined;scrollbar-highlight-color:undefined;scrollbar-darkshadow-color:undefined;scrollbar-track-color:undefined;scrollbar-arrow-color:undefined}</style>
              <div style="direction:ltr; font-family:Tahoma;
                color:#000000; font-size:10pt"><font size="2"><span
                    style="font-size:10pt">Hi All,<br>
                       I need your advice for the implementation of the
                    following blueprint. <a moz-do-not-send="true"
                      href="https://review.openstack.org/#/c/160605"
                      target="_blank">
                      https://review.openstack.org/#/c/160605</a> .<br>
                       All the use cases mentioned in the blueprint
                    have  been implemented and the complete code is up
                    for review.<br>
                      <a moz-do-not-send="true"
                      href="https://review.openstack.org/#/c/149828/"
                      target="_blank">https://review.openstack.org/#/c/149828/</a><br>
                      However, we have an issue on which we need your
                    input. In the nova quota api call, keystone calls
                    are made to<br>
                      get the parent_id and the child project or sub
                    project list. This is required because nova doesn't
                    store any information
                    <br>
                      regarding the hierarchy. Hierarchy Information is 
                    taken during run time,  from keystone. Since the
                    keystone calls are
                    <br>
                      made inside the api call, it is not possible to
                    give any dummy or  fake values while writing the
                    unit tests. If the keystone<br>
                      call was made outside the api call, we could have
                    given fake values in the test cases. However,  the
                    keystone calls for
                    <br>
                       parent_id and child projects are made inside the
                    api call.<br>
                      Can anyone suggest an elegant solution to this
                    problem? What is the proper way to implement this ?
                    <br>
                        Did anybody encounter and solve a  similar 
                    problem ? Many thanks for any suggestions!<br>
                             best regards<br>
                               sajeesh</span></font></div>
              <br>
              <fieldset class="mimeAttachmentHeader" target="_blank"></fieldset>
              <br>
              <pre>__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: <a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a>
</pre>
            </blockquote>
            If you are talking to a live Keystone server, make sure you
            are using valid data.<br>
            <br>
            If you are not talking to a live keystone server in a unit
            test, use RequestsMock or equivalent (varied by project)  to
            handle the HTTP request and response.<br>
            <br>
            A worst case approach is to monkey patch the
            Keystoneclient.  Please don't do that if you can avoid it; 
            better to provide a mock alternative.<br>
            <br>
            <br>
            Hi Adam,<br>
                           Thanks a lot. I am not planning to talk to
            the live keystone server in the unit test.<br>
                           I don't think that I need to monkey patch the
            KeystoneClient. In the nova api code, there are two methods
            (get_parent_project and get_immediate_child_list),which uses
            keystoneclient.I can monkey patch those two methods to
            return fixed data according to a fake hierarchy. Am I right
            ?<br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Its not great, but not horrible.  It seems to match the scope of
    what you are testing.  However, you might want to consider doing a
    mock for the whole Keystoneclient call, as that really should beo
    utside of the unit test for the Nova code.<br>
    <br>
    <br>
    <blockquote
      cite="mid:08B59792F3F22F449DE8F6390F7587EF3F51B98E@CERNXCHG72.cern.ch"
      type="cite">
      <div style="direction: ltr;font-family: Tahoma;color:
        #000000;font-size: 10pt;">
        <div style="font-family: Times New Roman; color: #000000;
          font-size: 16px">
          <div>
                          best regards<br>
                           sajeesh<br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: <a class="moz-txt-link-abbreviated" href="mailto:OpenStack-dev-request@lists.openstack.org?subject:unsubscribe">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</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>