Skip to content

Commit cb5a09b

Browse files
eoaksnessebastianvitterso
authored andcommitted
refactor: structure web to group files by feature
1 parent 568539e commit cb5a09b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+396
-201
lines changed

api/src/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
description_md = """
2020
### Description
21-
A RESTful API for handling todo items.
21+
A RESTful API for handling todos items.
2222
2323
Anyone in Equinor are authorized to run these calculations.
2424
* Click **Authorize** to login and start testing.

api/src/data_providers/get_repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919

2020
def get_todo_repository():
2121
mongo_database_client = MongoDatabaseClient(
22-
collection_name="todo", database_name=config.MONGODB_DATABASE, client=MONGO_CLIENT
22+
collection_name="todos", database_name=config.MONGODB_DATABASE, client=MONGO_CLIENT
2323
)
2424
return TodoRepository(client=mongo_database_client)

api/src/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
def test_client():
1818
mongo_test_client = mongomock.MongoClient()
1919
client = MongoDatabaseClient(
20-
collection_name="todo", database_name=mongo_test_client.TestDB.name, client=mongo_test_client
20+
collection_name="todos", database_name=mongo_test_client.TestDB.name, client=mongo_test_client
2121
)
2222
yield client
2323
client.wipe_db()

api/src/tests/unit/data_providers/repositories/test_TodoRepository.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,52 @@ def _setup_repository(self, test_client: MongoDatabaseClient):
1212
self.repository = TodoRepository(client=test_client)
1313

1414
def test_create(self):
15-
todo_item = TodoItem(id="1234", title="todo 1")
15+
todo_item = TodoItem(id="1234", title="todos 1")
1616
self.repository.create(todo_item)
1717
assert len(self.repository.get_all()) == 1
1818

1919
def test_create_already_exists(self):
20-
todo_item_1 = TodoItem(id="1234", title="todo 1")
20+
todo_item_1 = TodoItem(id="1234", title="todos 1")
2121
self.repository.create(todo_item_1)
2222
with pytest.raises(ValidationException):
23-
todo_item_2 = TodoItem(id="1234", title="todo 1")
23+
todo_item_2 = TodoItem(id="1234", title="todos 1")
2424
self.repository.create(todo_item_2)
2525

2626
def test_find_item_that_exist(self):
2727
documents = [
28-
{"_id": "81549300", "title": "todo 1"},
29-
{"_id": "1a2b", "title": "todo 2"},
30-
{"_id": "987321", "title": "todo 3"},
28+
{"_id": "81549300", "title": "todos 1"},
29+
{"_id": "1a2b", "title": "todos 2"},
30+
{"_id": "987321", "title": "todos 3"},
3131
{
3232
"_id": "987456",
33-
"title": "todo 4",
33+
"title": "todos 4",
3434
},
3535
]
3636
self.repository.client.insert_many(documents)
37-
todo_item = self.repository.find_one({"title": "todo 2"})
37+
todo_item = self.repository.find_one({"title": "todos 2"})
3838
assert todo_item.id == "1a2b"
3939

4040
def test_find_item_that_does_not_exist(self):
4141
documents = [
42-
{"_id": "81549300", "title": "todo 1"},
43-
{"_id": "1a2b", "title": "todo 2"},
44-
{"_id": "987321", "title": "todo 3"},
42+
{"_id": "81549300", "title": "todos 1"},
43+
{"_id": "1a2b", "title": "todos 2"},
44+
{"_id": "987321", "title": "todos 3"},
4545
{
4646
"_id": "987456",
47-
"title": "todo 4",
47+
"title": "todos 4",
4848
},
4949
]
5050
self.repository.client.insert_many(documents)
5151
assert self.repository.find_one({"_id": "invalid"}) is None
5252

5353
def test_get_item_that_does_exist(self):
5454
documents = [
55-
{"_id": "81549300", "title": "todo 1"},
56-
{"_id": "1a2b", "title": "todo 2"},
57-
{"_id": "987321", "title": "todo 3"},
55+
{"_id": "81549300", "title": "todos 1"},
56+
{"_id": "1a2b", "title": "todos 2"},
57+
{"_id": "987321", "title": "todos 3"},
5858
{
5959
"_id": "987456",
60-
"title": "todo 4",
60+
"title": "todos 4",
6161
},
6262
]
6363
self.repository.client.insert_many(documents)
@@ -66,20 +66,20 @@ def test_get_item_that_does_exist(self):
6666

6767
def test_get_item_that_does_not_exist(self):
6868
documents = [
69-
{"_id": "81549300", "title": "todo 1"},
70-
{"_id": "1a2b", "title": "todo 2"},
71-
{"_id": "987321", "title": "todo 3"},
69+
{"_id": "81549300", "title": "todos 1"},
70+
{"_id": "1a2b", "title": "todos 2"},
71+
{"_id": "987321", "title": "todos 3"},
7272
{
7373
"_id": "987456",
74-
"title": "todo 4",
74+
"title": "todos 4",
7575
},
7676
]
7777
self.repository.client.insert_many(documents)
7878
with pytest.raises(NotFoundException):
7979
self.repository.get("invalid")
8080

8181
def test_update_item(self):
82-
todo_item = TodoItem(id="81549300", title="todo 1")
82+
todo_item = TodoItem(id="81549300", title="todos 1")
8383
self.repository.create(todo_item)
8484
todo_item_to_update = TodoItem(id="81549300", title="Updated title")
8585
self.repository.update(todo_item=todo_item_to_update)
@@ -91,15 +91,15 @@ def test_update_item_that_does_not_exist(self):
9191
self.repository.update(todo_item_to_update)
9292

9393
def test_delete(self):
94-
documents = [{"_id": "81549300", "title": "todo 1"}, {"_id": "1a2b", "title": "todo 2"}]
94+
documents = [{"_id": "81549300", "title": "todos 1"}, {"_id": "1a2b", "title": "todos 2"}]
9595
self.repository.client.insert_many(documents)
9696
assert len(self.repository.get_all()) == 2
9797
self.repository.delete("81549300")
9898
assert len(self.repository.get_all()) == 1
9999
assert self.repository.get_all() == [self.repository.get("1a2b")]
100100

101101
def test_delete_all(self):
102-
documents = [{"_id": "81549300", "title": "todo 1"}, {"_id": "1a2b", "title": "todo 2"}]
102+
documents = [{"_id": "81549300", "title": "todos 1"}, {"_id": "1a2b", "title": "todos 2"}]
103103
self.repository.client.insert_many(documents)
104104
assert len(self.repository.get_all()) == 2
105105
self.repository.delete_all()

api/src/tests/unit/features/todo/use_cases/test_delete_todo_by_id.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ def test_delete_todo_should_return_not_success(todo_repository: TodoRepositoryIn
2020
id = "unkown"
2121
with pytest.raises(NotFoundException):
2222
delete_todo_use_case(id=id, todo_repository=todo_repository)
23+
assert error.message == "The todos item you specified does not exist."

api/src/tests/unit/features/todo/use_cases/test_get_todo_by_id.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ def test_get_todo_by_id_should_throw_todo_not_found_error(todo_repository: TodoR
2222
id = "unknown"
2323
with pytest.raises(NotFoundException):
2424
get_todo_by_id_use_case(id, todo_repository=todo_repository)
25+
assert error.message == "The todos item you specified does not exist."

api/src/tests/yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+

web/.pnp.cjs

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)