def dropbox_stone_to_dict(obj: "StoneStruct") -> StoneType: """Converts the result of a Dropbox SDK call to a dictionary.""" obj_string = json_encode(Struct(type(obj)), obj) dictionary: StoneType = dict(type=type(obj).__name__) dictionary.update(json.loads(obj_string)) return dictionary
def dropbox_stone_to_dict(obj): """Converts the result of a Dropbox SDK call to a dictionary.""" dictionary = dict(type=obj.__class__.__name__) obj_string = json_encode(Struct(obj.__class__), obj) dictionary.update(json.loads(obj_string)) return _remove_tags(dictionary)
def test_as_user(self, dbxt): dbx_as_user = dbxt.as_user('1') path_root = PathRoot.root("123") dbx_new = dbx_as_user.with_path_root(path_root) self.assertIsInstance(dbx_new, Dropbox) self.assertEqual(dbx_new._headers.get(SELECT_USER_HEADER), '1') expected = stone_serializers.json_encode(PathRoot_validator, path_root) self.assertEqual(dbx_new._headers.get(PATH_ROOT_HEADER), expected)
def test_as_user(self, dbx_team_from_env): dbx_as_user = dbx_team_from_env.as_user('1') path_root = PathRoot.root("123") dbx_new = dbx_as_user.with_path_root(path_root) assert isinstance(dbx_new, Dropbox) assert dbx_new._headers.get(SELECT_USER_HEADER) == '1' expected = stone_serializers.json_encode(PathRoot_validator, path_root) assert dbx_new._headers.get(PATH_ROOT_HEADER) == expected
def test_with_path_root_constructor(self, dbx): # Verify valid mode types for path_root in ( PathRoot.home, PathRoot.root("123"), PathRoot.namespace_id("123"), ): dbx_new = dbx.with_path_root(path_root) self.assertIsNot(dbx_new, dbx) expected = stone_serializers.json_encode(PathRoot_validator, path_root) self.assertEqual(dbx_new._headers.get(PATH_ROOT_HEADER), expected) # verify invalid mode raises ValueError with self.assertRaises(ValueError): dbx.with_path_root(None)
def test_with_path_root_constructor(self, dbx_from_env): # Verify valid mode types for path_root in ( PathRoot.home, PathRoot.root("123"), PathRoot.namespace_id("123"), ): dbx_new = dbx_from_env.with_path_root(path_root) assert dbx_new is not dbx_from_env expected = stone_serializers.json_encode(PathRoot_validator, path_root) assert dbx_new._headers.get(PATH_ROOT_HEADER) == expected # verify invalid mode raises ValueError with pytest.raises(ValueError): dbx_from_env.with_path_root(None)