Пример #1
0
    def test_ignore_repeated_subscription(self):
        subscriptions.insert_one = mock.Mock()
        subscriptions.find_one = mock.Mock()
        subscriptions.find_one.return_value = {'email': '*****@*****.**',
                                               'topic': 'cycling',
                                               '_id': '[email protected]/cycling',
                                               'unsubscribe_id': 'a-uuid'}

        save_subscription("*****@*****.**", "cycling")

        subscriptions.find_one.assert_called_once_with({'_id': '[email protected]/cycling'})
        assert not subscriptions.insert_one.called
Пример #2
0
    def test_save_new_subscription(self):
        uuid.uuid1 = mock.Mock()
        subscriptions.insert_one = mock.Mock()
        subscriptions.find_one = mock.Mock()
        subscriptions.find_one.return_value = None
        uuid.uuid1.return_value = "a-uuid"

        save_subscription("*****@*****.**", "shooting")

        subscriptions.find_one.assert_called_once_with({'_id': '*****@*****.**'})
        subscriptions.insert_one.assert_called_once_with({'email': '*****@*****.**',
                                                          'topic': 'shooting',
                                                          '_id': '*****@*****.**',
                                                          'unsubscribe_id': 'a-uuid'})
Пример #3
0
    def test_save_new_subscription(self):
        sid = "c3848299-23e2-11e5-a64b-a45e60d3c73b"
        uuid.uuid1 = mock.Mock()
        subscriptions.insert_one = mock.Mock()
        subscriptions.find_one = mock.Mock()
        subscriptions.find_one.return_value = None
        uuid.uuid1.return_value = uuid.UUID(sid)

        save_subscription("*****@*****.**", "Shooting and Hunting")

        subscriptions.find_one.assert_called_once_with({'_id': '[email protected]/shootingandhunting'})
        subscriptions.insert_one.assert_called_once_with({'email': '*****@*****.**',
                                                          'topic': 'Shooting and Hunting',
                                                          '_id': '[email protected]/shootingandhunting',
                                                          'unsubscribe_id': sid})
Пример #4
0
    def test_save_updated_subscription(self):
        subscriptions.insert_one = mock.Mock()
        subscriptions.find_one = mock.Mock()
        subscriptions.find_one.return_value = {'email': '*****@*****.**',
                                               'topic': 'shooting',
                                               '_id': '*****@*****.**',
                                               'unsubscribe_id': 'a-uuid'}

        save_subscription("*****@*****.**", "cycling")

        subscriptions.find_one.assert_called_once_with({'_id': '*****@*****.**'})
        subscriptions.insert_one.assert_called_one_with({'_id': '*****@*****.**'},
                                                        {'email': '*****@*****.**',
                                                         'topic': 'cycling',
                                                         '_id': '*****@*****.**',
                                                         'unsubcribe_id': 'a-uuid'},
                                                        True)
Пример #5
0
    def test_save_new_subscription(self):
        uuid.uuid1 = mock.Mock()
        subscriptions.insert_one = mock.Mock()
        subscriptions.find_one = mock.Mock()
        subscriptions.find_one.return_value = None
        uuid.uuid1.return_value = "a-uuid"

        save_subscription("*****@*****.**", "shooting")

        subscriptions.find_one.assert_called_once_with(
            {'_id': '*****@*****.**'})
        subscriptions.insert_one.assert_called_once_with({
            'email':
            '*****@*****.**',
            'topic':
            'shooting',
            '_id':
            '*****@*****.**',
            'unsubscribe_id':
            'a-uuid'
        })
Пример #6
0
    def test_save_updated_subscription(self):
        subscriptions.insert_one = mock.Mock()
        subscriptions.find_one = mock.Mock()
        subscriptions.find_one.return_value = {
            'email': '*****@*****.**',
            'topic': 'shooting',
            '_id': '*****@*****.**',
            'unsubscribe_id': 'a-uuid'
        }

        save_subscription("*****@*****.**", "cycling")

        subscriptions.find_one.assert_called_once_with(
            {'_id': '*****@*****.**'})
        subscriptions.insert_one.assert_called_one_with(
            {'_id': '*****@*****.**'}, {
                'email': '*****@*****.**',
                'topic': 'cycling',
                '_id': '*****@*****.**',
                'unsubcribe_id': 'a-uuid'
            }, True)