Skip to content
Browse files

Trying to run tests.

  • Loading branch information...
1 parent e60f6fc commit 1912bdee35aaf7af5854ea7098273c3c6b50f01e @heynemann committed
View
9 pyccuracy/pyccuracy_client.py 100644 → 100755
@@ -1,7 +1,10 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
import socket
import time
from uuid import uuid4
-from pyccuracy_distributed_language import *
+from pyccuracy.pyccuracy_distributed_language import *
def write_lines():
try:
@@ -20,13 +23,15 @@ def write_lines():
response = sock.recv(BUFFER_SIZE)
print "Server responded: %s" % response
+ time.sleep(20)
+
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()
except socket.error:
View
4 pyccuracy/pyccuracy_distributed_language.py
@@ -1,4 +1,4 @@
-DEFAULT_PORT = 4587
+DEFAULT_PORT = 4589
BUFFER_SIZE = 8192
identify_action = "@identify"
identify_message = identify_action + ":%s"
@@ -6,3 +6,5 @@
get_next_test_message = get_next_test_action
send_result_action = "@send-test-result"
send_result_message = send_result_action + ":%s=%s"
+sending_test_action = "@test-to-run"
+sending_test_message = sending_test_action + ":%s"
View
29 pyccuracy/pyccuracy_server.py 100644 → 100755
@@ -6,6 +6,7 @@
import asyncore
import socket
import optparse
+import Queue
from uuid import uuid4
from pyccuracy_distributed_language import *
from pyccuracy.pyccuracy_core import PyccuracyCore
@@ -69,7 +70,7 @@ def main():
pyc = PyccuracyServer(port=options.port)
- result = pyc.start(actions_dir=options.actions_dir,
+ pyc.start(actions_dir=options.actions_dir,
custom_actions_dir=options.custom_actions_dir,
pages_dir=options.pages_dir,
languages_dir=options.languages_dir,
@@ -84,10 +85,6 @@ def main():
browser_driver=options.browser_driver,
should_throw=options.should_throw)
- if result.status != "SUCCESSFUL":
- sys.exit(1)
- sys.exit(0)
-
class PyccuracyServer(object):
def __init__(self, port):
self.port = port
@@ -124,7 +121,7 @@ def start(self,
report_file_name,
browser_to_run,
browser_driver)
-
+
self.server_socket = PyccuracyServerMainSocket(DEFAULT_PORT, core)
asyncore.loop()
except KeyboardInterrupt:
@@ -166,6 +163,13 @@ class PyccuracyServerFactory(object):
def __init__(self, send_method, core):
self.send = send_method
self.core = core
+ self.build_tests_queue()
+
+ def build_tests_queue(self):
+ self.queue = Queue.Queue()
+ for story in self.core.context.test_fixture.stories:
+ story.uuid = uuid4()
+ self.queue.put(story)
def route(self, message):
print "Routing message: %s" % message
@@ -186,10 +190,15 @@ def handle_identify(self, user_id):
self.send("Identity granted at user %s" % self.identity)
def handle_next_test(self):
- test_number = uuid4()
- print "Sending test number %s..." % test_number
- self.send("You got your test mofo: %s" % test_number)
- print "Test sent!"
+ try:
+ story = self.queue.get()
+ import pdb;pdb.set_trace()
+ print "Sending story"
+ self.send(sending_test_message % story.serialize())
+ print "Story sent!"
+ except Queue.Empty:
+ print "No more tests to run"
+ self.send(no_more_tests_message)
def handle_test_result(self, test_id, status):
print "Received result for test %s of %s" % (test_id, status)
View
46 pyccuracy/test_fixture_items.py
@@ -12,8 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import time
from errors import *
-import time
+import simplejson as json
class Story(object):
def __init__(self, as_a, i_want_to, so_that):
@@ -38,7 +39,23 @@ def start_run(self):
self.start_time = time.time()
def end_run(self):
- self.end_time = time.time()
+ self.end_time = time.time()
+
+ def serialize(self):
+ result = []
+ result.append("story:{")
+ result.append(" as_a:'%s'," % self.as_a)
+ result.append(" i_want_to:'%s'," % self.i_want_to)
+ result.append(" so_that:'%s'," % self.so_that)
+ result.append(" status:'%s'," % self.status)
+ result.append(" scenarios: [")
+ for scenario in self.scenarios:
+ result.append(scenario.serialize())
+ result.append(",")
+ result.append(" ]
+ result.append("}")
+
+ return "".join(result)
class Scenario(object):
def __init__(self, story, index, title):
@@ -77,7 +94,30 @@ def start_run(self):
self.start_time = time.time()
def end_run(self):
- self.end_time = time.time()
+ self.end_time = time.time()
+
+ def serialize(self):
+ result = []
+ result.append("scenario:{")
+ result.append(" index:%d," % self.index)
+ result.append(" title:'%s'," % self.title)
+ result.append(" status:'%s'," % self.status)
+ result.append(" givens:[")
+ for given in self.givens:
+ result.append(given.serialize())
+ result.append(",")
+ result.append(" ],")
+ result.append(" whens:[")
+ for when in self.whens:
+ result.append(when.serialize())
+ result.append(",")
+ result.append(" ],")
+ result.append(" thens:[")
+ for then in self.thens:
+ result.append(then.serialize())
+ result.append(",")
+ result.append(" ]")
+ result.append("}")
class Action(object):
def __init__(self, scenario, description, execute_function, arguments):

0 comments on commit 1912bde

Please sign in to comment.
Something went wrong with that request. Please try again.