Exemple #1
0
    def test_security(self, flask, models, current_user, url_for):
        data = {
            'securityCode': "code",
            'courseId': 12,
        }
        c1 = Mock(securityCode="code", id=12)
        current_user.courses = []
        flask.request.get_json.return_value = data
        models.Course.query.filter_by.return_value.first.return_value = c1

        views.securityCode().post()
        self.assertEqual(current_user.courses, [c1])
Exemple #2
0
    def test_security(self, flask, models, current_user, url_for):
        data = {
            'securityCode': "code",
            'courseId': 12,
        }
        c1 = Mock(securityCode="code", id=12)
        current_user.courses = []
        flask.request.get_json.return_value = data
        models.Course.query.filter_by.return_value.first.return_value = c1

        views.securityCode().post()
        self.assertEqual(current_user.courses, [c1])
Exemple #3
0
    def test_bad_code(self, flask, models, current_user, url_for):
        data = {
            'securityCode': "code",
            'courseId': 12,
        }
        c1 = Mock(securityCode="asdf", id=12)
        current_user.courses = []
        flask.request.get_json.return_value = data
        models.Course.query.filter_by.return_value.first.return_value = c1

        ret = views.securityCode().post()
        self.assertEqual(current_user.courses, [])
        self.assertEqual(ret, "Registration Code Incorrect")
Exemple #4
0
    def test_bad_code(self, flask, models, current_user, url_for):
        data = {
            'securityCode': "code",
            'courseId': 12,
        }
        c1 = Mock(securityCode="asdf", id=12)
        current_user.courses = []
        flask.request.get_json.return_value = data
        models.Course.query.filter_by.return_value.first.return_value = c1

        ret = views.securityCode().post()
        self.assertEqual(current_user.courses, [])
        self.assertEqual(ret, "Registration Code Incorrect")