<div dir="ltr">Hi, I'm learning how to use autopilot and wanted to interrogate a value.<div><br></div><div style>This involves the calendar app. Here is the output, followed by what I tried. Where did I go wrong?</div>
<div style><br></div><div style><div> File "/home/cecil/Workspace/ubuntu-calendar-app/tests/autopilot/calendar_app/tests/test_calendar_current_day_of_month.py", line 30, in test_day_of_month</div><div> print intern.today</div>
<div>AttributeError: 'NoneType' object has no attribute 'today'</div><div><br></div><div style>In the emulator dir, I added this to main_window.py:</div><div style>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>def<span style="color:rgb(192,192,192)"> </span>get_intern(self):</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>return<span style="color:rgb(192,192,192)"> </span>self.app.select_single("intern")</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">In the tests dir, I created this new test:</pre><pre style="margin-top:0px;margin-bottom:0px">... elided ...</pre><pre style="margin-top:0px;margin-bottom:0px">
<pre style="margin-top:0px;margin-bottom:0px">class<span style="color:rgb(192,192,192)"> </span>TestDayOfMonth(CalendarTestCase):</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>def<span style="color:rgb(192,192,192)"> </span>setUp(self):</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>super(TestDayOfMonth,<span style="color:rgb(192,192,192)"> </span>self).setUp()</pre><pre style="margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>self.assertThat(</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>self.main_window.get_qml_view().visible,<span style="color:rgb(192,192,192)"> </span>Eventually(Equals(True)))</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial;color:rgb(192,192,192)"> </span><span style="font-family:arial">def</span><span style="font-family:arial;color:rgb(192,192,192)"> </span><span style="font-family:arial">tearDown(self):</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>super(TestDayOfMonth,<span style="color:rgb(192,192,192)"> </span>self).tearDown()</pre><pre style="margin-top:0px;margin-bottom:0px">
<br></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>def<span style="color:rgb(192,192,192)"> </span>test_day_of_month(self):</pre><pre style="margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>intern<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>self.main_window.get_intern()</pre><pre style="margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>print<span style="color:rgb(192,192,192)"> </span>intern.today</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">What I'm trying to see is in MonthView.qml starting around line 89:</pre><pre style="margin-top:0px;margin-bottom:0px">
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QtObject</span><span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">id</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">intern</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">property</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">squareUnit</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">monthView</span>.width<span style="color:rgb(192,192,192)"> </span>/<span style="color:rgb(192,192,192)"> </span>8</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">property</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">verticalMargin</span>:<span style="color:rgb(192,192,192)"> </span><a href="http://units.gu">units.gu</a>(1)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">property</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">weekstartDay</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,85,175)">Qt</span>.locale().firstDayOfWeek</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">property</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">monthCount</span>:<span style="color:rgb(192,192,192)"> </span>49<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">months</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">for</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">+-2</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">years</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">property</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">var</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">today</span>:<span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,128,0)">new</span><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,85,175)">Date</span>()).midnight()<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">TODO:</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">update</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">at</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">midnight</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">property</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">var</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">currentDayStart</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">today</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">property</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">monthIndex0</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,85,175)">Math</span>.floor(<span style="font-style:italic;color:rgb(0,0,0)">monthCount</span><span style="color:rgb(192,192,192)"> </span>/<span style="color:rgb(192,192,192)"> </span>2)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">property</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">var</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">monthStart0</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">today</span>.monthStart()</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre></pre></pre></div></div></div>