Skip to content

Commit

Permalink
refactor(tests): various test refactors
Browse files Browse the repository at this point in the history
* refactor(tests): add testing_utilities.py

* style(tests): add NOSONAR

* fix(tests): correct import of testing_utilities

* refactor(tests): add test_yaml_loader_convert_phrase.py

* refactor(tests): add _alt_versions() and _alt_translations()

* fix(tests): add missing parentheses

* style(tests): rename randomPath to random_path

* refactor(tests): add test_yaml_loader_convert_phrases.py

* fix(tests): add mock_convert_phrase to test_converts_every_word

* refactor(tests): add test_yaml_loader_convert_words.py

* refactor(tests): add test_yaml_loader_convert_word.py

* style(tests): add _also_accepted()

* refactor(tests): remove testing_utilities.py and use fakes

* refactor: add number

* refactor(tests): use fakes.number()

* docs: update of the fakes README.md

* fix: add blank line

* style: improve wording

* fix: add missing i

* refactor(tests): add _access_functions

* refactor(tests): use all(...)

* refactor(tests): add _access_functions
  • Loading branch information
vil02 authored Jan 16, 2022
1 parent 73e32cd commit bb74688
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 217 deletions.
10 changes: 10 additions & 0 deletions apps/librelingo_fakes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ fake_course = fakes.customize(fakes.course1, modules=[
])
```

<a name="librelingo_fakes.fakes.number"></a>
#### number

```python
number(max_value=10000)
```

Returns a 'random' non-negative integer.
It is NOT cryptographically-secure.

12 changes: 10 additions & 2 deletions apps/librelingo_fakes/librelingo_fakes/fakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,17 @@
)


def number(max_value=10000):
"""
Returns a 'random' non-negative integer.
It is NOT cryptographically-secure.
"""
return random.randint(0, max_value) # NOSONAR


def fake_value():
FakeValue = namedtuple("FakeValue", ["id"])
return FakeValue(random.randint(0, 10000))
return FakeValue(number())


def customize(fake, **kwargs):
Expand All @@ -279,4 +287,4 @@ def customize(fake, **kwargs):


def path():
return Path(f"./path{random.randint(0, 5000)}")
return Path(f"./path{number(max_value=5000)}")
Loading

1 comment on commit bb74688

@vercel
Copy link

@vercel vercel bot commented on bb74688 Jan 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.