Skip to content

Commit d1fcf72

Browse files
authored
Merge pull request #27 from Lakitna/Support-Secret-variables
Support secret variables
2 parents 3001ce1 + ee88cef commit d1fcf72

18 files changed

Lines changed: 526 additions & 143 deletions

File tree

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,14 @@ token every time you run a test. This can be a great help while making or debugg
7070

7171
```robotframework
7272
Get Api Session Token
73-
VAR ${cache_key} = api-sessions
74-
${cached_token} = Cache Retrieve value ${cache_key}
73+
${cached_token} = Cache Retrieve value api-sessions
7574
IF $cached_token is not $None
7675
RETURN ${cached_token}
7776
END
7877
7978
# Request a new session token
8079
81-
Cache Store Value ${cache_key} ${new_token}
80+
Cache Store Value api-sessions ${new_token}
8281
RETURN ${new_token}
8382
```
8483

@@ -122,6 +121,14 @@ When importing the library, you can provide an alternative cache file path.
122121
Library CacheLibrary file_path=alternative-cache-file.json
123122
```
124123

124+
Cache file paths can have one of the following extensions:
125+
126+
- `.json` (default) - A JSON file. Simple types will be stored as plain JSON. Complex types will be
127+
Pickled. See [jsonpickle](https://jsonpickle.github.io/) for more information.
128+
- `.pkl` - A Pickle file. Pickle is a binary protocol for serializing and de-serializing a Python
129+
object structure. See [pickle](https://docs.python.org/3/library/pickle.html) for more
130+
information.
131+
125132
### Cache too big warnings
126133

127134
A big cache file can indicate an issue with CacheLibary or with how it's used. To help you spot
@@ -145,19 +152,23 @@ Alternatively, you can use the keyword `Cache Reset` for the same purpose.
145152

146153
### What can I cache?
147154

148-
Anything that is JSON serializable.
155+
Anything that is JSON serializable or Pickleable.
149156

150-
CacheLibrary uses a JSON file to store data. Because of this, anything you cache must be able to
151-
fit in a JSON file. In practice, this means that most Robot variables can be stored in the cache.
157+
CacheLibrary uses [jsonpickle](https://jsonpickle.github.io/) to store data. Because of this,
158+
anything you cache must be supported by [JSON](https://docs.python.org/3/library/json.html) or
159+
[Pickle](https://docs.python.org/3/library/pickle.html).
152160

153-
Supported values include (but are not limited to):
161+
In practice, this means that basically all Robot variables can be stored in the cache. Supported
162+
values include (but are not limited to):
154163

155164
- String
156165
- Integer
157166
- Float
158167
- Boolean
159168
- Dictionary
160169
- List
170+
- Secret
171+
- Complex Python objects
161172

162173
### Should I commit my cache file?
163174

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ classifiers = [
1313
"Typing :: Typed",
1414
]
1515
requires-python = ">=3.10"
16-
dependencies = ["robotframework (>=5.0.1)", "robotframework-pabot (>=2.2.0)"]
16+
dependencies = [
17+
"jsonpickle>=2.2.0",
18+
"robotframework (>=5.0.1)",
19+
"robotframework-pabot (>=2.2.0)",
20+
]
1721

1822
[dependency-groups]
1923
dev = [

0 commit comments

Comments
 (0)