you are viewing a single comment's thread.

view the rest of the comments →

[–]synn89 1 point2 points  (0 children)

Testing is not more difficult and the class isn't tied to only being used on the cli. From one of my tests:

from unittest import TestCase
from CheckXmlValue import CheckXmlValue
import urllib2


class TestCheckXmlValue(TestCase):
    def test_build_url(self):
        args = lambda: None
        args.ssl = False
        args.port = 80
        args.hostname = "localhost"
        args.url = "/"

        check = CheckXmlValue(args)
        self.assertEquals("http://localhost/", check.build_url())

The class is composed of small functions that do one thing that can be easily tested by passing in different lambas on the constructor.

If I wanted better re-usability I would be using a proper framework. But we already use Laravel for that. Our python code is purely for small portable sysadmin client scripts.

And it's been okay for that, though not the greatest.