Beispiel #1
0
 def test_add_webapp_path_duplication(self):
     """
     Test: The path is not add more than once to sys.path
     When: add_webapp_path is called more than once
     """
     DjangoORM.add_webapp_path()
     expected = sys.path
     DjangoORM.add_webapp_path()
     self.assertEqual(expected, sys.path)
Beispiel #2
0
 def test_add_webapp_path(self):
     """
     Test: The correct path is added to sys.path
     When: add_webapp_path is called
     """
     path = sys.path
     expected = os.path.join(get_project_root(), 'WebApp',
                             'autoreduce_webapp')
     DjangoORM.add_webapp_path()
     self.assertTrue(expected in path)
     sys.path.remove(expected)  # Cleanup test
Beispiel #3
0
 def test_add_webapp_path_already_exist(self):
     """
     Test: The webapp path is not added to sys.path
     When: webapp path already exists and add_webapp_path is called
     """
     webapp_path = os.path.join(get_project_root(), 'WebApp',
                                'autoreduce_webapp')
     sys.path.append(webapp_path)
     expected = sys.path.count(webapp_path)
     DjangoORM.add_webapp_path()
     self.assertEqual(expected, sys.path.count(webapp_path))
     sys.path.remove(webapp_path)  # Cleanup test
Beispiel #4
0
    def test_add_webapp_path_not_already_exist(self):
        """
        Test: The webapp path is added to sys.path
        When: webapp path does not already exist and add_webapp_path is called
        """
        expected = os.path.join(get_project_root(), 'WebApp',
                                'autoreduce_webapp')
        old_sys_path = sys.path.copy()
        if expected in sys.path:
            # Remove all expected from sys.path
            sys.path = list(filter(lambda a: a != expected, sys.path))

        DjangoORM.add_webapp_path()
        self.assertIn(expected, sys.path)
        sys.path = old_sys_path  # Cleanup test