TestSmartPrice.test_validurls()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
dl 0
loc 4
rs 10
c 1
b 0
f 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