Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add tasks sequence support #827
This pr is related to this issue.
As I said In slack, I know there is an easy workaround of defining only one task in the TaskSet and defining all the behavior there. The problem with the workaround is that it is a bit hacky, since you have to do
If accepted this pr will
Introduce a new class:
class BrowseDocumentationSequence(TaskSquence): def on_start(self): self.urls_on_current_page = self.toc_urls # assume all users arrive at the index page @seq_task(1) def index_page(self): r = self.client.get("/") pq = PyQuery(r.content) link_elements = pq(".toctree-wrapper a.internal") self.toc_urls = [ l.attrib["href"] for l in link_elements ] @seq_task(2) @task(50) def load_page(self, url=None): url = random.choice(self.toc_urls) r = self.client.get(url) pq = PyQuery(r.content) link_elements = pq("a.internal") self.urls_on_current_page = [ l.attrib["href"] for l in link_elements ] @seq_task(3) @task(30) def load_sub_page(self): url = random.choice(self.urls_on_current_page) r = self.client.get(url)
In the example above, index_page/1 will be executed first, then load_page/1 fifty times, and then load_sub_page/1 thirty times.
@@ Coverage Diff @@ ## master #827 +/- ## ========================================== + Coverage 66.1% 66.55% +0.44% ========================================== Files 14 14 Lines 1422 1438 +16 Branches 224 226 +2 ========================================== + Hits 940 957 +17 + Misses 431 430 -1 Partials 51 51