Beispiel #1
0
    def test_already_existing_mention(self, mock_soundcloud):
        next_href = 'https://api.soundcloud.com/e1/me/activities.json?' + \
                    'limit=1&cursor=41d51698-0e80-0000-68c4-d0a603b982a9'
        results = [
            {
                'collection': [soundcloud_mention_fixture[0]],
                'next_href': next_href
            }, {
                'collection': [soundcloud_mention_fixture[1]],
                'next_href': next_href
            }, {
                'collection': [soundcloud_mention_fixture[2]],
                'next_href': next_href
            }
        ]
        m1 = MagicMock()
        m1.obj = results[0]
        m2 = MagicMock()
        m2.obj = results[1]
        m3 = MagicMock()
        m3.obj = results[2]
        mocks = [m1, m2, m3]
        mock_soundcloud.return_value.get.side_effect = mocks

        soundcloud = SoundCloudAPI()
        soundcloud.create_mentions()
        mentions = Mention.objects.all()
        self.assertEqual(len(mentions), 2)
        mock_soundcloud.return_value.get.side_effect = mocks
        soundcloud.create_mentions()
        self.assertEqual(len(mentions), 2)
Beispiel #2
0
    def test_already_existing_mention(self, mock_soundcloud):
        next_href = 'https://api.soundcloud.com/e1/me/activities.json?' + \
                    'limit=1&cursor=41d51698-0e80-0000-68c4-d0a603b982a9'
        results = [{
            'collection': [soundcloud_mention_fixture[0]],
            'next_href': next_href
        }, {
            'collection': [soundcloud_mention_fixture[1]],
            'next_href': next_href
        }, {
            'collection': [soundcloud_mention_fixture[2]],
            'next_href': next_href
        }]
        m1 = MagicMock()
        m1.obj = results[0]
        m2 = MagicMock()
        m2.obj = results[1]
        m3 = MagicMock()
        m3.obj = results[2]
        mocks = [m1, m2, m3]
        mock_soundcloud.return_value.get.side_effect = mocks

        soundcloud = SoundCloudAPI()
        soundcloud.create_mentions()
        mentions = Mention.objects.all()
        self.assertEqual(len(mentions), 2)
        mock_soundcloud.return_value.get.side_effect = mocks
        soundcloud.create_mentions()
        self.assertEqual(len(mentions), 2)
Beispiel #3
0
    def test_create_mentions(self, mock_soundcloud):
        next_href = 'https://api.soundcloud.com/e1/me/activities.json?' + \
                    'limit=1&cursor=41d51698-0e80-0000-68c4-d0a603b982a9'
        results = [
            {
                'collection': [soundcloud_mention_fixture[0]],
                'next_href': next_href
            }, {
                'collection': [soundcloud_mention_fixture[1]],
                'next_href': next_href
            }, {
                'collection': [soundcloud_mention_fixture[2]],
                'next_href': next_href
            }
        ]
        m1 = MagicMock()
        m1.obj = results[0]
        m2 = MagicMock()
        m2.obj = results[1]
        m3 = MagicMock()
        m3.obj = results[2]
        mocks = [m1, m2, m3]
        mock_soundcloud.return_value.get.side_effect = mocks

        soundcloud = SoundCloudAPI()
        soundcloud.create_mentions()
        mentions = Mention.objects.all()
        self.assertEqual(len(mentions), 2)

        self.assertEqual(mentions[0].from_user_name, '666robobo777')
        self.assertEqual(mentions[0].from_user_id, '123577402')
        self.assertEqual(mentions[0].message, '@dogebot: tip 10')
        self.assertFalse(mentions[0].processed)

        self.assertEqual(mentions[1].from_user_name, '666robobo777')
        self.assertEqual(mentions[1].from_user_id, '123577402')
        self.assertEqual(mentions[1].message, '@dogebot: tip 20')
        self.assertFalse(mentions[1].processed)
Beispiel #4
0
    def test_create_mentions(self, mock_soundcloud):
        next_href = 'https://api.soundcloud.com/e1/me/activities.json?' + \
                    'limit=1&cursor=41d51698-0e80-0000-68c4-d0a603b982a9'
        results = [{
            'collection': [soundcloud_mention_fixture[0]],
            'next_href': next_href
        }, {
            'collection': [soundcloud_mention_fixture[1]],
            'next_href': next_href
        }, {
            'collection': [soundcloud_mention_fixture[2]],
            'next_href': next_href
        }]
        m1 = MagicMock()
        m1.obj = results[0]
        m2 = MagicMock()
        m2.obj = results[1]
        m3 = MagicMock()
        m3.obj = results[2]
        mocks = [m1, m2, m3]
        mock_soundcloud.return_value.get.side_effect = mocks

        soundcloud = SoundCloudAPI()
        soundcloud.create_mentions()
        mentions = Mention.objects.all()
        self.assertEqual(len(mentions), 2)

        self.assertEqual(mentions[0].from_user_name, '666robobo777')
        self.assertEqual(mentions[0].from_user_id, '123577402')
        self.assertEqual(mentions[0].message, '@dogebot: tip 10')
        self.assertFalse(mentions[0].processed)

        self.assertEqual(mentions[1].from_user_name, '666robobo777')
        self.assertEqual(mentions[1].from_user_id, '123577402')
        self.assertEqual(mentions[1].message, '@dogebot: tip 20')
        self.assertFalse(mentions[1].processed)