'A POST request to /api/v1/users/me/subscriptions/properties with stream_id and
pin_to_top data pins the stream.'

def test_set_pin_to_top(self):

    user_profile = self.example_user('hamlet')
    test_email = user_profile.email
    self.login(test_email)
    (old_subs, _) = gather_subscriptions(user_profile)
    sub = old_subs[0]
    stream_id = sub['stream_id']
    new_pin_to_top = (not sub['pin_to_top'])
    result = self.client_post('/api/v1/users/me/subscriptions/properties', {'subscription_data': ujson.dumps([{'property': 'pin_to_top', 'stream_id': stream_id, 'value': new_pin_to_top}])}, **self.api_auth(test_email))
    self.assert_json_success(result)
    updated_sub = get_subscription(sub['name'], user_profile)
    self.assertIsNotNone(updated_sub)
    self.assertEqual(updated_sub.pin_to_top, new_pin_to_top)
