Skip to content

Commit

Permalink
bug 1405675 - update crashstats/api/tests/* to pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
willkg committed Oct 17, 2017
1 parent eb41846 commit ceef110
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 145 deletions.
27 changes: 13 additions & 14 deletions webapp-django/crashstats/api/tests/test_cleaner.py
@@ -1,5 +1,4 @@
import mock
from nose.tools import eq_, ok_

from crashstats.base.tests.testbase import TestCase
from crashstats.api.cleaner import Cleaner, SmartWhitelistMatcher
Expand Down Expand Up @@ -30,7 +29,7 @@ def test_simplest_case(self):
'bar': 5},
]
}
eq_(data, expect)
assert data == expect

@mock.patch('warnings.warn')
def test_simplest_case_with_warning(self, p_warn):
Expand Down Expand Up @@ -75,7 +74,7 @@ def test_all_dict_data(self):
'bar': 8,
},
}
eq_(data, expect)
assert data == expect

def test_simple_list(self):
whitelist = ('foo', 'bar')
Expand Down Expand Up @@ -103,7 +102,7 @@ def test_simple_list(self):
'bar': 8,
},
]
eq_(data, expect)
assert data == expect

def test_plain_dict(self):
whitelist = ('foo', 'bar')
Expand All @@ -118,7 +117,7 @@ def test_plain_dict(self):
'foo': 1,
'bar': 2,
}
eq_(data, expect)
assert data == expect

def test_dict_data_with_lists(self):
whitelist = {
Expand Down Expand Up @@ -152,7 +151,7 @@ def test_dict_data_with_lists(self):
]
}
}
eq_(data, expect)
assert data == expect

def test_all_dict_data_deeper(self):
whitelist = {Cleaner.ANY: {Cleaner.ANY: ('foo', 'bar')}}
Expand Down Expand Up @@ -206,7 +205,7 @@ def test_all_dict_data_deeper(self):
}
},
}
eq_(data, expect)
assert data == expect

def test_with_scrubber_cleaning(self):
whitelist = {'hits': ('foo', 'bar', 'baz')}
Expand Down Expand Up @@ -240,17 +239,17 @@ def test_with_scrubber_cleaning(self):
'baz': "talk to bill@gates.com"},
]
}
eq_(data, expect)
assert data == expect


class TestSmartWhitelistMatcher(TestCase):

def test_basic_in(self):
whitelist = ['some', 'thing*']
matcher = SmartWhitelistMatcher(whitelist)
ok_('some' in matcher)
ok_('something' not in matcher)
ok_('awesome' not in matcher)
ok_('thing' in matcher)
ok_('things' in matcher)
ok_('nothing' not in matcher)
assert 'some' in matcher
assert 'something' not in matcher
assert 'awesome' not in matcher
assert 'thing' in matcher
assert 'things' in matcher
assert 'nothing' not in matcher
10 changes: 4 additions & 6 deletions webapp-django/crashstats/api/tests/test_jinja_helpers.py
@@ -1,15 +1,13 @@
from nose.tools import eq_

from crashstats.base.tests.testbase import TestCase
from crashstats.api.templatetags.jinja_helpers import pluralize


class TestPluralize(TestCase):

def test_basics(self):
eq_(pluralize(0), 's')
eq_(pluralize(1), '')
eq_(pluralize(59), 's')
assert pluralize(0) == 's'
assert pluralize(1) == ''
assert pluralize(59) == 's'

def test_overide_s(self):
eq_(pluralize(59, 'ies'), 'ies')
assert pluralize(59, 'ies') == 'ies'

0 comments on commit ceef110

Please sign in to comment.