def test_7_user_preferences(self): print "" print "test user preferences" # Force authentication ... connection = frontend.login("admin", "admin", force=True) assert_true(frontend.authenticated) assert_true(frontend.token) connection = frontend.connect(username="******") assert_true(frontend.authenticated) assert_true(frontend.connected) parameters = {"a": 1, "b": "2"} response = frontend.set_user_preferences("admin", "test_prefs", parameters) # {u'_updated': u'Sun, 04 Oct 2015 08:14:41 GMT', u'_links': {u'self': {u'href': u'uipref/5610dff1f9e3854415d129be', u'title': u'Uipref'}}, u'_created': u'Sun, 04 Oct 2015 08:14:41 GMT', u'_status': u'OK', u'_id': u'5610dff1f9e3854415d129be', u'_etag': u'26569a70b70d9ea2f5df5983a685c41278db23cf'} print response assert_true("_updated" in response) parameters = frontend.get_user_preferences("admin", "test_prefs") # u'_updated': u'Sun, 04 Oct 2015 08:19:08 GMT', u'data': {u'a': 1, u'b': u'2'}, u'_links': {u'self': {u'href': u'uipref/5610dff1f9e3854415d129be', u'title': u'Uipref'}}, u'user': u'admin', u'_created': u'Sun, 04 Oct 2015 08:14:41 GMT', u'_id': u'5610dff1f9e3854415d129be', u'type': u'test_prefs', u'_etag': u'8c05b7d8ee64d18e10a98a7885569c48f4a68d13'} print parameters assert_true("data" in parameters) assert_true("a" in parameters["data"]) assert_true(parameters["data"]["a"] == 1) assert_true("b" in parameters["data"]) assert_true(parameters["data"]["b"] == "2") parameters = {"a": 2, "b": "3"} response = frontend.set_user_preferences("admin", "test_prefs", parameters) print response assert_true("_updated" in response) parameters = frontend.get_user_preferences("admin", "test_prefs") # u'_updated': u'Sun, 04 Oct 2015 08:19:08 GMT', u'data': {u'a': 1, u'b': u'2'}, u'_links': {u'self': {u'href': u'uipref/5610dff1f9e3854415d129be', u'title': u'Uipref'}}, u'user': u'admin', u'_created': u'Sun, 04 Oct 2015 08:14:41 GMT', u'_id': u'5610dff1f9e3854415d129be', u'type': u'test_prefs', u'_etag': u'8c05b7d8ee64d18e10a98a7885569c48f4a68d13'} print parameters assert_true("data" in parameters) assert_true("a" in parameters["data"]) assert_true(parameters["data"]["a"] == 2) assert_true("b" in parameters["data"]) assert_true(parameters["data"]["b"] == "3") connection = frontend.logout() assert_false(frontend.authenticated) assert_false(frontend.connected) assert_false(frontend.token)
def test_4_connection_username(self): print "" print "test connection with username/password" connection = frontend.login("admin", "admin") assert_true(frontend.authenticated) assert_false(frontend.connected) assert_true(frontend.token) # Already authenticated ... connection = frontend.login("", "") assert_true(frontend.authenticated) assert_false(frontend.connected) assert_true(frontend.token) # Force authentication ... connection = frontend.login("admin", "admin", force=True) assert_true(frontend.authenticated) assert_false(frontend.connected) assert_true(frontend.token) connection = frontend.logout() assert_false(frontend.authenticated) assert_false(frontend.connected) assert_false(frontend.token) print "authenticated:", frontend.authenticated connection = frontend.connect(username="******") print "authenticated:", frontend.authenticated assert_false(frontend.connected) assert_false(frontend.authenticated) connection = frontend.disconnect() assert_false(frontend.authenticated) assert_false(frontend.connected) assert_false(frontend.token)