DevNet Associate In 30 Day Challenge Week 2

I can’t believe it’s the end of week 2 already, I’ve managed to fit in a lot of study time this week during the evenings and weekend, though I’m starting to feel burnout coming on a bit now so I’ll slow down a little bit this week.

At the end of last week I stated that I would spend time on these following topics;

  • Meraki
  • Cisco DNA Center
  • ACI
  • Cisco SD-WAN and NSO

So far I’ve managed to get through Meraki, DNA Center and ACI API’s, I will concentrate on SD-WAN and NSO this week, but the above isn’t the only things I’ve been studying.

I decided to purchase Boson ExSim-Max for the DevNet associate, I used Boson Netsim back in 2019 when I was going for my CCNP certification and it helped me pass then.

So what is Boson ExSim you may ask? It’s an exam simulator that get’s as close as possible to the real thing, click the image below and it will take you to the website where you can find more details on the product.

The DevNet associate practice exam comes with a total of 306 questions, I decided to take a test which has 102 questions which is pretty similar to the real exam if not the same. I scored a total of 69% which was a fail.

I failed but this was the reason I got the practice test so that I could see where I was already at and what I needed to study in further detail.

I took the above test on Friday evening so I spent Saturday and Sunday going over the topics above that I was struggling with.

I’m going to complete another test later this week to see if the study over weekend has helped, the best thing with Ex-Sim is that it randomises the questions.

Every week I’m trying to show one key piece of information that I’ve learnt and this week it’s making sure that you are testing code correctly.

How to use unittest for Network Engineers

When I first started out writing Python, I didn’t know about Unit Testing, I thought just running your script was enough testing, but that’s not the case as your codebase get’s bigger, you end up with tons of different functions.

So how do we test properly? We use a testing framework e.g. unittest, pytest these are to name a few there are others out there.

The DevNet associate exam specifically covers unittest so lets go ahead and get started with an example.

import unittest
from netmiko import ConnectHandler

def get_device_hostname():
    net_connect = ConnectHandler(

    hostname = net_connect.send_command("show run | sec hostname").strip("hostname ")

    return hostname

class TestNetworkHostname(unittest.TestCase):

    def test_device_hostname(self):

        output = get_device_hostname()

        self.assertIn("SW1", output)

if __name__ == "__main__":

In the above code we import unittest and for this example we will use Netmiko as it’s easy to get going and gives us some real data to work with.

I’ve created a function called get_device_hostname, I want to simply get the hostname of the device and then return this at the end of the function.

I have then created a class called TestNetworkHostname and then we will inherit unittest.TestCase, now inside the class I’ve created a new method called test_device_hostname, inside this method I will create a new variable called output which will call on the get_device_hostname function.

We now use the self.assertIn method which will check to see if the string SW1 is contained within output, in this case it does so the test will pass.

The last thing we do is use if __name__ == "__main__" as we are running the code directly.

venv) robinsonm@Marks-Laptop:~/Network Automation/Marks-DevNet-Associate-Training$ python3 
Ran 1 test in 1.052s

(venv) robinsonm@Marks-Laptop:~/Network Automation/Marks-DevNet-Associate-Training$ 

There are multiple different Assert methods available e.g. you can pass in lists, dictionary’s to name a few.

Testing should be a part of your Network Automation journey, if you are following Test Driven Development you should be writing your test cases before you even write the code.

Anyway that’s me done for week two, see you in for the week three update 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *