Code Coverage

Cobertura Coverage Report > n2vc.tests.unit >

test_definitions.py

Trend

File Coverage summary

NameClassesLinesConditionals
test_definitions.py
100%
1/1
100%
23/23
100%
0/0

Coverage Breakdown by Class

NameLinesConditionals
test_definitions.py
100%
23/23
N/A

Source

n2vc/tests/unit/test_definitions.py
1 # Copyright 2021 Canonical Ltd.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #     Unless required by applicable law or agreed to in writing, software
10 #     distributed under the License is distributed on an "AS IS" BASIS,
11 #     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #     See the License for the specific language governing permissions and
13 #     limitations under the License.
14
15 1 from typing import NoReturn
16 1 from unittest import TestCase
17 1 from unittest.mock import patch
18
19 1 from n2vc.definitions import Offer, RelationEndpoint
20
21
22 1 @patch("n2vc.definitions.get_ee_id_components")
23 1 class RelationEndpointTest(TestCase):
24 1     def test_success(self, mock_get_ee_id_components) -> NoReturn:
25 1         mock_get_ee_id_components.return_value = ("model", "application", "machine_id")
26 1         relation_endpoint = RelationEndpoint(
27             "model.application.machine_id",
28             "vca",
29             "endpoint",
30         )
31 1         self.assertEqual(relation_endpoint.model_name, "model")
32 1         self.assertEqual(relation_endpoint.application_name, "application")
33 1         self.assertEqual(relation_endpoint.vca_id, "vca")
34 1         self.assertEqual(relation_endpoint.endpoint, "application:endpoint")
35 1         self.assertEqual(relation_endpoint.endpoint_name, "endpoint")
36 1         self.assertEqual(
37             str(relation_endpoint), "application:endpoint (model: model, vca: vca)"
38         )
39
40
41 1 class OfferTest(TestCase):
42 1     def test_success(self) -> NoReturn:
43 1         url = "admin/test-model.my-offer"
44 1         offer = Offer(url)
45 1         self.assertEqual(offer.model_name, "test-model")
46 1         self.assertEqual(offer.name, "my-offer")
47 1         self.assertEqual(offer.username, "admin")
48 1         self.assertEqual(offer.url, url)