2014.10.18 – Testing, Testing

It’s Saturday and I had no plans! It seems like that rarely happens so I took full advantage of this by sleeping in until nearly 8:00 and then doing a lot of nothing all day. I still had a test to write for my bug fix so I poked around trying to figure out how things work. I kept confusing myself by reading the same code over and over. Luckily Alena messaged and asked if she could come over with the little ones and hang out today. Yes! I hadn’t seen them in too long!

Once Alena and the kids got here we did little else but play, eat, make pesto, and watch a movie. Tiberias is three and full of Why’s. His sister Rialla is almost two and looks up to her big brother so naturally she is also full of Why’s. I’m not sure she knows why though 🙂 Baby Anya is getting so big! She’s moving all around and seems happy that she can get places by herself. I had a huge bag of basil that needed to be turned into pesto so Tiberias, Rialla and I got busy in the kitchen stripping off the leaves. They were so interested in helping and it really did make things go faster. We moved to the food processor and they both remained my side kicks even though they were sure it was going to be LOUD. Luckily it’s not loud at all and this made them pretty happy. We added our ingredients and would taste and adjust. Tiberias said, “It needs more salt.” So we added a bit more then tasted again. He still thought it needed more salt but it tasted good to me! They both loved the pesto and probably would have eaten a large portion of it had I let them.

It was getting late in the day and they needed to get home for dinner. We were going to have dinner with Alice and Jason and then watch a movie in their basement theater. I walked everyone out to the truck but first we found a few nice strawberries they could eat. Off they went until next time!

Once I was back inside I headed right back to this test I needed to write. I finally asked Andrew if he would help me out since I was kind of struggling. He sat with me and started asking me questions about what I had to do, what I had figured out and what I had tried. He then explained where I was going wrong and explained how the test should work. He gave me the general steps I would need to take and sat with me as I tried to complete each one. He would help me when I would ask. Watching the test come together was like magic. He’s done it so many times that this all makes sense to him but it’s all very new to me so I learned a LOT today. I got the test written and passing and then wrote an additional test since it was very simple to copy my test, make some changes and reuse it.

I was testing a change I made to the Air Mozilla iCal feed. The staff was wanting the iCal feed to show a start time 30 minutes prior to the scheduled event time so that staff has time for AV setup. I made the code change to adjust the iCal feed but Peter, the mentor, wanted a test to prove that all is well. The way I ended up writing the test, with a lot of help from Andrew, was as follows:

def test_calendar_dtstart(self):
# Get the test event created during setup
    event = Event.objects.get(title='Test event')
# Set var = the event time adjusted 30min earlier
# Print the data to see how dtstart is formatted
# then delete print statement.
    dtstart = event.start_time - datetime.timedelta(minutes=30)
# Format var the same as the data in iCal feed
    dtstart = dtstart.strftime("DTSTART:%Y%m%dT%H%M%SZ")
# Set the url to the public feed
    url = self._calendar_url('public')
# Retrieve the public feed
    response_public = self.client.get(url)
# Compare var is equal to start time in public feed
    ok_(dtstart in response_public.content)
# Set url to the private feed
    url = self._calendar_url('company')
# Retrieve the private feed
    response_private = self.client.get(url)
# Compare var is equal to start time in private feed
    ok_(dtstart in response_private.content)

My code comments are just for explanation here and aren’t part of the test I submitted. We’ll see if the mentor is happy with the way this was done but if not, I at least kind of know what I am doing now.

Alice had finished dinner about the time I was done. It was delicious! We had pasta with my pesto sauce (it needed more salt!) salad, rosemary potato bread and veggies from the garden in some sort of yummy tomato based sauce. It was really good but I tried not to eat a ton since we were going to be having popcorn with our movie soon.

Andrew made a bunch of popcorn and we headed over to their house. Jason had just finished the platform for stadium seating. The three of us took the couch in the back and got all settled in to watch the new Transformers movie. They have such a sweet setup. It was perfect. I don’t want to watch a movie anywhere else! The movie itself was pretty bad though. It was really long too. Long enough that I had time to sleep in the middle and not really miss anything.

Today I learned how to write a unit test from scratch.