|
2 | 2 |
|
3 | 3 | from app.db.models.healthcare_provider import HealthcareProviderEntity |
4 | 4 | from app.db.repository.healthcare_provider import HealthcareProvidersRepository |
| 5 | +from app.models.ura_number import UraNumber |
5 | 6 |
|
6 | 7 |
|
7 | 8 | def test_add_one_success( |
@@ -79,23 +80,90 @@ def test_update_not_found( |
79 | 80 | assert result is None |
80 | 81 |
|
81 | 82 |
|
82 | | -def test_get_all( |
| 83 | +def test_get_many_should_return_all_records( |
83 | 84 | healthcare_provider_repository: HealthcareProvidersRepository, |
84 | 85 | healthcare_provider_entity: HealthcareProviderEntity, |
| 86 | + ura_number: UraNumber, |
85 | 87 | ) -> None: |
| 88 | + entity_2 = HealthcareProviderEntity( |
| 89 | + ura_number=ura_number.value, |
| 90 | + source_id="some_other_source_id", |
| 91 | + is_source=True, |
| 92 | + is_viewer=True, |
| 93 | + oin="some_oin", |
| 94 | + common_name="some_common_name", |
| 95 | + status="active", |
| 96 | + ) |
| 97 | + entity_3 = HealthcareProviderEntity( |
| 98 | + ura_number=UraNumber("00000125").value, |
| 99 | + source_id="antoher-source-id", |
| 100 | + is_source=True, |
| 101 | + is_viewer=False, |
| 102 | + oin="antoher-oin", |
| 103 | + common_name="fake-name", |
| 104 | + status="active", |
| 105 | + ) |
86 | 106 | with healthcare_provider_repository.db_session: |
87 | 107 | healthcare_provider_repository.add_one(healthcare_provider_entity) |
| 108 | + healthcare_provider_repository.add_one(entity_2) |
| 109 | + healthcare_provider_repository.add_one(entity_3) |
88 | 110 |
|
89 | | - result = healthcare_provider_repository.get_all() |
| 111 | + results = healthcare_provider_repository.get_many() |
90 | 112 |
|
91 | | - assert len(result) == 1 |
92 | | - assert result[0].id == healthcare_provider_entity.id |
| 113 | + assert len(results) == 3 |
93 | 114 |
|
94 | 115 |
|
95 | | -def test_get_all_returns_empty_list_when_no_data( |
| 116 | +def test_get_many_should_return_exact_as_per_query( |
96 | 117 | healthcare_provider_repository: HealthcareProvidersRepository, |
| 118 | + healthcare_provider_entity: HealthcareProviderEntity, |
| 119 | + ura_number: UraNumber, |
97 | 120 | ) -> None: |
| 121 | + entity_2 = HealthcareProviderEntity( |
| 122 | + ura_number=ura_number.value, |
| 123 | + source_id="some_other_source_id", |
| 124 | + is_source=True, |
| 125 | + is_viewer=True, |
| 126 | + oin="some_oin", |
| 127 | + common_name="some_common_name", |
| 128 | + status="active", |
| 129 | + ) |
| 130 | + entity_3 = HealthcareProviderEntity( |
| 131 | + ura_number=UraNumber("00000125").value, |
| 132 | + source_id="antoher-source-id", |
| 133 | + is_source=True, |
| 134 | + is_viewer=False, |
| 135 | + oin="antoher-oin", |
| 136 | + common_name="fake-name", |
| 137 | + status="active", |
| 138 | + ) |
98 | 139 | with healthcare_provider_repository.db_session: |
99 | | - result = healthcare_provider_repository.get_all() |
| 140 | + healthcare_provider_repository.add_one(healthcare_provider_entity) |
| 141 | + healthcare_provider_repository.add_one(entity_2) |
| 142 | + healthcare_provider_repository.add_one(entity_3) |
| 143 | + |
| 144 | + results = healthcare_provider_repository.get_many(ura_number=ura_number.value, oin="some_oin") |
| 145 | + |
| 146 | + assert len(results) == 2 |
| 147 | + |
| 148 | + results = healthcare_provider_repository.get_many( |
| 149 | + ura_number=ura_number.value, |
| 150 | + oin=healthcare_provider_entity.oin, |
| 151 | + source_id=healthcare_provider_entity.source_id, |
| 152 | + ) |
| 153 | + assert len(results) == 1 |
| 154 | + |
| 155 | + |
| 156 | +def test_many_should_return_empty_list_when_no_match_is_found( |
| 157 | + healthcare_provider_repository: HealthcareProvidersRepository, |
| 158 | + healthcare_provider_entity: HealthcareProviderEntity, |
| 159 | +) -> None: |
| 160 | + with healthcare_provider_repository.db_session: |
| 161 | + healthcare_provider_repository.add_one(healthcare_provider_entity) |
| 162 | + |
| 163 | + results = healthcare_provider_repository.get_many( |
| 164 | + ura_number="00000157", |
| 165 | + source_id="some-unknown-source", |
| 166 | + oin="000012345678910", |
| 167 | + ) |
100 | 168 |
|
101 | | - assert result == [] |
| 169 | + assert len(results) == 0 |
0 commit comments