8000 style: reduce amount of the copy-paste code in the examples package · proofit404/stories@771090a · GitHub
[go: up one dir, main page]

Skip to content

Commit 771090a

Browse files
dry-python-botdry-python-bot
dry-python-bot
authored and
dry-python-bot
committed
style: reduce amount of the copy-paste code in the examples package
1 parent bd4fbd0 commit 771090a

File tree

11 files changed

+244
-936
lines changed

11 files changed

+244
-936
lines changed
Lines changed: 1 addition & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,3 @@
11
# -*- coding: utf-8 -*-
22
from examples.contract.cerberus import * # noqa: F401, F403
3-
from stories import Success
4-
5-
6-
# Mixins.
7-
8-
9-
class NormalMethod(object):
10-
async def one(self, ctx):
11-
return Success()
12-
13-
14-
class StringMethod(object):
15-
async def one(self, ctx):
16-
ctx.foo = "1"
17-
ctx.bar = ["2"]
18-
return Success()
19-
20-
21-
class WrongMethod(object):
22-
async def one(self, ctx):
23-
ctx.foo = "<boom>"
24-
25-
26-
class UnknownMethod(object):
27-
async def one(self, ctx):
28-
ctx.spam = "0"
29-
30-
31-
class ExceptionMethod(object):
32-
async def one(self, ctx):
33-
raise Exception
34-
35-
36-
class AliasMethod(object):
37-
async def one(self, ctx):
38-
value = {"key": "1"}
39-
ctx.foo = value
40-
ctx.bar = value
41-
ctx.baz = value
42-
return Success()
43-
44-
45-
# Next child mixins.
46-
47-
48-
class NormalNextMethod(object):
49-
async def two(self, ctx):
50-
return Success()
51-
52-
53-
# Parent mixins.
54-
55-
56-
class NormalParentMethod(object):
57-
async def before(self, ctx):
58-
return Success()
59-
60-
async def after(self, ctx):
61-
return Success()
62-
63-
64-
class StringParentMethod(object):
65-
async def before(self, ctx):
66-
ctx.foo = "1"
67-
ctx.bar = ["2"]
68-
return Success()
69-
70-
async def after(self, ctx):
71-
return Success()
72-
73-
74-
class ExceptionParentMethod(object):
75-
async def before(self, ctx):
76-
raise Exception
77-
78-
async def after(self, ctx):
79-
return Success()
80-
81-
82-
# Root mixins.
83-
84-
85-
class NormalRootMethod(object):
86-
async def start(self, ctx):
87-
return Success()
88-
89-
async def finish(self, ctx):
90-
return Success()
91-
92-
93-
class StringRootMethod(object):
94-
async def start(self, ctx):
95-
ctx.foo = "1"
96-
ctx.bar = ["2"]
97-
return Success()
98-
99-
async def finish(self, ctx):
100-
return Success()
101-
102-
103-
class StringWideRootMethod(object):
104-
async def start(self, ctx):
105-
ctx.foo = "1"
106-
ctx.bar = ["2"]
107-
ctx.baz = "1"
108-
return Success()
109-
110-
async def finish(self, ctx):
111-
return Success()
112-
113-
114-
class ExceptionRootMethod(object):
115-
async def start(self, ctx):
116-
raise Exception
117-
118-
async def finish(self, ctx):
119-
return Success()
3+
from examples.contract.common.coroutines import * # noqa: F401, F403
Lines changed: 1 addition & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,3 @@
11
# -*- coding: utf-8 -*-
22
from examples.contract.cerberus import * # noqa: F401, F403
3-
from stories import Success
4-
5-
6-
# Mixins.
7-
8-
9-
class NormalMethod(object):
10-
def one(self, ctx):
11-
return Success()
12-
13-
14-
class StringMethod(object):
15-
def one(self, ctx):
16-
ctx.foo = "1"
17-
ctx.bar = ["2"]
18-
return Success()
19-
20-
21-
class WrongMethod(object):
22-
def one(self, ctx):
23-
ctx.foo = "<boom>"
24-
25-
26-
class UnknownMethod(object):
27-
def one(self, ctx):
28-
ctx.spam = "0"
29-
30-
31-
class ExceptionMethod(object):
32-
def one(self, ctx):
33-
raise Exception
34-
35-
36-
class AliasMethod(object):
37-
def one(self, ctx):
38-
value = {"key": "1"}
39-
ctx.foo = value
40-
ctx.bar = value
41-
ctx.baz = value
42-
return Success()
43-
44-
45-
# Next child mixins.
46-
47-
48-
class NormalNextMethod(object):
49-
def two(self, ctx):
50-
return Success()
51-
52-
53-
# Parent mixins.
54-
55-
56-
class NormalParentMethod(object):
57-
def before(self, ctx):
58-
return Success()
59-
60-
def after(self, ctx):
61-
return Success()
62-
63-
64-
class StringParentMethod(object):
65-
def before(self, ctx):
66-
ctx.foo = "1"
67-
ctx.bar = ["2"]
68-
return Success()
69-
70-
def after(self, ctx):
71-
return Success()
72-
73-
74-
class ExceptionParentMethod(object):
75-
def before(self, ctx):
76-
raise Exception
77-
78-
def after(self, ctx):
79-
return Success()
80-
81-
82-
# Root mixins.
83-
84-
85-
class NormalRootMethod(object):
86-
def start(self, ctx):
87-
return Success()
88-
89-
def finish(self, ctx):
90-
return Success()
91-
92-
93-
class StringRootMethod(object):
94-
def start(self, ctx):
95-
ctx.foo = "1"
96-
ctx.bar = ["2"]
97-
return Success()
98-
99-
def finish(self, ctx):
100-
return Success()
101-
102 2851 -
103-
class StringWideRootMethod(object):
104-
def start(self, ctx):
105-
ctx.foo = "1"
106-
ctx.bar = ["2"]
107-
ctx.baz = "1"
108-
return Success()
109-
110-
def finish(self, ctx):
111-
return Success()
112-
113-
114-
class ExceptionRootMethod(object):
115-
def start(self, ctx):
116-
raise Exception
117-
118-
def finish(self, ctx):
119-
return Success()
3+
from examples.contract.common.functions import * # noqa: F401, F403

