Skip to content

Commit 336eb75

Browse files
author
EliuX
committed
Apply requested changes
1 parent bafb867 commit 336eb75

File tree

13 files changed

+8
-78
lines changed

13 files changed

+8
-78
lines changed

tests/conftest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010

1111
@pytest.fixture(scope='session', params=CONFIGURATIONS)
1212
def app(request: FixtureRequest) -> Flask:
13-
"""An instance of the app for tests"""
1413
return create_app("time_tracker_api.config.%s" % request.param)
1514

1615

1716
@pytest.fixture
1817
def client(app: Flask) -> FlaskClient:
19-
"""A test client for the app."""
2018
with app.test_client() as c:
2119
return c
2220

tests/projects/projects_namespace_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
def test_list_all_elements(client: FlaskClient, mocker: MockFixture):
7-
"""Should return all elements in a list"""
87
from time_tracker_api.projects.projects_namespace import project_dao
98
repository_find_all_mock = mocker.patch.object(project_dao.repository, 'find_all', return_value=[])
109

tests/resources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from time_tracker_api.sql_repository import db, SQLAuditedModel
1+
from time_tracker_api.sql_repository import db, AuditedSQLModel
22

33

4-
class PersonSQLModel(db.Model, SQLAuditedModel):
4+
class PersonSQLModel(db.Model, AuditedSQLModel):
55
__tablename__ = 'tests'
66
id = db.Column(db.Integer, primary_key=True)
77
name = db.Column(db.String(80), unique=False, nullable=False)

tests/smoke_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
def test_app_exists(app):
2-
"""Does app exists"""
32
assert app is not None

