TestSmartPrice   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 23
rs 10
c 1
b 0
f 1
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A generate_soupelement_tests() 0 6 3
A test_validurls() 0 4 2
A test_webexists() 0 4 1
A setUp() 0 2 1
1
import unittest
2
import pytest
3
import requests
4
5
from pysmartprice.base import SmartPrice
6
from pysmartprice import constants
7
8
9
class TestSmartPrice(unittest.TestCase):
10
11
    def setUp(self):
12
        self.smartprice = SmartPrice()
13
        # self.generate_soupelement_tests()
14
15
    def generate_soupelement_tests(self):
16
        """Generate test methods to check valid URLS"""
17
        for key, url in constants.URL_MAPPER.iteritems():
18
            testmethodname = 'test_fn_{0}'.format(key)
19
            testmethod = lambda self: self.assertEqual(key, key)
20
            setattr(TestSmartPrice, testmethodname, testmethod)
21
22
    def test_webexists(self):
23
        self.assertEqual(
24
            'http://www.mysmartprice.com/',
25
            constants.SMARTPRICE_WEB_URL
26
            )
27
28
    def test_validurls(self):
29
        for key, url in constants.URL_MAPPER.iteritems():
30
            complete_url = '{}{}'.format(constants.SMARTPRICE_WEB_URL, url)
31
            requests.get(complete_url)
32