tests/helpers/examples/contract/common/__init__.py

Whitespace-only changes.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# -*- coding: utf-8 -*-
2+
from stories import Success
3+
4+
5+
# Mixins.
6+
7+
8+
class NormalMethod(object):
9+
async def one(self, ctx):
10+
return Success()
11+
12+
13+
class StringMethod(object):
14+
async def one(self, ctx):
15+
ctx.foo = "1"
16+
ctx.bar = ["2"]
17+
return Success()
18+
19+
20+
class WrongMethod(object):
21+
async def one(self, ctx):
22+
ctx.foo = "<boom>"
23+
24+
25+
class UnknownMethod(object):
26+
async def one(self, ctx):
27+
ctx.spam = "0"
28+
29+
30+
class ExceptionMethod(object):
31+
async def one(self, ctx):
32+
raise Exception
33+
34+
35+
class AliasMethod(object):
36+
async def one(self, ctx):
37+
value = {"key": "1"}
38+
ctx.foo = value
39+
ctx.bar = value
40+
ctx.baz = value
41+
return Success()
42+
43+
44+
# Next child mixins.
45+
46+
47+
class NormalNextMethod(object):
48+
async def two(self, ctx):
49+
return Success()
50+
51+
52+
# Parent mixins.
53+
54+
55+
class NormalParentMethod(object):
56+
async def before(self, ctx):
57+
return Success()
58+
59+
async def after(self, ctx):
60+
return Success()
61+
62+
63+
class StringParentMethod(object):
64+
async def before(self, ctx):
65+
ctx.foo = "1"
66+
ctx.bar = ["2"]
67+
return Success()
68+
69+
async def after(self, ctx):
70+
return Success()
71+
72+
73+
class ExceptionParentMethod(object):
74+
async def before(self, ctx):
75+
raise Exception
76+
77+
async def after(self, ctx):
78+
return Success()
79+
80+
81+
# Root mixins.
82+
83+
84+
class NormalRootMethod(object):
85+
async def start(self, ctx):
86+
return Success()
87+
88+
async def finish(self, ctx):
89+
return Success()
90+
91+
92+
class StringRootMethod(object):
93+
async def start(self, ctx):
94+
ctx.foo = "1"
95+
ctx.bar = ["2"]
96+
return Success()
97+
98+
async def finish(self, ctx):
99+
return Success()
100+
101+
102+
class StringWideRootMethod(object):
103+
async def start(self, ctx):
104+
ctx.foo = "1"
105+
ctx.bar = ["2"]
106+
ctx.baz = "1"
107+
return Success()
108+
109+
async def finish(self, ctx):
110+
return Success()
111+
112+
113+
class ExceptionRootMethod(object):
114+
async def start(self, ctx):
115+
raise Exception
116+
117+
async def finish(self, ctx):
118+
return Success()

0 commit comments

Comments
 (0)
0