Skip to content

Commit

Permalink
doc:update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Aug 14, 2023
1 parent ebefbfd commit c975885
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 51 deletions.
22 changes: 11 additions & 11 deletions docs/about/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ description: Change log of all fakeredis releases

### 🧰 Bug Fixes

- Fix incorrect error msg for group not found #210
- fix: use same server_key within pipeline when issued watch #213
- Fix incorrect error msg for the group not found #210
- fix: use the same server_key within the pipeline when issued watch #213
- issue with ZRANGE and ZRANGESTORE with BYLEX #214

### Contributors
Expand All @@ -43,7 +43,7 @@ We'd like to thank all the contributors who worked on this release!

### 🧰 Bug Fixes

- Add support for version for async FakeRedis #205
- Add support for `version` for async FakeRedis #205

### 🧰 Maintenance

Expand Down Expand Up @@ -253,7 +253,7 @@ We'd like to thank all the contributors who worked on this release!
#### 🐛 Bug Fixes

- Fix json mget when dict is returned (#114)
- fix: properly export (#116)
- fix: proper export (#116)

#### 🧰 Maintenance

Expand All @@ -275,7 +275,7 @@ We'd like to thank all the contributors who worked on this release!

#### 🐛 Bug Fixes

- Fix bug checking type in scan\_iter (#109)
- Fix a bug the checking type in scan\_iter (#109)

**Full Changelog**: https://github.com/cunla/fakeredis-py/compare/v2.3.0...v2.4.0

Expand Down Expand Up @@ -341,7 +341,7 @@ We'd like to thank all the contributors who worked on this release!
#### 🚀 Features

- Add support for redis-py v4.4rc4 (#73)
- Add mypy support (#74)
- Add mypy support (#74)

#### 🧰 Maintenance

Expand Down Expand Up @@ -393,7 +393,7 @@ We'd like to thank all the contributors who worked on this release!
#### What's Changed

* zadd support for GT/LT in [#49](https://github.com/cunla/fakeredis-py/pull/49)
* Remove six dependency in [#51](https://github.com/cunla/fakeredis-py/pull/51)
* Remove `six` dependency in [#51](https://github.com/cunla/fakeredis-py/pull/51)
* Add host to `conn_pool_args` in [#51](https://github.com/cunla/fakeredis-py/pull/51)

**Full Changelog**: https://github.com/cunla/fakeredis-py/compare/v1.9.1...v1.9.2
Expand All @@ -419,12 +419,12 @@ We'd like to thank all the contributors who worked on this release!

#### What's Changed

* Update publish GitHub action to create an issue on failure by @terencehonles
* Update the `publish` GitHub action to create an issue on failure by @terencehonles
in [#33](https://github.com/dsoftwareinc/fakeredis-py/pull/33)
* Add release draft job in [#37](https://github.com/dsoftwareinc/fakeredis-py/pull/37)
* Add `release draft` job in [#37](https://github.com/dsoftwareinc/fakeredis-py/pull/37)
* Fix input and output type of cursors for SCAN commands by @tohin
in [#40](https://github.com/dsoftwareinc/fakeredis-py/pull/40)
* Fix passing params in args - Fix #36 in [#41](https://github.com/dsoftwareinc/fakeredis-py/pull/41)
* Fix passing params in argsFix #36 in [#41](https://github.com/dsoftwareinc/fakeredis-py/pull/41)

#### New Contributors

Expand Down Expand Up @@ -468,7 +468,7 @@ We'd like to thank all the contributors who worked on this release!

#### What's Changed

* fix: work with redis.asyncio by @zhongkechen in [#10](https://github.com/dsoftwareinc/fakeredis-py/pull/10)
* fix: work with `redis.asyncio` by @zhongkechen in [#10](https://github.com/dsoftwareinc/fakeredis-py/pull/10)
* Migrate to poetry in [#12](https://github.com/dsoftwareinc/fakeredis-py/pull/12)
* Create annotation for redis4+ tests in [#14](https://github.com/dsoftwareinc/fakeredis-py/pull/14)
* Make aioredis and lupa optional dependencies in [#16](https://github.com/dsoftwareinc/fakeredis-py/pull/16)
Expand Down
16 changes: 8 additions & 8 deletions docs/about/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ the maintainers and smooth out the experience for all involved. The community lo
>
> - Star the project
> - Tweet about it
> - Refer this project in your project's readme
> - Refer to this project in your project's readme
> - Mention the project at local meetups and tell your friends/colleagues
## Code of Conduct
Expand Down Expand Up @@ -45,7 +45,7 @@ We will then take care of the issue as soon as possible.
You might want to create a separate issue tag for questions and include it in this description.
People should then tag their issues accordingly.
Depending on how large the project is, you may want to outsource the questioning, e.g. to Stack Overflow or Gitter.
Depending on how large the project is, you may want to outsource the questioning, e.g., to Stack Overflow or Gitter.
You may add additional contact and information possibilities:
- IRC
- Slack
Expand Down Expand Up @@ -73,7 +73,7 @@ Therefore, we ask you to investigate carefully, collect information and describe
Please complete the following steps in advance to help us fix any potential bug as fast as possible.

- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible
- Determine if your bug is really a bug and not an error on your side, e.g., using incompatible
environment components/versions (Make sure that you have read
the [documentation](https://github.com/cunla/fakeredis-py).
If you are looking for support, you might want to check [this section](#i-have-a-question)).
Expand All @@ -91,9 +91,9 @@ Please complete the following steps in advance to help us fix any potential bug

### How Do I Submit a Good Bug Report?

> You must never report security related issues, vulnerabilities or bugs including sensitive information
> You must never report security related issues, vulnerabilities or bugs, including sensitive information
> to the issue tracker, or elsewhere in public.
> Instead sensitive bugs must be sent by email to <daniel@moransoftware.ca>.
> Instead, sensitive bugs must be sent by email to <daniel@moransoftware.ca>.
We use GitHub issues to track bugs and errors. If you run into an issue with the project:

Expand All @@ -103,7 +103,7 @@ We use GitHub issues to track bugs and errors. If you run into an issue with the
- Follow the issue template and provide as much context as possible and describe the *reproduction steps* that someone
else can follow to recreate the issue on their own.
This usually includes your code.
For good bug reports you should isolate the problem and create a reduced test case.
For good bug reports, you should isolate the problem and create a reduced test case.
- Provide the information you collected in the previous section.

Once it's filed:
Expand Down Expand Up @@ -197,15 +197,15 @@ Taken from [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/
[optional footer(s)]
```

The commit contains the following structural elements, to communicate intent to the consumers of your library:
The commit contains the following structural elements to communicate intent to the consumers of your library:

* `fix:` a commit of the type fix patches a bug in your codebase (this correlates with `PATCH` in Semantic Versioning).
* `feat:` a commit of the type feat introduces a new feature to the codebase (this correlates with `MINOR` in Semantic
Versioning).
* `BREAKING CHANGE:` a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a
breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any
type.
* types other than `fix:` and `feat:` are allowed, for example @commitlint/config-conventional (based on the Angular
* types other than `fix:` and `feat:` are allowed, for example, `@commitlint/config-conventional` (based on the Angular
convention) recommends `build:`, `chore:`, `ci:`, `docs:`, `style:`, `refactor:`, `perf:`, `test:`, and others.
* footers other than `BREAKING CHANGE: <description>` may be provided and follow a convention similar to
[git trailer format](https://git-scm.com/docs/git-interpret-trailers).
Expand Down
28 changes: 16 additions & 12 deletions docs/guides/implement-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,29 @@ class FakeSocket(BaseFakeSocket, FakeLuaSocket):
```

## Parsing command arguments
The `extract_args` method should help extracting arguments from `*args`.

The `extract_args` method should help to extract arguments from `*args`.
It extracts from actual arguments which arguments exist and their value if relevant.

Parameters `extract_args` expect:

- `actual_args`
The actual arguments to parse
The actual arguments to parse
- `expected`
Arguments to look for, see below explanation.
Arguments to look for, see below explanation.
- `error_on_unexpected` (default: True)
Should an error be raised when actual_args contain an unexpected argument?
Should an error be raised when actual_args contain an unexpected argument?
- `left_from_first_unexpected` (default: True)
Once reaching an unexpected argument in actual_args,
Should parsing stop?
Once reaching an unexpected argument in actual_args,
Should parsing stop?

It returns two lists:

- List of values for expected arguments.
- List of remaining args.

### Expected argument structure:

- If expected argument has only a name, it will be parsed as boolean
(Whether it exists in actual `*args` or not).
- In order to parse a numerical value following the expected argument,
Expand All @@ -53,11 +57,11 @@ method will be triggered to check the validity of syntax and analyze the command

By default, it takes the name of the method as the command name.

If the method implements a subcommand (eg, `SCRIPT LOAD`), a Redis module command (eg, `JSON.GET`),
or a python reserve word where you can not use it as the method name (eg, `EXEC`), then you can supply
explicitly the name parameter.
If the method implements a subcommand (e.g., `SCRIPT LOAD`), a Redis module command (e.g., `JSON.GET`),
or a python reserve word where you can not use it as the method name (e.g., `EXEC`), then you can explicitly supply
the name parameter.

If the command implemented require certain arguments, they can be supplied in the first parameter as a tuple.
If the command implemented requires certain arguments, they can be supplied in the first parameter as a tuple.
When receiving the command through the socket, the bytes will be converted to the argument types
supplied or remain as `bytes`.

Expand All @@ -82,8 +86,8 @@ The tests not only assert the validity of output but runs the same test on a rea
to the real server output.

- Create tests in the relevant test file.
- If support for the command was introduced in a certain version of redis-py (
see [redis-py release notes](https://github.com/redis/redis-py/releases/tag/v4.3.4)) you can use the
- If support for the command was introduced in a certain version of redis-py
(see [redis-py release notes](https://github.com/redis/redis-py/releases/tag/v4.3.4)) you can use the
decorator `@testtools.run_test_if_redispy_ver` on your tests. example:

```python
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/test-case.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ That way parity of real Redis and FakeRedis is ensured.
To write a new test case for a command:

- Determine which mixin the command belongs to and the test file for
the mixin (eg, `string_mixin.py` => `test_string_commands.py`).
the mixin (e.g., `string_mixin.py` => `test_string_commands.py`).
- Tests should support python 3.7 and above.
- Determine when support for the command was introduced
- To limit the redis-server versions it will run on use:
- To limit the redis-server versions, it will run on use:
`@pytest.mark.max_server(version)` and `@pytest.mark.min_server(version)`
- To limit the redis-py version use `@run_test_if_redispy_ver(above/below, version)`
- pytest will inject a redis connection to the argument `r` of the test.
Expand Down
31 changes: 18 additions & 13 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ FakeRedis is a pure-Python implementation of the Redis key-value store.

It enables running tests requiring redis server without an actual server.

It provides enhanced versions of the redis-py Python bindings for Redis. That provide the following added functionality:
It provides enhanced versions of the redis-py Python bindings for Redis.

That provides the following added functionality:
A built-in Redis server that is automatically installed, configured and managed when the Redis bindings are used. A
single server shared by multiple programs or multiple independent servers. All the servers provided by
FakeRedis support all Redis functionality including advanced features such as RedisJson, GeoCommands.
Expand All @@ -31,7 +33,8 @@ FakeRedis can imitate Redis server version 6.x or 7.x.
If you do not specify the version, version 7 is used by default.

The intent is for fakeredis to act as though you're talking to a real
redis server. It does this by storing state internally.
redis server.
It does this by storing the state internally.
For example:

```pycon
Expand Down Expand Up @@ -91,7 +94,7 @@ redis client for python, and models the responses of redis 6.x or 7.x.

### async Redis

async redis client is supported. Instead of using `fakeredis.FakeRedis`, use `fakeredis.aioredis.FakeRedis`.
Async redis client is supported. Instead of using `fakeredis.FakeRedis`, use `fakeredis.aioredis.FakeRedis`.

```pycon
>>> from fakeredis import aioredis
Expand Down Expand Up @@ -156,13 +159,14 @@ bugs in GitHub.
type.

- Redis makes guarantees about the order in which clients blocked on blocking
commands are woken up. Fakeredis does not honour these guarantees.
commands are woken up.
Fakeredis does not honor these guarantees.

- Where redis contains bugs, fakeredis generally does not try to provide exact
bug-compatibility. It's not practical for fakeredis to try to match the set
of bugs in your specific version of redis.
bug compatibility.
It's not practical for fakeredis to try to match the set of bugs in your specific version of redis.

- There are a number of cases where the behaviour of redis is undefined, such
- There are a number of cases where the behavior of redis is undefined, such
as the order of elements returned by set and hash commands. Fakeredis will
generally not produce the same results, and in Python versions before 3.6
may produce different results each time the process is re-run.
Expand All @@ -182,7 +186,7 @@ bugs in GitHub.
To ensure parity with the real redis, there are a set of integration tests
that mirror the unittests. For every unittest that is written, the same
test is run against a real redis instance using a real redis-py client
instance. In order to run these tests you must have a redis server running
instance. In order to run these tests, you must have a redis server running
on localhost, port 6379 (the default settings). **WARNING**: the tests will
completely wipe your database!

Expand All @@ -207,9 +211,9 @@ poetry run pytest -m fake

Because this module is attempting to provide the same interface as `redis-py`,
the python bindings to redis, a reasonable way to test this to take each
unittest and run it against a real redis server. fakeredis and the real redis
server should give the same result. To run tests against a real redis instance
instead:
unittest and run it against a real redis server.
Fakeredis and the real redis server should give the same result.
To run tests against a real redis instance instead:

```bash
poetry run pytest -m real
Expand All @@ -219,8 +223,9 @@ If redis is not running, and you try to run tests against a real redis server,
these tests will have a result of 's' for skipped.

There are some tests that test redis blocking operations that are somewhat
slow. If you want to skip these tests during day to day development,
they have all been tagged as 'slow' so you can skip them by running:
slow.
If you want to skip these tests during day-to-day development, they have all been tagged as 'slow' so you can skip them
by running:

```bash
poetry run pytest -m "not slow"
Expand Down
10 changes: 5 additions & 5 deletions docs/redis-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

## RedisJson support

Currently, Redis Json module is fully implemented (
see [supported commands](./redis-commands/RedisJson/)).
Support for JSON commands (eg, [`JSON.GET`](https://redis.io/commands/json.get/)) is implemented using
[jsonpath-ng](https://github.com/h2non/jsonpath-ng), you can simply install it using `pip install 'fakeredis[json]'`.
Currently, Redis Json module is fully implemented (see [supported commands](./redis-commands/RedisJson/)).
Support for JSON commands (e.g., [`JSON.GET`](https://redis.io/commands/json.get/)) is implemented using
[jsonpath-ng,](https://github.com/h2non/jsonpath-ng) you can simply install it using `pip install 'fakeredis[json]'`.

```pycon
>>> import fakeredis
Expand All @@ -21,4 +20,5 @@ Support for JSON commands (eg, [`JSON.GET`](https://redis.io/commands/json.get/)
## Lua support

If you wish to have Lua scripting support (this includes features like ``redis.lock.Lock``, which are implemented in
Lua), you will need [lupa](https://pypi.org/project/lupa/), you can simply install it using `pip install 'fakeredis[lua]'`
Lua), you will need [lupa](https://pypi.org/project/lupa/), you can simply install it
using `pip install 'fakeredis[lua]'`

0 comments on commit c975885

Please sign in to comment.