示例#1
0
    def test_run_command(self, mock_subprocess):
        mock_subprocess.check_output.return_value = ""

        # Run normally to generate settings file
        with captured_stderr() as error, captured_stdout() as out:
            run_signals("./tests/files/test_schema.json", "objc",
                        "./tests/files/",
                        "./tests/files/doubledummy.xcdatamodeld", True,
                        "YetiProject", True)
            self.assertEqual(error.getvalue(), "")
            self.assertIn("Finished generating your files!", out.getvalue())

        # Verify successful generation using the --settingspath argument
        with captured_stderr() as error, captured_stdout() as out:
            project_specified(None, None, "./tests/files")
            self.assertEqual(error.getvalue(), "")
            self.assertIn("Finished generating your files!", out.getvalue())

        # Remove the settings file
        command = "rm ./tests/files/.signalsconfig"
        process = subprocess.Popen(command,
                                   shell=True,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
        output, error = process.communicate()
        self.assertEqual(error, "")

        # Ensure that attempting to use the settings path fails now
        with captured_stderr() as error, captured_stdout() as out:
            project_specified(None, None, "./tests/files")
            self.assertIn("Settings file", out.getvalue())
            self.assertIn("not found", out.getvalue())
示例#2
0
    def test_run_command(self, mock_subprocess):
        mock_subprocess.check_output.return_value = ""

        # Run normally to generate settings file
        with captured_stderr() as error, captured_stdout() as out:
            run_signals("./tests/files/test_schema.json", "objc", "./tests/files/",
                        "./tests/files/doubledummy.xcdatamodeld", True, "YetiProject", True)
            self.assertEqual(error.getvalue(), "")
            self.assertIn("Finished generating your files!", out.getvalue())

        # Verify successful generation using the --settingspath argument
        with captured_stderr() as error, captured_stdout() as out:
            project_specified(None, None, "./tests/files")
            self.assertEqual(error.getvalue(), "")
            self.assertIn("Finished generating your files!", out.getvalue())

        # Remove the settings file
        command = "rm ./tests/files/.signalsconfig"
        process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        output, error = process.communicate()
        self.assertEqual(error, "")

        # Ensure that attempting to use the settings path fails now
        with captured_stderr() as error, captured_stdout() as out:
            project_specified(None, None, "./tests/files")
            self.assertIn("Settings file", out.getvalue())
            self.assertIn("not found", out.getvalue())
示例#3
0
 def test_run_signals_error(self, mock_subprocess):
     mock_subprocess.check_output.return_value = "Xcode.app"
     with captured_stdout() as out:
         run_signals("./tests/files/test_schema.json", "objc",
                     "./tests/files/", "./core/data/path", True,
                     "YetiProject", False)
         self.assertIn("Must quit Xcode before writing to core data",
                       out.getvalue())
示例#4
0
 def test_run_signals_error(self, mock_subprocess):
     mock_subprocess.check_output.return_value = "Xcode.app"
     with captured_stdout() as out:
         run_signals(
             "./tests/files/test_schema.json",
             "objc",
             "./tests/files/",
             "./core/data/path",
             True,
             "YetiProject",
             False,
         )
         self.assertIn("Must quit Xcode before writing to core data", out.getvalue())
示例#5
0
 def test_validate_json_fails(self):
     url = URL({"url": "posts/"})
     with captured_stdout() as s:
         url.validate_json({
             "url": "posts/",
             "gets": {
                 "#meta": "oauth2,optional",
                 "response": {
                     "200+": "$postResponse"
                 }
             }
         })
         self.assertEqual(s.getvalue().rstrip("\n"),
                          colorize_string("yellow", "Found unsupported attribute, gets, for url: posts/"))
示例#6
0
 def test_run_signals(self):
     with captured_stderr() as error, captured_stdout() as out:
         run_signals("./tests/files/test_schema.json", "objc", "./tests/files/", None, False, "YetiProject", False)
         self.assertEqual(error.getvalue(), "")
         self.assertIn("Finished generating your files!", out.getvalue())
示例#7
0
 def test_field_process_attribute_error(self):
     with captured_stdout() as out:
         Field("username", ["string", "option"])
         self.assertEqual(out.getvalue().rstrip("\n"),
                          colorize_string("yellow", "Found an unexpected attribute: option on username."))
示例#8
0
 def test_run_signals(self):
     with captured_stderr() as error, captured_stdout() as out:
         run_signals("./tests/files/test_schema.json", "objc",
                     "./tests/files/", None, False, "YetiProject", False)
         self.assertEqual(error.getvalue(), "")
         self.assertIn("Finished generating your files!", out.getvalue())