forked from OpenInterpreter/open-interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Koissi's critical server fix, shrink image fix, huge logs fix, securi…
…ty improvements Koissi's critical server fix, shrink image fix, huge logs fix, security improvements
- Loading branch information
Showing
7 changed files
with
137 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
from unittest import TestCase, mock | ||
|
||
from interpreter.core.async_core import Server, AsyncInterpreter | ||
|
||
|
||
class TestServerConstruction(TestCase): | ||
""" | ||
Tests to make sure that the underlying server is configured correctly when constructing | ||
the Server object. | ||
""" | ||
|
||
def test_host_and_port_defaults(self): | ||
""" | ||
Tests that a Server object takes on the default host and port when | ||
a) no host and port are passed in, and | ||
b) no HOST and PORT are set. | ||
""" | ||
with mock.patch.dict(os.environ, {}): | ||
s = Server(AsyncInterpreter()) | ||
self.assertEqual(s.host, Server.DEFAULT_HOST) | ||
self.assertEqual(s.port, Server.DEFAULT_PORT) | ||
|
||
def test_host_and_port_passed_in(self): | ||
""" | ||
Tests that a Server object takes on the passed-in host and port when they are passed-in, | ||
ignoring the surrounding HOST and PORT env vars. | ||
""" | ||
host = "the-really-real-host" | ||
port = 2222 | ||
|
||
with mock.patch.dict(os.environ, {"HOST": "this-is-supes-fake", "PORT": "9876"}): | ||
sboth = Server(AsyncInterpreter(), host, port) | ||
self.assertEqual(sboth.host, host) | ||
self.assertEqual(sboth.port, port) | ||
|
||
def test_host_and_port_from_env_1(self): | ||
""" | ||
Tests that the Server object takes on the HOST and PORT env vars as host and port when | ||
nothing has been passed in. | ||
""" | ||
fake_host = "fake_host" | ||
fake_port = 1234 | ||
|
||
with mock.patch.dict(os.environ, {"HOST": fake_host, "PORT": str(fake_port)}): | ||
s = Server(AsyncInterpreter()) | ||
self.assertEqual(s.host, fake_host) | ||
self.assertEqual(s.port, fake_port) |