Ejemplo n.º 1
0
    def test_load_question_from_index(self):
        question = Question(pub_date=timezone.now() -
                            datetime.timedelta(days=3),
                            question_text='Foo Bar')
        question.save()

        self.selenium.get('%s%s' %
                          (self.live_server_url, reverse('polls:index')))
        self.selenium.find_element_by_css_selector(
            'a[data-question-id="{}"]'.format(question.id)).click()
        # Wait until the response is received
        WebDriverWait(
            self.selenium,
            2).until(lambda driver: driver.find_element_by_tag_name('body'))
Ejemplo n.º 2
0
def create(post_data):
    question_text = post_data.get("question_text")
    sample_input = post_data.get("sample_input")
    sample_output = post_data.get("sample_output")
    explanation = post_data.get("explanation")
    question_type = post_data.get("question_type")
    q = Question(question_id=shortuuid.uuid(),
                 question_text=question_text,
                 sample_input=sample_input,
                 sample_output=sample_output,
                 explanation=explanation,
                 question_type=question_type)
    try:
        obj = q.save()
        log.debug("## Question Added: ID {}".format(obj.question_id))
        return_dict = obj.to_dict()
        return return_dict
    except Exception as e:
        log.error(e)
        return response.failure({"status": "Failure occurred."})
Ejemplo n.º 3
0
def create_question(question_text, days):
    time = timezone.now() + datetime.timedelta(days=days)
    q = Question(pub_date=time, question_text=question_text)
    q.save()
    return q