tests/sql_repository_test.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
def test_create(sql_repository):
10-
"""Should create a new Entry"""
1110
global sample_element
1211
sample_element = dict(name=fake.name(),
1312
email=fake.safe_email(),
@@ -26,7 +25,6 @@ def test_create(sql_repository):
2625

2726

2827
def test_find(sql_repository):
29-
"""Should find created element"""
3028
existing_element = existing_elements_registry[0]
3129

3230
found_element = sql_repository.find(existing_element.id)
@@ -36,7 +34,6 @@ def test_find(sql_repository):
3634

3735

3836
def test_update(sql_repository):
39-
"""Updates an existing element"""
4037
existing_element = existing_elements_registry[0]
4138

4239
updated_element = sql_repository.update(existing_element.id,
@@ -52,7 +49,6 @@ def test_update(sql_repository):
5249

5350

5451
def test_find_all(sql_repository):
55-
"""Find all existing elements"""
5652
existing_elements = sql_repository.find_all()
5753

5854
assert all(e in existing_elements_registry for e in existing_elements)
@@ -78,7 +74,6 @@ def test_find_all_that_contains_property_with_string(sql_repository):
7874

7975

8076
def test_delete_existing_element(sql_repository):
81-
"""Should delete created element"""
8277
existing_element = existing_elements_registry[0]
8378

8479
result = sql_repository.remove(existing_element.id)

time_tracker_api/activities/activities_namespace.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@ class Activities(Resource):
4646
@ns.doc('list_activities')
4747
@ns.marshal_list_with(activity, code=200)
4848
def get(self):
49-
"""List all available activities"""
5049
return []
5150

5251
@ns.doc('create_activity')
5352
@ns.expect(activity_input)
5453
@ns.marshal_with(activity, code=201)
5554
@ns.response(400, 'Invalid format of the attributes of the activity.')
5655
def post(self):
57-
"""Create a single activity"""
5856
return ns.payload, 201
5957

6058

@@ -65,19 +63,16 @@ class Activity(Resource):
6563
@ns.doc('get_activity')
6664
@ns.marshal_with(activity)
6765
def get(self, id):
68-
"""Retrieve all the data of a single activity"""
6966
return {}
7067

7168
@ns.doc('delete_activity')
7269
@ns.response(204, 'The activity was deleted successfully (No content is returned)')
7370
def delete(self, id):
74-
"""Deletes a activity"""
7571
return None, 204
7672

7773
@ns.doc('put_activity')
7874
@ns.response(400, 'Invalid format of the attributes of the activity.')
7975
@ns.expect(activity_input)
8076
@ns.marshal_with(activity)
8177
def put(self, id):
82-
"""Updates an activity"""
8378
return ns.payload

time_tracker_api/database.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,18 @@ def delete(self, id):
4242
class Seeder(abc.ABC):
4343
@abc.abstractmethod
4444
def run(self):
45-
"""Provision database"""
4645
raise NotImplementedError
4746

4847
@abc.abstractmethod
4948
def fresh(self):
50-
"""will drop all tables and seed again the database"""
5149
raise NotImplementedError
5250

5351
def __call__(self, *args, **kwargs):
5452
self.run()
5553

5654

5755
class DatabaseModel:
58-
"""
59-
Represents a model of a particular database,
60-
e.g. SQL Model
61-
"""
62-
6356
def to_dto(self):
64-
"""Override this in case you need a DTO instead of a model"""
6557
return self
6658

6759

@@ -74,10 +66,6 @@ def convert_if_necessary(result):
7466
return result
7567

7668
def to_dto(*args, **kw):
77-
"""
78-
Decorator that converts any result that is a
79-
DatabaseModel into its correspondent dto.
80-
"""
8169
result = f(*args, **kw)
8270
return convert_if_necessary(result)
8371

@@ -88,7 +76,6 @@ def to_dto(*args, **kw):
8876

8977

9078
def init_app(app: Flask) -> None:
91-
"""Make the app ready to use the database"""
9279
database_strategy = app.config['DATABASE']
9380
with app.app_context():
9481
globals()["use_%s" % database_strategy.name.lower()](app)

time_tracker_api/errors.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

time_tracker_api/projects/projects_model.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from flask import Flask
44

55
from time_tracker_api.database import DATABASE_TYPE, CRUDDao
6-
from time_tracker_api.sql_repository import SQLCRUDDao, SQLAuditedModel, SQLModel
6+
from time_tracker_api.sql_repository import SQLCRUDDao, AuditedSQLModel, SQLModel
77

88

99
class PROJECT_TYPE(enum.Enum):
@@ -20,11 +20,10 @@ class ProjectDao(CRUDDao):
2020

2121

2222
def create_dao(app: Flask) -> ProjectDao:
23-
"""This will construct the dao based on the chosen DATABASE"""
2423
if app.config['DATABASE'] == DATABASE_TYPE.SQL:
2524
from time_tracker_api.sql_repository import db
2625

27-
class ProjectSQLModel(db.Model, SQLModel, SQLAuditedModel):
26+
class ProjectSQLModel(db.Model, SQLModel, AuditedSQLModel):
2827
__tablename__ = 'projects'
2928
id = db.Column(db.Integer, primary_key=True)
3029
name = db.Column(db.String(50), unique=True, nullable=False)

time_tracker_api/projects/projects_namespace.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class Projects(Resource):
6565
@ns.doc('list_projects')
6666
@ns.marshal_list_with(project, code=200)
6767
def get(self):
68-
"""List all projects"""
6968
return project_dao.get_all(), 200
7069

7170
@ns.doc('create_project')
@@ -74,7 +73,6 @@ def get(self):
7473
@ns.expect(project_input)
7574
@ns.marshal_with(project, code=201)
7675
def post(self):
77-
"""Create a project"""
7876
return project_dao.create(ns.payload), 201
7977

8078

@@ -90,7 +88,6 @@ class Project(Resource):
9088
@ns.response(422, 'The id has an invalid format')
9189
@ns.marshal_with(project)
9290
def get(self, id):
93-
"""Retrieve a project"""
9491
return project_dao.get(id)
9592

9693
@ns.doc('update_project')
@@ -99,13 +96,11 @@ def get(self, id):
9996
@ns.expect(project_input)
10097
@ns.marshal_with(project)
10198
def put(self, id):
102-
"""Updates a project"""
10399
return project_dao.update(id, ns.payload)
104100

105101
@ns.doc('delete_project')
106102
@ns.response(204, 'Project deleted successfully')
107103
@ns.response(422, 'The id has an invalid format')
108104
def delete(self, id):
109-
"""Deletes a project"""
110105
project_dao.delete(id)
111106
return None, 204

0 commit comments

Comments
 (0)