Skip to content

Commit

Permalink
Server working
Browse files Browse the repository at this point in the history
  • Loading branch information
heynemann committed Mar 29, 2009
1 parent beaaa85 commit 42c51f4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
7 changes: 7 additions & 0 deletions pyccuracy/pyccuracy_client.py
Expand Up @@ -18,6 +18,13 @@ def write_lines():
sock.sendall(get_next_test_message)
response = sock.recv(BUFFER_SIZE)
print "Server responded: %s" % response

test_number = response[-12:]
test_result = i % 2 == 0 and "SUCCESSFUL" or "FAILED"
print "sending result for test %s of %s" % (test_number, test_result)
sock.sendall(send_result_message % (test_number, test_result))
response = sock.recv(BUFFER_SIZE)
print "Server responded: %s" % response
time.sleep(2)

sock.close()
Expand Down
14 changes: 8 additions & 6 deletions pyccuracy/pyccuracy_core.py
Expand Up @@ -12,18 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from os.path import join, abspath

from pyoc.ioc import IoC
from pyoc.config import InPlaceConfig

from selenium_browser_driver import *
from webdriver_browser_driver import *
from story_runner import *
from test_fixture_parser import *
from language import *
from errors import *
from pyoc.ioc import IoC
from pyoc.config import InPlaceConfig
from page import Page
from actions.action_base import ActionBase
import report_parser as report
from os.path import join

class PyccuracyCore(object):
def configure_context(self,
Expand Down Expand Up @@ -118,10 +120,10 @@ def configure_ioc(self,
config.register("test_fixture_parser", FileTestFixtureParser)
config.register("tests_dir", tests_dir)

config.register_files("all_actions", actions_dir, "*_action.py", lifestyle_type = "singleton")
config.register_files("all_actions", abspath(actions_dir), "*_action.py", lifestyle_type = "singleton")

config.register_inheritors("all_pages", pages_dir, Page)
config.register_inheritors("all_custom_actions", custom_actions_dir, ActionBase)
config.register_inheritors("all_pages", abspath(pages_dir), Page)
config.register_inheritors("all_custom_actions", abspath(custom_actions_dir), ActionBase)

config.register("story_runner", StoryRunner)

Expand Down
2 changes: 2 additions & 0 deletions pyccuracy/pyccuracy_distributed_language.py
Expand Up @@ -4,3 +4,5 @@
identify_message = identify_action + ":%s"
get_next_test_action = "@get-next-test"
get_next_test_message = get_next_test_action
send_result_action = "@send-test-result"
send_result_message = send_result_action + ":%s=%s"
17 changes: 13 additions & 4 deletions pyccuracy/pyccuracy_server.py
Expand Up @@ -64,7 +64,7 @@ def main():
parser.add_option("-F", "--reportfile", dest="report_file_name", default="report.html", help="Report file. Defines the file name to write the report with [default: %default].")

#server
parser.add_option("-P", "--port", dest="port", default=DEFAULT_PORT, help="Server Port. Defines the port that the server will listen at [default: %default].")
parser.add_option("-o", "--port", dest="port", default=DEFAULT_PORT, help="Server Port. Defines the port that the server will listen at [default: %default].")
(options, args) = parser.parse_args()

pyc = PyccuracyServer(port=options.port)
Expand Down Expand Up @@ -118,7 +118,7 @@ def start(self,
languages_dir,
base_url,
should_throw,
context,
None,
write_report,
report_file_dir,
report_file_name,
Expand Down Expand Up @@ -172,9 +172,13 @@ def route(self, message):
if message.startswith(identify_action):
action, user_id = message.split(':')
self.handle_identify(user_id)
if message.startswith(get_next_test_action):
elif message.startswith(get_next_test_action):
action = message
self.handle_next_test()
elif message.startswith(send_result_action):
action, result = message.split(':')
test_id, status = result.split('=')
self.handle_test_result(test_id, status)

def handle_identify(self, user_id):
self.identity = user_id
Expand All @@ -186,7 +190,12 @@ def handle_next_test(self):
print "Sending test number %s..." % test_number
self.send("You got your test mofo: %s" % test_number)
print "Test sent!"


def handle_test_result(self, test_id, status):
print "Received result for test %s of %s" % (test_id, status)
self.send("Your result got computed for test %s" % test_id)
print "Informed client of acceptance"

if __name__ == "__main__":
main()
#srv = PyccuracyServer(DEFAULT_PORT)
Expand Down

0 comments on commit 42c51f4

Please sign in to comment.