def setUpClass(cls):
        cls.client = get_test_client()
        cls.client_not_logged_in = get_test_client()

        user = create_mock_user(password='******')
        cls.client.post('/auth/login', json={'username': user.username, 'password': '******'})
        cls.courses = [create_mock_course(), create_mock_course()]

        return super().setUpClass()
Exemple #2
0
def client():
    """
    Login via API, return client. Login information, by default, will be taken from
    environment variables, so ensure those are set properly before testing. Alternatively,
    to force a particular user, adjust input arguments as necessary.
    """
    return get_test_client()
    def setUpClass(cls):
        cls.user = create_mock_user(password='******')
        people = [
            create_mock_user(category='professor'),
            create_mock_user(), cls.user
        ]
        cls.enrollments = [
            create_mock_enrollment(people=people),
            create_mock_enrollment(people=people),
            create_mock_enrollment()
        ]
        cls.threads = [
            create_mock_discussion_thread(enrollment=cls.enrollments[0]),
            create_mock_discussion_thread(enrollment=cls.enrollments[0]),
            create_mock_discussion_thread(enrollment=cls.enrollments[1]),
        ]

        cls.client = get_test_client()
        resp = cls.client.post('/auth/login',
                               json={
                                   'username': cls.user.username,
                                   'password': '******'
                               })
        resp.raise_for_status()

        return super().setUpClass()
Exemple #4
0
def client2():
    api_token = os.environ.get('BLACKFYNN_API_TOKEN2')
    api_secret = os.environ.get('BLACKFYNN_API_SECRET2')
    assert api_token != "", "Must define BLACKFYNN_API_TOKEN2"
    assert api_secret != "", "Must define BLACKFYNN_API_SECRET2"

    bf = get_test_client(api_token=api_token, api_secret=api_secret)
    return bf
    def setUpClass(cls):
        cls.user = create_mock_user(password='******')
        cls.profiles = [
            create_mock_user_profile(user=cls.user),
            create_mock_user_profile()
        ]

        cls.test_client = get_test_client()
        resp = cls.test_client.post('/auth/login',
                                    json={
                                        'username': cls.user.username,
                                        'password': '******'
                                    })
        resp.raise_for_status()

        return super().setUpClass()
    def setUpClass(cls):
        cls.users = [create_mock_user(password='******'), create_mock_user()]
        cls.threads = [
            create_mock_discussion_thread(),
            create_mock_discussion_thread()
        ]

        cls.client = get_test_client()
        resp = cls.client.post('/auth/login',
                               json={
                                   'username': cls.users[0].username,
                                   'password': '******'
                               })
        resp.raise_for_status()

        return super().setUpClass()
 def test_require_auth(self):
     client_not_logged_in = get_test_client()
     resp = client_not_logged_in.get(f'/profiles/{self.user.guid}')
     assert resp.status_code == 403
 def test_1_require_auth(self):
     client_not_logged_in = get_test_client()
     resp = client_not_logged_in.get('/enrollments/')
     assert resp.status_code == 403
 def setUpClass(cls):
     cls.client = get_test_client()
     cls.user = create_mock_user(username='******', password='******');
     return super().setUpClass()
 def test_require_auth(self):
     client_not_logged_in = get_test_client()
     assert client_not_logged_in.get('/discussions/').status_code == 403