## Importing utilities
from unittests import TestCase #or, in Django:
from django.test import TestCase #(see https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.TestCase)
from unittests impor skip
from mock import (Mock, patch, mock_open, )
from nose.tools import (istest, nottest, assert_equal, raises)
## Writting tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package { 'dnsmasq': | |
| ensure => present, | |
| } | |
| $dnsmasq_conf = "no-resolv | |
| server=8.8.4.4 | |
| server=8.8.8.8 | |
| interface=eth0 | |
| no-dhcp-interface=eth0 | |
| no-hosts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def watch(var1): | |
| """ | |
| Helper to watch the value of VARIABLES (not expressions) | |
| in the scope of calling function: | |
| >>> k = 3 | |
| >>> watch('k') | |
| "k" := int, "3" | |
| Won't work with expressions like: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| def rows_from_a_csv_file(filename, skip_first_line=False, dialect='excel', **fmtparams): | |
| with open(filename, 'r') as csv_file: | |
| reader = csv.reader(csv_file, dialect, **fmtparams) | |
| if skip_first_line: | |
| next(reader, None) | |
| for row in reader: | |
| yield row |
.head on|off Turn on the header (column names) for table listings.
.schema Shows DB schema: all CREATE TABLE statements, etc.
from django.shortcuts import (render, redirect, )
from django.contrib.auth import logout as auth_logout
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.contrib.auth.models import User
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import (TemplateView, View, )
from django.core.exceptions import (ObjectDoesNotExist, MultipleObjectsReturned)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #coding: utf-8 | |
| from os import system | |
| from os.path import join | |
| from tempfile import mkdtemp | |
| # TODO | |
| # Convert into a proper commandline tool and pypi package | |
| # Dump a JSON with the config instead of running it, so I can run the same operation on several servers | |
| # Flag to install the files or not, or to install to other location |