Esempio n. 1
0
    def test_user_empty_field(self):
        tested_app = self.app.test_client()
        tested_app.set_app(self.app)

        form = {
            "email": "*****@*****.**",
            "firstname": "firstname",
            "lastname": "lastname",
            "password": "******",
            "dateofbirth": "01/01/1970",
            "telephone": "1234567890",
            "password_repeat": "password",
            "ssn": None,
            'is_operator': False,
            'is_admin': False,
            'is_health_authority': False
        }

        fields = [
            "email", "firstname", "lastname", "password", "dateofbirth",
            "telephone", "password_repeat"
        ]

        for f in fields:
            tested_form = form
            tested_form[f] = ""

            reply = send_registration_form(tested_app, '/create_user', form)

            self.assertEqual(reply["status_code"], 200, msg=reply)
Esempio n. 2
0
    def test_user_good_form(self):
        tested_app = self.app.test_client()
        tested_app.set_app(self.app)

        form = {
            'firstname': 'GoodUser1',
            'lastname': 'Lastname',
            'email': '*****@*****.**',
            'password': '******',
            'phone': '3566289713',
            'rest_id': None,
            'is_operator': False,
            'ssn': 'OPERATORE2SDFGYJ',
            'is_admin': False,
            'dateofbirth': '1998-10-10',
            'is_health_authority': False,
            'is_positive': False
        }

        reply = send_registration_form(tested_app, '/create_user', form)

        self.assertEqual(reply["status_code"], 200, msg=reply)

        tested_app.t_post('/login',
                          data={
                              "email": "*****@*****.**",
                              "password": "******"
                          })
        resp = tested_app.get('/users')
        print(resp.get_json())
Esempio n. 3
0
    def test_user_with_ssn_form(self):
        tested_app = self.app.test_client()
        tested_app.set_app(self.app)

        form = {
            "email": "*****@*****.**",
            "firstname": "Tester",
            "lastname": "SSN",
            "password": "******",
            "dateofbirth": "01/01/1970",
            "telephone": "0123456789001",
            "ssn": "0192837465HGTHUA",
            'is_operator': False,
            'is_admin': False,
            'is_health_authority': False
        }

        reply = send_registration_form(tested_app, '/create_user', form)

        self.assertEqual(reply["status_code"], 200, msg=reply)
Esempio n. 4
0
    def test_user_regood_form(self):
        tested_app = self.app.test_client()
        tested_app.set_app(self.app)

        form = {
            "email": "*****@*****.**",
            "firstname": "Tester",
            "lastname": "GF",
            "password": "******",
            "password_repeat": "42",
            "dateofbirth": "01/01/1970",
            "telephone": "01234567890",
            "ssn": None,
            'is_operator': False,
            'is_admin': False,
            'is_health_authority': False
        }

        reply = send_registration_form(tested_app, '/create_user', form)

        self.assertEqual(reply["status_code"], 400, msg=reply)
Esempio n. 5
0
    def test_operator_existing_email(self):
        tested_app = self.app.test_client()
        tested_app.set_app(self.app)

        form = {
            "email": "*****@*****.**",
            "firstname": "Tester",
            "lastname": "OEE",
            "password": "******",
            "password_repeat": "42",
            "dateofbirth": "01/01/1970",
            "telephone": "1234567890",
            'ssn': None,
            'is_operator': True,
            'is_admin': False,
            'is_health_authority': False
        }

        reply = send_registration_form(tested_app, '/create_operator', form)

        self.assertEqual(reply["status_code"], 400, msg=reply)
Esempio n. 6
0
    def test_user_wrong_dateofbirth(self):
        tested_app = self.app.test_client()
        tested_app.set_app(self.app)

        form = {
            "email": "*****@*****.**",
            "firstname": "Tester",
            "lastname": "DoB",
            "password": "******",
            "password_repeat": "42",
            "dateofbirth": "thisisadateofbirth",
            "telephone": "1234567890",
            "ssn": None,
            'is_operator': False,
            'is_admin': False,
            'is_health_authority': False
        }

        reply = send_registration_form(tested_app, '/create_user', form)

        self.assertEqual(reply["status_code"], 200, msg=reply)
Esempio n. 7
0
    def test_user_existing_name_surname(self):
        tested_app = self.app.test_client()
        tested_app.set_app(self.app)

        form = {
            "email": "*****@*****.**",
            "firstname": "Daniele",
            "lastname": "Verdi",
            "password": "******",
            "password_repeat": "42",
            "dateofbirth": "01/01/1970",
            "telephone": "12345678902",
            "ssn": None,
            'is_operator': False,
            'is_admin': False,
            'is_health_authority': False
        }

        reply = send_registration_form(tested_app, '/create_user', form)

        self.assertEqual(reply["status_code"], 302, msg=reply)
Esempio n. 8
0
    def test_login2(self):
        # Now in your tests, you can request a test client the same way
        # that you normally do:
        tested_app = app.test_client()
        tested_app.set_app(app)
        # But now, `client` is an instance of the class we defined!

        form = {
            "email":"*****@*****.**",
            "firstname":"Tester",
            "lastname":"OGF",
            "password":"******",
            "password_repeat":"42",
            "dateofbirth":"01/01/1970",
            "telephone":"12345678900",
            "ssn": "",
        }

        reply = send_registration_form(tested_app,'/create_operator', form)
        self.assertEqual(
            reply["status_code"],
            302)
Esempio n. 9
0
    def test_operator_good_form(self):
        tested_app = self.app.test_client()
        tested_app.set_app(self.app)

        form = {
            'firstname': 'GoodUser',
            'lastname': 'Lastname',
            'email': '*****@*****.**',
            'password': '******',
            'phone': '3576289713',
            'rest_id': None,
            'is_operator': True,
            'ssn': 'OPERATOREASDFGHJ',
            'is_admin': False,
            'dateofbirth': '1998-10-10',
            'is_health_authority': False,
            'is_positive': False
        }

        reply = send_registration_form(tested_app, '/create_operator', form)

        self.assertEqual(reply["status_code"], 200, msg=reply)