Esempio n. 1
0
    def test_should_choose_high_quality_avatar_on_big_score(self, se):
        se.count_score.return_value = 11

        # do
        create_user("*****@*****.**", "pwd", "Foo Bar")

        se.choose_high_quality_avatar.assert_called_with(se.user)
Esempio n. 2
0
    def test_should_choose_low_quality_avatar_on_small_score(
        self, user_mock, not_md5_and_has_salt_mock, count_score_mock,
        choose_low_quality_avatar_mock):

        count_score_mock.return_value = 9
        user = user_mock.return_value

        # do
        create_user("*****@*****.**", "pwd", "Foo Bar")

        count_score_mock.assert_called_with(user)
        choose_low_quality_avatar_mock.assert_called_with(user)
Esempio n. 3
0
    def test_should_create_save_and_return_user(self, se):
        # do
        rv = create_user("*****@*****.**", "pwd", "Foo Bar")

        se.User.assert_called_with(
            email="*****@*****.**",
            password=se.secure_pwd,
            full_name="Foo Bar")
        se.not_md5_and_has_salt.assert_called_with("pwd")
        self.assertIs(rv, se.user)
Esempio n. 4
0
    def test_should_create_save_and_return_user(
        self, user_mock, not_md5_and_has_salt_mock, count_score_mock,
        choose_low_quality_avatar_mock):

        count_score_mock.return_value = 0
        user = user_mock.return_value

        # do
        rv = create_user("*****@*****.**", "pwd", "Foo Bar")
        user_mock.assert_called_with(
            email="*****@*****.**",
            password=not_md5_and_has_salt_mock.return_value,
            full_name="Foo Bar")
        not_md5_and_has_salt_mock.assert_called_with("pwd")
        user.save.assert_called_with()
        self.assertIs(rv, user)