| |
@@ -5,7 +5,7 @@
|
| |
from flask import json
|
| |
|
| |
from hubs.app import app
|
| |
- from hubs.models import Hub, User
|
| |
+ from hubs.models import Hub, User, Association
|
| |
from hubs.tests import APPTest, FakeAuthorization, auth_set
|
| |
|
| |
|
| |
@@ -131,6 +131,43 @@
|
| |
hub_config = Hub.query.get("decause").config
|
| |
self.assertEqual(hub_config.summary, "Decause")
|
| |
|
| |
+ def test_put_users(self):
|
| |
+ hub = Hub.by_name('ralph')
|
| |
+ for username in ["devyani7", "dhrish"]:
|
| |
+ hub.associations.append(
|
| |
+ Association(user=User.query.get(username), role="member")
|
| |
+ )
|
| |
+ hub.associations.append(
|
| |
+ Association(user=User.query.get("shalini"), role="subscriber")
|
| |
+ )
|
| |
+ user = FakeAuthorization('ralph')
|
| |
+ with auth_set(app, user):
|
| |
+ result = self.app.put(
|
| |
+ '/api/hubs/ralph/config',
|
| |
+ content_type="application/json",
|
| |
+ data=json.dumps({
|
| |
+ "users": {
|
| |
+ "owner": [{"username": "ralph"}],
|
| |
+ "member": [
|
| |
+ {"username": "decause"},
|
| |
+ {"username": "dhrish"},
|
| |
+ ],
|
| |
+ }
|
| |
+ })
|
| |
+ )
|
| |
+ self.assertEqual(result.status_code, 200)
|
| |
+ result_data = json.loads(result.get_data(as_text=True))
|
| |
+ self.assertEqual(result_data["status"], "OK")
|
| |
+ self.assertListEqual(
|
| |
+ [(a.user_id, a.role) for a in hub.associations],
|
| |
+ [
|
| |
+ ('decause', 'member'),
|
| |
+ ('dhrish', u'member'),
|
| |
+ ('ralph', u'owner'),
|
| |
+ ('shalini', 'subscriber'),
|
| |
+ ]
|
| |
+ )
|
| |
+
|
| |
def test_suggest_users_no_filter(self):
|
| |
user = FakeAuthorization('ralph')
|
| |
expected = [
|
| |
Fix the PUT method for setting hub members and owners.