Beispiel #1
0
    def test_error_local_test_setting_file_does_not_exist(self):
        """test error when use local_settings.py as test settings"""
        invalid_file = "foo/local_test_settings.py"
        with self.assertRaises(CommandError) as cm:
            get_local_test_settings_file(
                ["manage.py", "test", "--local_test_settings", invalid_file])

        self.assertIn("file '%s' does not exist" % invalid_file,
                      str(cm.exception))
Beispiel #2
0
    def test_error_local_test_setting_file_does_not_exist(self):
        """test error when use local_settings.py as test settings"""
        invalid_file = "foo/local_test_settings.py"
        with self.assertRaises(CommandError) as cm:
            get_local_test_settings_file(
                ["manage.py", "test", "--local_test_settings",
                 invalid_file])

        self.assertIn(
            "file '%s' does not exist" % invalid_file, str(cm.exception))
Beispiel #3
0
    def test_error_use_local_settings(self):
        """test error when use local_settings.py as test settings"""
        with self.assertRaises(CommandError) as cm:
            get_local_test_settings_file(
                ["manage.py", "test", "--local_test_settings",
                 "local_settings.py"])

        self.assertIn(
            "Using production local_settings for tests is not "
            "allowed due to security reason.", str(cm.exception))
Beispiel #4
0
    def test_error_use_local_settings(self):
        """test error when use local_settings.py as test settings"""
        with self.assertRaises(CommandError) as cm:
            get_local_test_settings_file([
                "manage.py", "test", "--local_test_settings",
                "local_settings.py"
            ])

        self.assertIn(
            "Using production local_settings for tests is not "
            "allowed due to security reason.", str(cm.exception))
Beispiel #5
0
 def test_custom_local_test_setting_file(self):
     settings_file = "foo/local_test_settings.py"
     with mock.patch("os.path.isfile") as mock_is_file:
         mock_is_file.return_value = True
         self.assertEqual(get_local_test_settings_file(
                 ["manage.py", "test", "foo",
                  "--local_test_settings", settings_file]),
             settings_file)
Beispiel #6
0
 def test_custom_local_test_setting_file(self):
     settings_file = "foo/local_test_settings.py"
     with mock.patch("os.path.isfile") as mock_is_file:
         mock_is_file.return_value = True
         self.assertEqual(
             get_local_test_settings_file([
                 "manage.py", "test", "foo", "--local_test_settings",
                 settings_file
             ]), settings_file)
Beispiel #7
0
 def test_use_default_local_settings_example(self):
     self.assertEqual(
         get_local_test_settings_file(["manage.py", "test", "foo"]),
         "local_settings_example.py")
Beispiel #8
0
 def test_use_default_local_settings_example(self):
     self.assertEqual(get_local_test_settings_file(
             ["manage.py", "test", "foo"]), "local_settings_example.py")