Esempio n. 1
0
    def test(self, user_factory, channel_factory):
        channel_factory(user=user_factory())
        channel_factory(user=user_factory())

        records = services.get_channels()

        assert len(records) == 2
        assert all(isinstance(c, services.models.Channel) for c in records)
Esempio n. 2
0
    def test_with_user_id(self, user_factory, channel_factory):
        user = user_factory()
        channel_factory(user=user)
        channel_factory(user=user)
        channel_factory(user=user_factory())

        records = services.get_channels(user_id=user.id)

        assert len(records) == 2
        assert all(c.user_id == user.id for c in records)
Esempio n. 3
0
    def test(self, api_client, channel_factory, body):
        api_client, user = api_client
        channel_factory(user=user, is_selected=True)
        channel = channel_factory(user=user, is_selected=False)

        response = api_client.put(f'/api/v1/channel/{channel.id}/',
                                  body,
                                  format='json')

        assert response.status_code == OK
        assert response.json() == S({
            'id':
            channel.id,
            'user':
            user.id,
            'name':
            body.get('name', str),
            'description':
            body.get('description', str),
            'sync_videos_interested':
            body.get('sync_videos_interested', bool),
            'language':
            body.get('language', str),
            'created_on':
            str,
            'modified_on':
            str,
            'is_selected':
            body.get('is_selected', channel.is_selected),
            'videos':
            list,
            'followers_count':
            int,
            'avatar_image_large_url':
            str,
            'avatar_image_small_url':
            str,
            'banner_image_small_url':
            str,
            'banner_image_large_url':
            str,
            'has_banner':
            bool,
            'created_on':
            str,
            'created_date':
            str,
            'videos_count':
            int,
        })
        num_selected_channels = len(
            tuple(c for c in services.get_channels(user_id=user.id)
                  if c.is_selected))
        assert num_selected_channels == 1
Esempio n. 4
0
    def test(
        self,
        api_client,
        channel_factory,
        body,
        expected_channel_detail_resp_json,
    ):
        api_client, user = api_client
        channel_factory(user=user, is_selected=True)
        channel = channel_factory(user=user, is_selected=False)

        response = api_client.put(f'/api/v1/channel/{channel.id}/',
                                  body,
                                  format='json')

        assert response.status_code == OK
        assert response.json() == expected_channel_detail_resp_json.extend({
            'id':
            channel.id,
            'user':
            user.id,
            'name':
            body.get('name', str),
            'description':
            body.get('description', str),
            'sync_videos_interested':
            body.get('sync_videos_interested', bool),
            'primary_language':
            body.get('primary_language', str),
            'is_selected':
            body.get('is_selected', channel.is_selected),
            'tags': [t.lower()
                     for t in body.get('tags')] if body.get('tags') else list,
        })
        num_selected_channels = len(
            tuple(c for c in services.get_channels(user_id=user.id)
                  if c.is_selected))
        assert num_selected_channels == 1
Esempio n. 5
0
def test_run():
    import_seed_data._run()

    assert get_user_model().objects.filter(is_superuser=True).count() == 2
    assert len(channel_services.get_channels()) == 3
    assert Video.objects.count() == 2