コード例 #1
0
 def test_notifier_with_message(self):
     self.mock_listener.expects(never()).first_key_heared()
     self.mock_listener.expects(never()).first_key_heared_again()
     self.mock_listener.expects(once()).method('second_key_heared').\
             with_at_least(same('little message'))
     self.notifier.notify('key_with_message', 'little message')
     self.mock_listener.verify()
コード例 #2
0
ファイル: test_fields.py プロジェクト: rhcarvalho/dead-parrot
    def test_urlfield_success_no_verify(self):
        checker_mock = pmock.Mock()

        blog_url = "http://foo.bar.com/blog"

        class Person(Model):
            blog = fields.URLField(verify_exists=False,
                                   url_checker=checker_mock)

        person_dict = {'Person': {'blog': blog_url}}

        checker_mock.expects(pmock.once()) \
            .set_url(pmock.eq(blog_url))

        checker_mock.expects(pmock.once()) \
            .is_valid() \
            .will(pmock.return_value(True))

        checker_mock.expects(pmock.never()) \
            .does_exists()

        john = Person.from_dict(person_dict)

        assert_equals(john.blog, blog_url)
        assert_equals(john.to_dict(), person_dict)
        checker_mock.verify()
コード例 #3
0
ファイル: acceptance_tests.py プロジェクト: gma/pmock
 def test_conflicting_method(self):
     mock = pmock.Mock()
     mock.expects(pmock.never()).cockroach()
     try:
         mock.cockroach()
     except pmock.MatchError, err:
         self.assertEqual(err.msg,
                          "expected method to never be invoked\n"
                          "invoked cockroach()\n"
                          "in:\n"
                          "expected not to be called: cockroach()")
コード例 #4
0
 def test_remove_quizzes_not_from_multiple_choices(self):
     """
     Removing questions NOT in the list of multiple choices shouldn't 
     change multiple choice list.
     """
     self.mock_listener.expects(never()).question_changed()
     self.quiz = Quiz(self.QUIZ_POOL[:])
     old_multi_choices = self.quiz.multi_choices[:]
     old_question = self.quiz.question[:]
     quiz_list = self.QUIZ_POOL[:]
     for quiz in old_multi_choices:
         quiz_list.remove(quiz)
     for quiz in quiz_list:
         self.quiz.remove_quizzes([quiz])
         assert self.quiz.multi_choices == old_multi_choices, \
                 "Multiple choice options changed after removing other "\
                 "quizzes. " "New: %s; Old: %s; Removed: %s." % \
                 (self.quiz.multi_choices, old_multi_choices, quiz)
     self.mock_listener.verify()
コード例 #5
0
 def test_remove_quizzes_not_from_multiple_choices(self):
     """
     Removing questions NOT in the list of multiple choices shouldn't 
     change multiple choice list.
     """
     self.mock_listener.expects(never()).question_changed()
     self.quiz = Quiz(self.QUIZ_POOL[:])
     old_multi_choices = self.quiz.multi_choices[:]
     old_question = self.quiz.question[:]
     quiz_list = self.QUIZ_POOL[:]
     for quiz in old_multi_choices:
         quiz_list.remove(quiz)
     for quiz in quiz_list:
         self.quiz.remove_quizzes([quiz])
         assert self.quiz.multi_choices == old_multi_choices, (
             "Multiple choice options changed after removing other "
             "quizzes. "
             "New: %s; Old: %s; Removed: %s." % (self.quiz.multi_choices, old_multi_choices, quiz)
         )
     self.mock_listener.verify()
コード例 #6
0
ファイル: acceptance_tests.py プロジェクト: gma/pmock
 def setUp(self):
     self.mock = pmock.Mock()
     self.mock.expects(pmock.never()).method("rabbit")
コード例 #7
0
 def test_disconnect(self):
     self.mock_listener.expects(once()).first_key_heared()
     self.mock_listener.expects(never()).first_key_heared_again()
     self.notifier.disconnect('simple_key', self.first_key_heared_again)
     self.notifier.notify('simple_key')
     self.mock_listener.verify()
コード例 #8
0
 def test_notifier(self):
     self.mock_listener.expects(once()).first_key_heared()
     self.mock_listener.expects(once()).first_key_heared_again()
     self.mock_listener.expects(never()).second_key_heared()
     self.notifier.notify('simple_key')
     self.mock_listener.verify()