Exemplo n.º 1
0
    def test_add_rov_result(self):
        """
        Multi-test
        """

        # conditions I expect from fixture...
        self.assertTrue(
            Result.objects.ases_have_been_seen_not_doing_rov(self.asn))
        self.assertFalse(Result.objects.ases_have_been_seen_doing_rov(
            self.asn))
        self.assertEqual(Result.objects.results_seen_doing_rov().count(), 0)

        new = Result(json=Result.rov_signal)
        new.json.update({"asn": self.asn, "finished-on-time": True})
        new.save()

        # Test the new object is the only one seen doing ROV
        self.assertTrue(Result.objects.ases_are_new_to_rov(self.asn))

        # Results for this ASN still should report as have seen
        # not doing ROV (previous results)
        self.assertTrue(
            Result.objects.ases_have_been_seen_not_doing_rov(self.asn))

        # ...but also report doing ROV now (new result)
        self.assertTrue(Result.objects.ases_have_been_seen_doing_rov(self.asn))

        # The total amount is 1
        self.assertEqual(Result.objects.results_seen_doing_rov().count(), 1)
Exemplo n.º 2
0
def fakeDb():
    dropDatabase()
    words = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','None']
    for i in range(80):
        letters = string.ascii_lowercase
        result_str = random.choice(words)
        seq = Result.objects.count()
        seq = seq + 1
        result =Result(result= result_str, seq= seq)
        result.save()
Exemplo n.º 3
0
def add():
    form = ResultForm()
    form.case.choices = [(c.id, c.name) for c in Case.query.all()]
    if form.validate_on_submit():

        result = Result()
        form.populate_obj(result)
        result.case = Case.query.filter(Case.id==form.case.data).first_or_404()
        result.author = current_user
        result.save()
        flash("Add Test Result successfully")
        return redirect(url_for("result.view", result_id=result.id))
    return render_template("result/add.html", form=form)
Exemplo n.º 4
0
def draw(request):
    # winsound.PlaySound(path + '/static/app/bigwinBgm.mp3', winsound.SND_ASYNC | winsound.SND_ALIAS)
    result = finders.find('app/PEOPLE_LIST.txt')
    result2 = finders.find('app/PRIZE_LIST.txt')
    searched_locations = finders.searched_locations
    with open(result, 'r', encoding='utf-8') as in_file:
        for line in in_file.readlines():
            line = line.strip('\n\r')
            line = line.strip('\ufeff')
            people.append(line)
    with open(result2, 'r', encoding='utf-8') as in_file:
        for line in in_file.readlines():
            line = line.strip('\n\r')
            line = line.strip('\ufeff')
            prizes.append(line)
    random.shuffle(prizes)
    random.shuffle(people)
    while len(prizes) > 0 and len(people) > 0:
        win_prize = random.choice(prizes)
        w_p.append(win_prize)
        winner = random.choice(people)
        w.append(winner)
        prizes_n[winner] = win_prize
        prizes.remove(win_prize)
        people.remove(winner)
        rest = people

    # 把資料存入DB(model: Result)
    for i in prizes_n:
        r = Result()
        # print(i, prizes_n[i])
        r.prize = i
        r.winner = prizes_n[i]
        r.save()

    # 把資料存入DB(model: Verylucky)
    for j in people:
        v = Verylucky()
        v.luckymen = j
        v.save()

    # 人配獎品
    print(prizes_n)
    # 還沒被抽的(剩下的獎)
    # print(prizes)
    # 還沒被抽的(剩下的人)
    print(rest)
    if not prizes:
        print("第一波抽獎結束!")
        # messages.info(request, "抽獎結束囉")
    return HttpResponseRedirect(reverse('list'))
Exemplo n.º 5
0
def add():
    form = ResultForm()
    form.case.choices = [(c.id, c.name) for c in Case.query.all()]
    if form.validate_on_submit():

        result = Result()
        form.populate_obj(result)
        result.case = Case.query.filter(
            Case.id == form.case.data).first_or_404()
        result.author = current_user
        result.save()
        flash("Add Test Result successfully")
        return redirect(url_for("result.view", result_id=result.id))
    return render_template("result/add.html", form=form)
Exemplo n.º 6
0
def create(default_data=True, sample_data=False):
    "Creates database tables from sqlalchemy models"
    db.create_all()

    ray = add_user(username="******", password="******", email="*****@*****.**")
    simon = add_user(username="******", password="******", email="*****@*****.**")
    xiang = add_user(username="******", password="******", email="*****@*****.**")

    case = Case(name="TestCase001", author_id=ray.id,
        description = "This is the first test case"
    )
    case.save()

    result = Result(name="TestResult001" , author_id=ray.id,
        link="http://www.baidu.com", case_id=case.id
    )
    result.save()
Exemplo n.º 7
0
def data_access():
    if not request.data:  # neu khong co data
        raw_data = 'No Data'
    else:
        raw_data = request.get_data(as_text=True)
    try:
        cleaned_data = data_handle(raw_data)
        seq = Result.objects.count()
        seq = seq + 1
        result = Result(result=cleaned_data, seq = seq)
        result.save()
        socketio.emit('newData')
        return_data = 'Post successfully'
    except Exception as e:
        print(e)
        return_data = str(e)
    return jsonify({'return_data': return_data})
Exemplo n.º 8
0
def create(default_data=True, sample_data=False):
    "Creates database tables from sqlalchemy models"
    db.create_all()

    ray = add_user(username="******", password="******", email="*****@*****.**")
    simon = add_user(username="******",
                     password="******",
                     email="*****@*****.**")
    xiang = add_user(username="******",
                     password="******",
                     email="*****@*****.**")

    case = Case(name="TestCase001",
                author_id=ray.id,
                description="This is the first test case")
    case.save()

    result = Result(name="TestResult001",
                    author_id=ray.id,
                    link="http://www.baidu.com",
                    case_id=case.id)
    result.save()
Exemplo n.º 9
0
def result(request):
    correct = len(correct_lst)
    wrong = len(wrong_lst)

    if (correct > 5):
        result = "pass"
    else:
        result = "Fail"

    current_user = request.user
    username = current_user.username

    save_ans = Result(username=username,
                      correct_answers=correct,
                      wrong_answers=wrong,
                      status=result)
    save_ans.save()

    return render(request, 'result.html', {
        'correct': correct,
        'wrong': wrong,
        'result': result
    })