Esempio n. 1
0
	def test_answer_question(self):
		request_id = self.submit_request(text=self.random_content('request'), email = '*****@*****.**')
		qa_id = prr.ask_a_question(request_id = request_id, user_id = 1, question  = self.random_content('question'))
		answer = self.random_content('answer')
		fields = dict(request_id = request_id, qa_id = qa_id, user_id = 1, answer_text = answer)
		page = self.submit_generic(fields = fields, endpoint = "update_a_qa")
		assert answer in page.data
Esempio n. 2
0
 def test_answer_question(self):
     request_id = self.submit_request(text=self.random_content('request'),
                                      email='*****@*****.**')
     qa_id = prr.ask_a_question(request_id=request_id,
                                user_id=1,
                                question=self.random_content('question'))
     answer = self.random_content('answer')
     fields = dict(request_id=request_id,
                   qa_id=qa_id,
                   user_id=1,
                   answer_text=answer)
     page = self.submit_generic(fields=fields, endpoint="update_a_qa")
     assert answer in page.data
Esempio n. 3
0
depts_json = open(os.path.join(app.root_path, 'static/json/list_of_departments.json'))
staff_json = open(os.path.join(app.root_path, 'static/json/staff_emails.json'))
departments = json.load(depts_json)
people = json.load(staff_json)
reasons = ['They have the document', 'They would know more about this', 'They are my backup', 'Can you look into this?']
documents = ['Minutes', 'Report']
answers = ["Yep, thanks so much!", "No, nevermind then."]

# Create some seed data so our tests run
for i in range(20):
	request_type = random.choice(common_requests)
	request_department = random.choice(departments)
	random_number = random.randrange(0, 901, 4)
	another_random_number =  random.randrange(0, 901, 4)
	request_text = "%(request_type)s %(random_number)s" % locals()
	request_id, success = prr.make_request(text=request_text, department = request_department)
	if success:
		prr.add_note(request_id = request_id, text = "We're working on this and will get back to you shortly.", user_id = 2)
		qa_id = prr.ask_a_question(request_id = request_id, owner_id = 1, question = "You specified %(random_number)s, but that does not exist. Did you mean %(another_random_number)s? " % locals())
		if qa_id:
			answer = random.choice(answers)
			prr.answer_a_question(qa_id = qa_id, answer = answer)
			if "Yep" in answer:
				prr.add_link(request_id = request_id, url = "http://www.postcode.io", description = "Report %(another_random_number)s" % locals(), user_id = 3)
			else:
				prr.close_request(request_id = request_id, reason = "Record does not exist.", user_id = 4)
		prr.assign_owner(request_id = request_id, reason = random.choice(reasons), email = random.choice(people))
		db_helpers.add_staff_participant(request_id = request_id, email = random.choice(people), reason = random.choice(reasons))
		

Esempio n. 4
0
 random_number = random.randrange(0, 901, 4)
 another_random_number = random.randrange(0, 901, 4)
 request_text = "%(request_type)s %(random_number)s" % locals()
 four_days_ago = (datetime.now() - timedelta(days=4))
 request_id, success = prr.make_request(text=request_text,
                                        department=request_department,
                                        date_received=four_days_ago,
                                        passed_spam_filter=True)
 if success:
     prr.add_note(
         request_id=request_id,
         text="We're working on this and will get back to you shortly.",
         user_id=1)
     qa_id = prr.ask_a_question(
         request_id=request_id,
         user_id=1,
         question=
         "You specified %(random_number)s, but that does not exist. Did you mean %(another_random_number)s? "
         % locals())
     if qa_id:
         answer = random.choice(answers)
         prr.answer_a_question(qa_id=qa_id, answer=answer)
         if "Yep" in answer:
             prr.add_link(request_id=request_id,
                          url="http://www.codeforamerica.org",
                          description="Report %(another_random_number)s" %
                          locals(),
                          user_id=1)
         else:
             prr.close_request(request_id=request_id,
                               reason="Record does not exist.",
                               user_id=1)