def test_invalid_json(self):
        testutil.put_stdin("""
            {
              "source": {
                "access_key_id": "apiKey123",
                "secret_access_key": "secretKey321"
              },
              "params": {
              }
            }
            """)

        self.assertEqual(in_.execute('/'), -1)
Exemplo n.º 2
0
 def test_returns_valid_json_with_version(self):
     testutil.put_stdin(
         """
         {
           "source": {
             "user": "******",
             "password": "******",
             "host": "hostname"
           },
           "version": {
             "version": "some-version"
           }
         }
         """)
     io = testutil.mock_stdout()
     self.assertEqual(in_.execute('/'), 0)
     self.assertEqual(testutil.read_from_io(io), '{"version": {"version": "some-version"}}')
    def test_json(self):
        with patch("builtins.open", create=True) as mock_open:
            mock_open.return_value = MagicMock(spec=TextIOWrapper)

            testutil.put_stdin("""
                {
                  "source": {
                    "access_key_id": "apiKey123",
                    "secret_access_key": "secretKey321"
                  },
                  "version": {
                    "env": "dev"
                  }
                }
                """)

            self.assertEqual(in_.execute('/'), 0)
            file_handle = mock_open.return_value.__enter__.return_value
            file_handle.write.assert_called_with('dev')