Exemple #1
0
 def test_unmark_user_not_in_app(self):
     """
     It tests that health authority cannot mark a customer as healed
     if the customer is not registered as customer
     """
     message = HealthyServices.unmark_positive("*****@*****.**", "")
     assert message == "The customer is not registered"
Exemple #2
0
    def test_search_contacts_user_with_booking(self):
        """
        Searching for list of contacts of a covid-19 positive
        customer with bookings
        """

        owner = create_user_on_db(787436)
        assert owner is not None
        restaurant = create_restaurants_on_db("Pepperwood", user_id=owner.id)
        assert restaurant is not None

        customer1 = create_user_on_db(787437)
        assert customer1 is not None

        date_booking_1 = (get_today_midnight() -
                          timedelta(days=datetime.today().weekday()) +
                          timedelta(hours=13))
        books1 = create_random_booking(1, restaurant.id, customer1,
                                       date_booking_1, "*****@*****.**")

        assert len(books1) == 1

        # a new user that books in the same restaurant of the previous one
        customer2 = create_user_on_db(787438)
        assert customer2 is not None

        date_booking_2 = (get_today_midnight() -
                          timedelta(days=datetime.today().weekday()) +
                          timedelta(hours=13))
        books2 = create_random_booking(1, restaurant.id, customer2,
                                       date_booking_2, "*****@*****.**")
        assert len(books2) == 1

        # an user become covid19 positive
        positive = positive_with_user_id(customer1.id)
        assert positive is None
        message = HealthyServices.mark_positive(user_phone=customer1.phone)
        assert len(message) == 0

        q_already_positive = (db.session.query(Positive).filter_by(
            user_id=customer1.id, marked=True).first())
        assert q_already_positive is not None

        contacts = HealthyServices.search_contacts(customer1.id)
        assert len(contacts) == 1

        message = HealthyServices.unmark_positive("", customer1.phone)
        assert len(message) == 0

        del_user_on_db(customer1.id)
        del_user_on_db(customer2.id)
        del_restaurant_on_db(restaurant.id)
Exemple #3
0
    def test_unmark_user_not_positive(self):
        """
        It tests that health authority cannot mark a customer as healed
        if the customer is not covid-19 positive
        """
        user = create_user_on_db()
        assert user is not None
        assert user.role_id is 3

        message = HealthyServices.unmark_positive(user.email, user.phone)
        assert message == "User with email {} is not Covid-19 positive".format(
            user.email)

        delete_positive_with_user_id(user.id)
        del_user_on_db(user.id)
Exemple #4
0
def unmark_positive():
    form = SearchUserForm()
    if request.method == "POST":
        if form.validate_on_submit():
            email = form.email.data
            phone = form.phone.data
            message = HealthyServices.unmark_positive(email, phone)
            if message == "":
                return redirect("/")
            return render_template(
                "unmark_positive.html",
                _test="unmark_positive_page",
                form=form,
                message=message,
            )
    return render_template("unmark_positive.html", form=form)
Exemple #5
0
    def test_mark_positive_user_by_phone(self):
        """
        It tests that health authority can mark a customer as healed
        using only customer's phone number
        """
        user = create_user_on_db()
        assert user is not None
        assert user.role_id is 3
        positive = positive_with_user_id(user.id)
        assert positive is None
        message = HealthyServices.mark_positive("", user.phone)
        assert len(message) is 0

        message = HealthyServices.unmark_positive("", user.phone)
        assert len(message) is 0

        delete_was_positive_with_user_id(user.id)
        del_user_on_db(user.id)
Exemple #6
0
    def test_search_contacts_user_with_booking_only_one_user(self):
        """
        Searching for list of contacts of a covid-19 positive
        customer with bookings
        """

        user = get_user_with_email("*****@*****.**")

        positive = positive_with_user_id(user.id)
        assert positive is None
        message = HealthyServices.mark_positive("", user.phone)
        assert len(message) == 0

        contacts = HealthyServices.search_contacts(user.id)
        assert len(contacts) == 0

        message = HealthyServices.unmark_positive("", user.phone)
        assert len(message) == 0

        delete_was_positive_with_user_id(user.id)
Exemple #7
0
    def test_search_contacts_user_with_no_booking(self):
        """
        Searching for list of contacts of a covid-19 positive
        customer with no bookings
        """
        user = create_user_on_db()
        assert user is not None
        assert user.role_id is 3
        positive = positive_with_user_id(user.id)
        assert positive is None
        message = HealthyServices.mark_positive("", user.phone)
        assert len(message) is 0

        contacts = HealthyServices.search_contacts(user.id)
        assert len(contacts) is 0

        message = HealthyServices.unmark_positive("", user.phone)
        assert len(message) is 0

        delete_was_positive_with_user_id(user.id)
        del_user_on_db(user.id)