Permalink
Browse files

Updating tests to pep8

  • Loading branch information...
1 parent b7c8f37 commit f7c00ee719d545e7e429cd1c623d3a9d55b4b21f Jonathan Moss committed Jul 30, 2012
Showing with 42 additions and 44 deletions.
  1. +1 −8 .gitignore
  2. +0 −2 pious/transform/errors.py
  3. +1 −1 setup.py
  4. +6 −6 tests/log_tests.py
  5. +14 −10 tests/matcher_tests.py
  6. +20 −17 tests/pipe_tests.py
View
@@ -1,5 +1,5 @@
*.py[co]
-
+.codeintel
# Packages
*.egg
*.egg-info
@@ -18,10 +18,3 @@ pip-log.txt
# Unit test / coverage reports
.coverage
-.tox
-
-#Translations
-*.mo
-
-#Mr Developer
-.mr.developer.cfg
@@ -1,4 +1,2 @@
-
-
class InvalidIterator(Exception):
pass
View
@@ -19,7 +19,7 @@
license='BSD',
platforms=['linux'],
packages=find_packages(exclude=["*.tests"]),
- include_package_data = True,
+ include_package_data=True,
install_requires=[],
# See http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=['Environment :: Console',
View
@@ -2,16 +2,16 @@
from pious.transform.log import ConsoleLogger
+
class ConsoleLoggerTest(TestCase):
-
+
def test_has_log_transform(self):
l = ConsoleLogger()
try:
- getattr(l, 'log_transform');
+ getattr(l, 'log_transform')
except AttributeError:
self.fail("Console logger is missing a log_transform method")
-
- i = { 'a': 'b' }
- o = { 'a': 'c'}
+
+ i = {'a': 'b'}
+ o = {'a': 'c'}
l.log_transform(i, o)
-
View
@@ -1,63 +1,67 @@
from unittest import TestCase
+
from pious.transform.matchers import KeyExists, KeyEquals, Collection
+
class KeyExistsText(TestCase):
def test_matches_if_key_present(self):
- test_data = {'a':'a'}
+ test_data = {'a': 'a'}
m = KeyExists('a').as_matcher()
self.assertTrue(m(test_data))
def test_does_not_match_if_key_not_present(self):
- test_data = {'b':'b'}
+ test_data = {'b': 'b'}
m = KeyExists('a').as_matcher()
self.assertFalse(m(test_data))
+
class KeyEqualsTest(TestCase):
def test_matches_if_key_value_correct(self):
- test_data = {'a':'a'}
+ test_data = {'a': 'a'}
m = KeyEquals('a', 'a').as_matcher()
self.assertTrue(m(test_data))
def test_does_not_match_if_key_value_incorrect(self):
- test_data = {'a':'b'}
+ test_data = {'a': 'b'}
m = KeyEquals('a', 'a').as_matcher()
self.assertFalse(m(test_data))
def test_does_not_match_if_key_does_not_exist(self):
- test_data = {'b':'a'}
+ test_data = {'b': 'a'}
m = KeyEquals('a', 'a').as_matcher()
self.assertFalse(m(test_data))
+
class CollectionTest(TestCase):
def test_matches_with_one_matcher(self):
- test_data = {'a':'a'}
+ test_data = {'a': 'a'}
collection = Collection()
collection.add_matcher(KeyExists('a').as_matcher())
m = collection.as_matcher()
self.assertTrue(m(test_data))
def test_matches_with_multiple_matchers(self):
- test_data = {'a':'a'}
+ test_data = {'a': 'a'}
collection = Collection()
collection.add_matcher(KeyExists('b').as_matcher())
collection.add_matcher(KeyExists('a').as_matcher())
m = collection.as_matcher()
self.assertTrue(m(test_data))
def test_does_not_match_when_none_added(self):
- test_data = {'a':'a'}
+ test_data = {'a': 'a'}
collection = Collection()
m = collection.as_matcher()
self.assertFalse(m(test_data))
def test_does_not_match_when_added_dont_match(self):
- test_data = {'a':'a'}
+ test_data = {'a': 'a'}
collection = Collection()
m = collection.as_matcher()
collection.add_matcher(KeyExists('b').as_matcher())
collection.add_matcher(KeyExists('c').as_matcher())
- self.assertFalse(m(test_data))
+ self.assertFalse(m(test_data))
View
@@ -1,10 +1,13 @@
from unittest import TestCase
-from pious.transform.pipes import Pipe, Ensure, Rename, RemoveKeys, AutoIncrement
+from pious.transform.pipes import Pipe, Ensure, Rename
+from pious.transform.pipes import RemoveKeys, AutoIncrement
+
+
class PipeTest(TestCase):
-
+
def test_bind_accepts_iterator(self):
- a = [1,2,3]
+ a = [1, 2, 3]
p = Pipe()
try:
p.bind(a)
@@ -15,8 +18,9 @@ def test_bind_pukes_if_not_passed_an_iterator(self):
p = Pipe()
self.assertRaises(Exception, p, {})
+
class EnsureTest(TestCase):
-
+
def test_sets_undefined_key(self):
a = [
{'a': 1, 'b': 1}
@@ -36,6 +40,7 @@ def test_does_not_overwrite_existing_key(self):
self.assertIn('a', i)
self.assertEquals(i['a'], 1)
+
class RenameTest(TestCase):
def test_renames_single_key(self):
@@ -44,7 +49,7 @@ def test_renames_single_key(self):
{'old_key': 'a_value'}
]
key_map = {
- 'old_key':'new_key'
+ 'old_key': 'new_key'
}
p = Rename(key_map)
p.bind(test_data)
@@ -65,8 +70,8 @@ def test_renames_multiple_keys(self):
},
]
key_map = {
- 'old_key1':'new_key1',
- 'old_key2':'new_key2'
+ 'old_key1': 'new_key1',
+ 'old_key2': 'new_key2'
}
p = Rename(key_map)
p.bind(test_data)
@@ -112,8 +117,8 @@ class AutoIncrementTest(TestCase):
def test_key_added(self):
test_data = [
- {'a': 'b',},
- {'a': 'b',}
+ {'a': 'b'},
+ {'a': 'b'}
]
p = AutoIncrement('counter')
p.bind(test_data)
@@ -122,8 +127,8 @@ def test_key_added(self):
def test_key_increments(self):
test_data = [
- {'a': 'b',},
- {'a': 'b',}
+ {'a': 'b'},
+ {'a': 'b'}
]
p = AutoIncrement('counter')
p.bind(test_data)
@@ -135,8 +140,8 @@ def test_key_increments(self):
def test_key_increment_interval(self):
test_data = [
- {'a': 'b',},
- {'a': 'b',}
+ {'a': 'b'},
+ {'a': 'b'}
]
p = AutoIncrement('counter', interval=2)
p.bind(test_data)
@@ -148,8 +153,8 @@ def test_key_increment_interval(self):
def test_key_increment_start(self):
test_data = [
- {'a': 'b',},
- {'a': 'b',}
+ {'a': 'b'},
+ {'a': 'b'}
]
p = AutoIncrement('counter', start_value=2)
p.bind(test_data)
@@ -158,5 +163,3 @@ def test_key_increment_start(self):
c += 1
self.assertIn('counter', i)
self.assertEquals(i['counter'], c)
-
-

0 comments on commit f7c00ee

Please sign in to comment.