File: test_repository.py

package info (click to toggle)
ppa-dev-tools 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,096 kB
  • sloc: python: 5,069; makefile: 3
file content (52 lines) | stat: -rw-r--r-- 1,455 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-

# Author:  Bryce Harrington <bryce@canonical.com>
#
# Copyright (C) 2023 Bryce W. Harrington
#
# Released under GNU GPLv2 or later, read the file 'LICENSE.GPLv2+' for
# more information.

"""Tests the Repository class as an interface to an Apt repository."""

import os
import sys

sys.path.insert(0, os.path.realpath(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")))

from ppa.repository import Repository
from ppa.suite import Suite


def test_object(tmp_path):
    """Checks that Repository objects can be instantiated."""
    repository = Repository(tmp_path)
    assert repository


def test_suites(tmp_path):
    """Checks getting all suites from the repository."""
    suites = ['a', 'b', 'b-0', 'b-1']
    for suite in suites:
        suite_dir = tmp_path / suite
        suite_dir.mkdir()

    repository = Repository(tmp_path)
    assert sorted(repository.suites.keys()) == sorted(suites)
    for suite in repository.suites.values():
        assert isinstance(suite, Suite)


def test_get_suite(tmp_path):
    """Checks getting a specific suite from the repository."""
    suites = ['a', 'b', 'b-0', 'b-1']
    for suite in suites:
        suite_dir = tmp_path / suite
        suite_dir.mkdir()

    repository = Repository(tmp_path)
    suite = repository.get_suite('b', '1')
    assert suite
    assert str(suite) == 'b-1'