Exemplo n.º 1
0
class TestFactoryManager(unittest.TestCase):
    def setUp(self):
        self.factorManager = FactorManager()

    def test_simple_array(self):
        input_list = [10, 5, 2, 20]
        return_list = self.factorManager.return_factor(input_list)
        expected_return = {10: [5, 2], 5: [], 2: [], 20: [10, 5, 2]}
        self.assertEqual(expected_return, return_list)

    def test_empty_array(self):
        input_list = []
        return_list = self.factorManager.return_factor(input_list)
        expected_return = {}
        self.assertEqual(expected_return, return_list)

    def test_repeating_array(self):
        input_list = [20, 20, 2, 20, 20]
        return_list = self.factorManager.return_factor(input_list)
        expected_return = {
            20: [2],
            2: [],
        }
        self.assertEqual(expected_return, return_list)

    def test_caching_array(self):
        self.factorManager = FactorManager(cache=True)
        input_list = [10, 5, 2, 20]
        return_list = self.factorManager.return_factor(input_list)
        expected_return = {10: [5, 2], 5: [], 2: [], 20: [10, 5, 2]}
        self.assertEqual(expected_return, return_list)
        return_list = self.factorManager.return_factor(input_list)
        self.assertEqual(expected_return, return_list)
Exemplo n.º 2
0
 def test_caching_array(self):
     self.factorManager = FactorManager(cache=True)
     input_list = [10, 5, 2, 20]
     return_list = self.factorManager.return_factor(input_list)
     expected_return = {10: [5, 2], 5: [], 2: [], 20: [10, 5, 2]}
     self.assertEqual(expected_return, return_list)
     return_list = self.factorManager.return_factor(input_list)
     self.assertEqual(expected_return, return_list)
Exemplo n.º 3
0
def form():
    if request.method == 'POST':
        factor_manager = FactorManager()
        #probably want some proper form validation later
        input1 = request.form['input1']
        list = input1.split(',')
        try:
            return_data = factor_manager.return_factor(map(int, list))
            return render_template('form_submit.html', error='', return_data=return_data)
        except Exception as e:
            return render_template('form_submit.html', error='Error has occurred', return_data='')

    else:
        return render_template('form_submit.html')
Exemplo n.º 4
0
class TestFactoryManager(unittest.TestCase):

    def setUp(self):
        self.factorManager = FactorManager()

    def test_simple_array(self):
        input_list = [10,5, 2, 20]
        return_list = self.factorManager.return_factor(input_list)
        expected_return = {
            10: [5, 2],
            5: [],
            2: [],
            20: [10, 5, 2]
        }
        self.assertEqual(expected_return, return_list)

    def test_empty_array(self):
        input_list = []
        return_list = self.factorManager.return_factor(input_list)
        expected_return = {}
        self.assertEqual(expected_return, return_list)

    def test_repeating_array(self):
        input_list = [20,20, 2, 20, 20]
        return_list = self.factorManager.return_factor(input_list)
        expected_return = {
            20: [2],
            2: [],
        }
        self.assertEqual(expected_return, return_list)

    def test_caching_array(self):
        self.factorManager = FactorManager(cache=True)
        input_list = [10,5, 2, 20]
        return_list = self.factorManager.return_factor(input_list)
        expected_return = {
            10: [5, 2],
            5: [],
            2: [],
            20: [10, 5, 2]
        }
        self.assertEqual(expected_return, return_list)
        return_list = self.factorManager.return_factor(input_list)
        self.assertEqual(expected_return, return_list)
Exemplo n.º 5
0
 def test_caching_array(self):
     self.factorManager = FactorManager(cache=True)
     input_list = [10,5, 2, 20]
     return_list = self.factorManager.return_factor(input_list)
     expected_return = {
         10: [5, 2],
         5: [],
         2: [],
         20: [10, 5, 2]
     }
     self.assertEqual(expected_return, return_list)
     return_list = self.factorManager.return_factor(input_list)
     self.assertEqual(expected_return, return_list)
Exemplo n.º 6
0
 def setUp(self):
     self.factorManager = FactorManager()
Exemplo n.º 7
0
 def setUp(self):
     self.factorManager = FactorManager()