API - init user account activation
This commit is contained in:
@ -887,3 +887,13 @@ class TestGetRecords(ApiTestCaseMixin):
|
||||
assert workout_4_short_id == data['data']['records'][7]['workout_id']
|
||||
assert 'MS' == data['data']['records'][7]['record_type']
|
||||
assert 12.0 == data['data']['records'][7]['value']
|
||||
|
||||
def test_it_returns_error_if_user_is_not_authenticated(
|
||||
self,
|
||||
app: Flask,
|
||||
) -> None:
|
||||
client = app.test_client()
|
||||
|
||||
response = client.get('/api/records')
|
||||
|
||||
self.assert_401(response)
|
||||
|
@ -45,6 +45,16 @@ expected_sport_1_cycling_inactive_admin_result['has_workouts'] = False
|
||||
|
||||
|
||||
class TestGetSports(ApiTestCaseMixin):
|
||||
def test_it_returns_error_if_user_is_not_authenticated(
|
||||
self,
|
||||
app: Flask,
|
||||
) -> None:
|
||||
client = app.test_client()
|
||||
|
||||
response = client.get('/api/sports')
|
||||
|
||||
self.assert_401(response)
|
||||
|
||||
def test_it_gets_all_sports(
|
||||
self,
|
||||
app: Flask,
|
||||
|
@ -9,6 +9,17 @@ from ..mixins import ApiTestCaseMixin
|
||||
|
||||
|
||||
class TestGetStatsByTime(ApiTestCaseMixin):
|
||||
def test_it_returns_error_if_user_is_not_authenticated(
|
||||
self, app: Flask, user_1: User
|
||||
) -> None:
|
||||
client = app.test_client()
|
||||
|
||||
response = client.get(
|
||||
f'/api/stats/{user_1.username}/by_time',
|
||||
)
|
||||
|
||||
self.assert_401(response)
|
||||
|
||||
def test_it_gets_no_stats_when_user_has_no_workouts(
|
||||
self, app: Flask, user_1: User
|
||||
) -> None:
|
||||
@ -853,6 +864,17 @@ class TestGetStatsByTime(ApiTestCaseMixin):
|
||||
|
||||
|
||||
class TestGetStatsBySport(ApiTestCaseMixin):
|
||||
def test_it_returns_error_if_user_is_not_authenticated(
|
||||
self, app: Flask, user_1: User
|
||||
) -> None:
|
||||
client = app.test_client()
|
||||
|
||||
response = client.get(
|
||||
f'/api/stats/{user_1.username}/by_sport',
|
||||
)
|
||||
|
||||
self.assert_401(response)
|
||||
|
||||
def test_it_gets_stats_by_sport(
|
||||
self,
|
||||
app: Flask,
|
||||
@ -987,6 +1009,15 @@ class TestGetStatsBySport(ApiTestCaseMixin):
|
||||
|
||||
|
||||
class TestGetAllStats(ApiTestCaseMixin):
|
||||
def test_it_returns_error_if_user_is_not_authenticated(
|
||||
self, app: Flask, user_1: User
|
||||
) -> None:
|
||||
client = app.test_client()
|
||||
|
||||
response = client.get('/api/stats/all')
|
||||
|
||||
self.assert_401(response)
|
||||
|
||||
def test_it_returns_all_stats_when_users_have_no_workouts(
|
||||
self, app: Flask, user_1_admin: User, user_2: User
|
||||
) -> None:
|
||||
|
@ -12,6 +12,15 @@ from .utils import get_random_short_id
|
||||
|
||||
|
||||
class TestGetWorkouts(ApiTestCaseMixin):
|
||||
def test_it_returns_error_if_user_is_not_authenticated(
|
||||
self, app: Flask
|
||||
) -> None:
|
||||
client = app.test_client()
|
||||
|
||||
response = client.get('/api/workouts')
|
||||
|
||||
self.assert_401(response)
|
||||
|
||||
def test_it_gets_all_workouts_for_authenticated_user(
|
||||
self,
|
||||
app: Flask,
|
||||
|
@ -206,6 +206,22 @@ def assert_workout_data_wo_gpx(data: Dict) -> None:
|
||||
|
||||
|
||||
class TestPostWorkoutWithGpx(ApiTestCaseMixin, CallArgsMixin):
|
||||
def test_it_returns_error_if_user_is_not_authenticated(
|
||||
self, app: Flask, sport_1_cycling: Sport, gpx_file: str
|
||||
) -> None:
|
||||
client = app.test_client()
|
||||
|
||||
response = client.post(
|
||||
'/api/workouts',
|
||||
data=dict(
|
||||
file=(BytesIO(str.encode(gpx_file)), 'example.gpx'),
|
||||
data='{"sport_id": 1}',
|
||||
),
|
||||
headers=dict(content_type='multipart/form-data'),
|
||||
)
|
||||
|
||||
self.assert_401(response)
|
||||
|
||||
def test_it_adds_an_workout_with_gpx_file(
|
||||
self, app: Flask, user_1: User, sport_1_cycling: Sport, gpx_file: str
|
||||
) -> None:
|
||||
@ -569,6 +585,27 @@ class TestPostWorkoutWithGpx(ApiTestCaseMixin, CallArgsMixin):
|
||||
|
||||
|
||||
class TestPostWorkoutWithoutGpx(ApiTestCaseMixin):
|
||||
def test_it_returns_error_if_user_is_not_authenticated(
|
||||
self, app: Flask, sport_1_cycling: Sport, gpx_file: str
|
||||
) -> None:
|
||||
client = app.test_client()
|
||||
|
||||
response = client.post(
|
||||
'/api/workouts/no_gpx',
|
||||
content_type='application/json',
|
||||
data=json.dumps(
|
||||
dict(
|
||||
sport_id=1,
|
||||
duration=3600,
|
||||
workout_date='2018-05-15 14:05',
|
||||
distance=10,
|
||||
)
|
||||
),
|
||||
headers=dict(content_type='multipart/form-data'),
|
||||
)
|
||||
|
||||
self.assert_401(response)
|
||||
|
||||
def test_it_adds_an_workout_without_gpx(
|
||||
self, app: Flask, user_1: User, sport_1_cycling: Sport
|
||||
) -> None:
|
||||
|
Reference in New Issue
Block a user