Code Duplication    Length = 30-30 lines in 4 locations

tests/test_tradehub_demex_client.py 4 locations

@@ 214-243 (lines=30) @@
211
        result: dict = self.demex_client.stop_market_buy(pair=pair, quantity='400', stop_price=stop_price)
212
        self.assertDictStructure(expect, result)
213
214
    def test_stop_market_sell(self):
215
        expect: dict = {
216
            'height': str,
217
            'txhash': str,
218
            'raw_log': str,
219
            'logs': [{
220
                'msg_index': int,
221
                'log': str,
222
                'events': [{
223
                    'type': str,
224
                    'attributes': [{
225
                        'key': str,
226
                        'value': str
227
                    }, {
228
                        'key': str,
229
                        'value': str
230
                    }]
231
                }]
232
            }],
233
            'gas_wanted': str,
234
            'gas_used': str
235
        }
236
237
        pair = 'swth_eth'
238
        current_price = self.demex_client.tradehub.get_prices(market=pair)["last"]
239
        stop_price = "{:10.8f}".format(float(current_price) - 0.000001)
240
241
        time.sleep(2)
242
        result: dict = self.demex_client.stop_market_sell(pair=pair, quantity='400', stop_price=stop_price)
243
        self.assertDictStructure(expect, result)
244
245
    def test_cancel_order(self):
246
        expect: dict = {
@@ 183-212 (lines=30) @@
180
        result: dict = self.demex_client.stop_limit_sell(pair=pair, quantity='400', price='0.0000227', stop_price=stop_price)
181
        self.assertDictStructure(expect, result)
182
183
    def test_stop_market_buy(self):
184
        expect: dict = {
185
            'height': str,
186
            'txhash': str,
187
            'raw_log': str,
188
            'logs': [{
189
                'msg_index': int,
190
                'log': str,
191
                'events': [{
192
                    'type': str,
193
                    'attributes': [{
194
                        'key': str,
195
                        'value': str
196
                    }, {
197
                        'key': str,
198
                        'value': str
199
                    }]
200
                }]
201
            }],
202
            'gas_wanted': str,
203
            'gas_used': str
204
        }
205
206
        pair = 'swth_eth'
207
        current_price = self.demex_client.tradehub.get_prices(market=pair)["last"]
208
        stop_price = "{:10.8f}".format(float(current_price) + 0.000001)
209
210
        time.sleep(2)
211
        result: dict = self.demex_client.stop_market_buy(pair=pair, quantity='400', stop_price=stop_price)
212
        self.assertDictStructure(expect, result)
213
214
    def test_stop_market_sell(self):
215
        expect: dict = {
@@ 152-181 (lines=30) @@
149
        result: dict = self.demex_client.stop_limit_buy(pair=pair, quantity='400', price='0.0000091', stop_price=stop_price)
150
        self.assertDictStructure(expect, result)
151
152
    def test_stop_limit_sell(self):
153
        expect: dict = {
154
            'height': str,
155
            'txhash': str,
156
            'raw_log': str,
157
            'logs': [{
158
                'msg_index': int,
159
                'log': str,
160
                'events': [{
161
                    'type': str,
162
                    'attributes': [{
163
                        'key': str,
164
                        'value': str
165
                    }, {
166
                        'key': str,
167
                        'value': str
168
                    }]
169
                }]
170
            }],
171
            'gas_wanted': str,
172
            'gas_used': str
173
        }
174
175
        pair = 'swth_eth'
176
        current_price = self.demex_client.tradehub.get_prices(market=pair)["last"]
177
        stop_price = "{:10.8f}".format(float(current_price) - 0.000001)
178
179
        time.sleep(2)
180
        result: dict = self.demex_client.stop_limit_sell(pair=pair, quantity='400', price='0.0000227', stop_price=stop_price)
181
        self.assertDictStructure(expect, result)
182
183
    def test_stop_market_buy(self):
184
        expect: dict = {
@@ 121-150 (lines=30) @@
118
        result: dict = self.demex_client.market_sell(pair='swth_eth', quantity='400')
119
        self.assertDictStructure(expect, result)
120
121
    def test_stop_limit_buy(self):
122
        expect: dict = {
123
            'height': str,
124
            'txhash': str,
125
            'raw_log': str,
126
            'logs': [{
127
                'msg_index': int,
128
                'log': str,
129
                'events': [{
130
                    'type': str,
131
                    'attributes': [{
132
                        'key': str,
133
                        'value': str
134
                    }, {
135
                        'key': str,
136
                        'value': str
137
                    }]
138
                }]
139
            }],
140
            'gas_wanted': str,
141
            'gas_used': str
142
        }
143
144
        pair = 'swth_eth'
145
        current_price = self.demex_client.tradehub.get_prices(market=pair)["last"]
146
        stop_price = "{:10.8f}".format(float(current_price) + 0.000001)
147
148
        time.sleep(2)
149
        result: dict = self.demex_client.stop_limit_buy(pair=pair, quantity='400', price='0.0000091', stop_price=stop_price)
150
        self.assertDictStructure(expect, result)
151
152
    def test_stop_limit_sell(self):
153
        expect: dict = {