def test_connects(self): mock = SocketMock() test = Get(mock) reply = test.connect() self.assertEquals(mock.connectCalled , ('quantbet.com', 80)) self.assertEquals(reply , ["<html><div>" , "test" , "</div></html>"]) self.assertEquals(mock.dataSent , "GET /quiz HTTP/1.1\nHost: quantbet.com\n\n") self.assertEquals(mock.closeCalled , 1)
import socket import time from development.get import Get from development.post import Post from development.localmath import GCD from development.processResponse import ProcessResponse start_time = time.time() print "Sending request..." soc = socket.socket(socket.AF_INET , socket.SOCK_STREAM) request = Get(soc) reply = request.connect() print "Processing response..." data = ProcessResponse(reply) cookie = data.getCookie() numbers = data.getNumbers() p = "recieved: " + str(numbers[0]) + " , " + str(numbers[1]) print p math = GCD(numbers[0] , numbers[1])