aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helpers.py (unfollow)
Commit message (Collapse)AuthorLines
2021-01-14Prevent an inventory refresh while waiting for item cacheGravatar Numerlor-0/+7
If an inventory refresh was started while the symbol embed coroutine was suspended, it could cause the parser to try to fetch a non existent future if the markdown was requested after it was cleared but before new inventories were loaded in.
2021-01-14Raise an error or log a warning if there's a global name conflictGravatar Numerlor-5/+35
When wrapper uses a global name, which conflicts with a global name from wrapped's module that wrapped uses for its annotations, we run into a situation that can't be solved without changing one of the names, so an error is raised to give this clearer meaning. The check may be erroneous in some edge cases or the objects the conflicting names refer to can be functionally identical, so the error can be turned into a logged warning.
2021-01-14Ensure footer is actually max 100 charsGravatar Numerlor-2/+3
Shortening the renamed symbols string to 100 chars is not accurate as the footer also contains a string before that, subtracting its length fixes this.
2021-01-14Set the user_requested attribute at the start of the coroutineGravatar Numerlor-1/+1
A context switch may occur when we're waiting for the web page response, during which a clear could be triggered. If the event is not set before that we could end up with the dictionary changing sizes, or if a copy was made, a future that'd never finish as it'd be cleared from the queue and the futures dict
2021-01-14Reuse the redis key instead of creating a new string for the expires setGravatar Numerlor-2/+2
2021-01-14Change typehint name casing to PascalCaseGravatar Numerlor-8/+9
2021-01-14Keep trakck of the init task and cancel it when the cog is unloadedGravatar Numerlor-1/+2
2021-01-14Simplify control flowGravatar Numerlor-3/+2
Co-authored-by: MarkKoz <[email protected]>
2021-01-14Use different task ids for every inventory reschedule attemptsGravatar Numerlor-6/+6
The scheduler can't keep track of multiple tasks with the same id, and rescheduling the update task using the same id within an already scheduled update task caused the new task to get ignored as the old task only got deleted from the scheduler after it was finished
2021-01-14Correct return type annotationGravatar Numerlor-1/+1
2021-01-14Turn update_single into a normal functionGravatar Numerlor-3/+3
The method no longer runs anything asynchronous
2021-01-11Fix docstringGravatar Numerlor-1/+1
The decorator works in revers to what the docstring explained
2021-01-11Return whitespace to its previous stateGravatar Numerlor-1/+1
2021-01-11Make REFRESH_EVENT an instance variableGravatar Numerlor-6/+6
2021-01-11Remove old reference to CachedParser and unused constGravatar Numerlor-4/+1
2021-01-11Check for containment instead of always getting the value from the dictGravatar Numerlor-2/+3
Getting the value from a defaultdict will always create the key for it, creating unnecessary entries every time a symbol is fetched from the bot
2021-01-11Notify the user that inventories were refreshed on cache clearsGravatar Numerlor-1/+1
2021-01-11Don't convert package names into lowercaseGravatar Numerlor-1/+1
The converter used to set them already ensures this for us, making the call redundant
2021-01-11Ensure footer fits into messageGravatar Numerlor-3/+8
The footer also now says Moved: at the start to clarify the meaning of the symbols to the user
2021-01-11Use a dictionary of lists instead of set for renamed symbolsGravatar Numerlor-8/+7
A dictionary allows us to grab the original symbol name and then get all the renamed symbols from it, with the improvements to `ensure_unique_symbol_name` we can also use lists instead of sets as each symbol we add should be unique
2021-01-11Handle renaming conflicting symbols in ensure_unique_symbol_nameGravatar Numerlor-15/+14
Previously update_single looped this function until there were no duplicates and when creating new symbols the function had to check if the symbol to create a new name from started with a group/package to avoid redundancy. The new approach ensures a new symbol is always unique when returning by handling the containment check inside and outputting a symbol name in the format of package.group.symbol which should always be unique
2021-01-11Update outdated docstringGravatar Numerlor-1/+1
2021-01-11Send a message to devlog instead of logging a warningGravatar Numerlor-1/+30
2021-01-11Annihilate all traces of Developer and Unverified rolesGravatar mbaruh-720/+14
2021-01-10Resolve wrapped command callbacks in the source commandGravatar Numerlor-1/+4
Without this the command will fetch the source of the wrapper
2021-01-10Create decorator for update_wrapper_globals mimicking functools.wrapsGravatar Numerlor-9/+30
2021-01-10Change the func name to wrapped for clarityGravatar Numerlor-6/+6
2021-01-10Rename CachedParser to BatchParser and move it to its own moduleGravatar Numerlor-166/+180
2021-01-10Make sure that users without the Developers role can use tag.Gravatar Matteo Bertucci-2/+2
We have a check in place to restrict tag usage to a certain role, but our default is the Developers role, and some users now don't have this code. This commit fixes this by using None as a default and adding a truth test in the check_accessibility method.
2021-01-10Defer import to avoid circular importsGravatar Numerlor-1/+1
2021-01-10Move functions strictly related to parsing html to the _html moduleGravatar Numerlor-120/+126
Some constants need to be shared between html and parsing, because they may also be wanted to be edited by the cog user to change the behaviour, they were moved into the package's init.
2021-01-10Expand docstringGravatar Numerlor-1/+6
2021-01-10Bump markdownify to 0.6.1-0.6.*Gravatar Numerlor-10/+15
The 0.6 release brought a new parameter that has to be included in all tag handling methods
2021-01-10Set exception on futureGravatar Numerlor-1/+2
Without the exception set, to the user the bot would fail silently if an exception was handled here
2021-01-10Refresh inventories when the redis cache is clearedGravatar Numerlor-0/+2
Because the futures are cleaned up and Markdown only exists in the cache after a short time, items that were requested previously and had the cache cleared would be missing from the CachedParser
2021-01-10Handle equal DocItems in the queueGravatar Numerlor-2/+6
This could be handled by using sets to hold the items in _page_symbols, but ultimately the check has a much smaller cost than having thousands of sets for the urls. Because we create futures for every item that ends up in the queue we can also skip the .get is None check and instead fetch the future directly from the dict
2021-01-10Stop scheduled and long running tasks on cog unloadGravatar Numerlor-0/+6
2021-01-10Periodically clear unnecessary futures from the _item_futures dictGravatar Numerlor-1/+33
The code has no way of reaching futures through new requests after their result has been set as that also includes setting its value in redis.
2021-01-09Do not add package name to the front of the symbol if it's already thereGravatar Numerlor-2/+11
2021-01-09Do not ignore symbols with slashes.Gravatar Numerlor-2/+0
In some cases these are actual symbols that we can look up
2021-01-09Ensure no symbols get overwritten while generating symbol mappingsGravatar Numerlor-19/+55
The code handling this was moved to a function to achieve this cleanly. Includes fixes for bugs where incorrect package was added to the symbol name in the second branch and an incorrect symbol being added in the third branch Co-authored-by: MarkKoz <[email protected]>
2021-01-09Do not attempt to set cache values for symbols that were not foundGravatar Numerlor-1/+2
2021-01-09Remove redundant variableGravatar Numerlor-2/+1
Co-authored-by: MarkKoz <[email protected]>
2021-01-09Add comments to truncation handling codeGravatar Numerlor-0/+6
Co-authored-by: MarkKoz <[email protected]>
2021-01-09Use update_wrapper instead of wrapsGravatar Numerlor-6/+5
We're not using it as a decorator so using wraps only complicates the call syntax
2021-01-09Return the fetched inventory in the Inventory converterGravatar Numerlor-46/+50
Instead of fetching it again in the cog, the converter now returns the inventory for later use. The set command now no longer attempts to reschedule the inventory, and a bug that caused the inventory rescheduling to do nothing in `update_single` was fixed after moving it to its own method
2021-01-09Wait for the inventory to be refreshed before attempting any fetchingGravatar Numerlor-3/+5
Previously the bot returned an error if a symbol was not found while inventories were refreshing, but we can just wait for the to finish refreshing and then the symbol may be filled in. A logging call to notify of the refresh being done was also added.
2021-01-09Create futures for all items in the queueGravatar Numerlor-5/+18
Creating futures for everything and then awaiting at the end takes care of all the potential race conditions that may pop up from items that are parsed and sent to redis while the get_markdown method is in the middle of fetching a page. In case it happens with the implementation we'll just need to move the item to the front and the future will get a result set soon afterwards.
2021-01-09Clear up docstring so it doesn't rely on private attributeGravatar Numerlor-1/+1
Co-authored-by: MarkKoz <[email protected]>
2021-01-09Revert "Clear up docstring so it doesn't rely on private attribute"Gravatar Numerlor-1/+1
This reverts commit ad90978f