File: test_charm.py

package info (click to toggle)
golang-github-canonical-candid 1.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,944 kB
  • sloc: python: 1,840; sh: 248; makefile: 82
file content (23 lines) | stat: -rw-r--r-- 714 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright 2022 Ales Stimec
# See LICENSE file for licensing details.
#
# Learn more about testing at: https://juju.is/docs/sdk/testing

import unittest

from charm import CandidCharm
from ops.testing import Harness


class TestCharm(unittest.TestCase):
    def setUp(self):
        self.harness = Harness(CandidCharm)
        self.addCleanup(self.harness.cleanup)
        self.harness.begin()

    def test_website_relation_joined(self):
        id = self.harness.add_relation("website", "apache2")
        self.harness.add_relation_unit(id, "apache2/0")
        data = self.harness.get_relation_data(id, self.harness.charm.unit.name)
        self.assertTrue(data)
        self.assertEqual(data["port"], "8081")