class TestProject(unittest.TestCase): def _default_options(self): options = Options() opts = options.parse() return opts def setUp(self): self.machine = Project(self._default_options()) self.mock_process = mock() self.machine.process = self.mock_process def test_machine_should_get_date(self): self.machine.date() verify(self.mock_process).execute('date')
def run_project(args): options = Options() options.parse(args[1:]) project = Project(options) print 'Printing date:', project.date() print 'Printing example arg:', project.print_example_arg()
class TestProject(unittest.TestCase): def _default_options(self): options = Options() opts, args = options.parse() return opts def setUp(self): self.machine = Project(self._default_options()) self.mock_process = MockProcess() self.machine.process = self.mock_process def test_machine_should_get_date(self): self.machine.date() self.assertTrue("date" in self.mock_process.commands)
def post(self): count=int(self.request.get("count")) + 1 category = self.request.get("category") address = self.request.get("address") lat = self.request.get("lat") lng = self.request.get("lng") title = self.request.get("title") search = self.request.get("title").lower() link = title.replace(" ", "-") shortDescription = self.request.get("shortDescription") #date = time.strtftime("%Y-%m-%d %H:%M:%S") date = datetime.date.today() date = str(date) funding = [] print shortDescription user=users.get_current_user() userid = user.user_id() projectObject = Project() projectObject.ngo = userid projectObject.link = link projectObject.description = shortDescription projectObject.category = category projectObject.title = title projectObject.search = search projectObject.funding = funding projectObject.date = date projectObject.address = address projectObject.lat = lat projectObject.lng = lng projectObject.authenticity = False projectObject.tasks = [] j=0 while j<count: Counter=str(j) taskTitle = self.request.get("taskTitle"+Counter) taskDescription = self.request.get("taskDescription"+Counter) taskFund = self.request.get("taskFund"+Counter) j=j+1 projectObject.tasks.append([taskTitle, taskDescription, taskFund]) projectObject.put() self.response.headers.add_header("Set-Cookie",str("title=%s"%title)) sleep(5) self.redirect("/home")
def post(self): count = int(self.request.get("count")) + 1 category = self.request.get("category") address = self.request.get("address") lat = self.request.get("lat") lng = self.request.get("lng") title = self.request.get("title") search = self.request.get("title").lower() link = title.replace(" ", "-") shortDescription = self.request.get("shortDescription") #date = time.strtftime("%Y-%m-%d %H:%M:%S") date = datetime.date.today() date = str(date) funding = [] print shortDescription user = users.get_current_user() userid = user.user_id() projectObject = Project() projectObject.ngo = userid projectObject.link = link projectObject.description = shortDescription projectObject.category = category projectObject.title = title projectObject.search = search projectObject.funding = funding projectObject.date = date projectObject.address = address projectObject.lat = lat projectObject.lng = lng projectObject.authenticity = False projectObject.tasks = [] j = 0 while j < count: Counter = str(j) taskTitle = self.request.get("taskTitle" + Counter) taskDescription = self.request.get("taskDescription" + Counter) taskFund = self.request.get("taskFund" + Counter) j = j + 1 projectObject.tasks.append([taskTitle, taskDescription, taskFund]) projectObject.put() self.response.headers.add_header("Set-Cookie", str("title=%s" % title)) sleep(5) self.redirect("/home")
import sys from lib import Project from lib import Options if __name__ == '__main__': options = Options() opts = options.parse(sys.argv[1:]) v = Project(opts) v.date() v.print_example_arg()
import sys from lib import Project from lib import Options if __name__ == '__main__': options = Options() opts, args = options.parse(sys.argv[1:]) v = Project(opts) v.date()