gc-server3 17 órája
szülő
commit
6f5f098ab7

+ 1 - 0
.gitignore

@@ -20,3 +20,4 @@ mailserver/temp/
 datev/export
 sandbox/sql
 awork/projects.json
+temp/

+ 5 - 0
pyproject.toml

@@ -39,3 +39,8 @@ dependencies = [
     "uptime>=3.0.1",
     "xlrd>=2.0.1",
 ]
+
+[tool.pytest.ini_options]
+addopts = [
+    "--import-mode=importlib",
+]

+ 0 - 46
sandbox/gilded_rose/gilded_rose.py

@@ -1,46 +0,0 @@
-# -*- coding: utf-8 -*-
-
-class GildedRose(object):
-
-    def __init__(self, items):
-        self.items = items
-
-    def update_quality(self):
-        for item in self.items:
-            if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert":
-                if item.quality > 0:
-                    if item.name != "Sulfuras, Hand of Ragnaros":
-                        item.quality = item.quality - 1
-            else:
-                if item.quality < 50:
-                    item.quality = item.quality + 1
-                    if item.name == "Backstage passes to a TAFKAL80ETC concert":
-                        if item.sell_in < 11:
-                            if item.quality < 50:
-                                item.quality = item.quality + 1
-                        if item.sell_in < 6:
-                            if item.quality < 50:
-                                item.quality = item.quality + 1
-            if item.name != "Sulfuras, Hand of Ragnaros":
-                item.sell_in = item.sell_in - 1
-            if item.sell_in < 0:
-                if item.name != "Aged Brie":
-                    if item.name != "Backstage passes to a TAFKAL80ETC concert":
-                        if item.quality > 0:
-                            if item.name != "Sulfuras, Hand of Ragnaros":
-                                item.quality = item.quality - 1
-                    else:
-                        item.quality = item.quality - item.quality
-                else:
-                    if item.quality < 50:
-                        item.quality = item.quality + 1
-
-
-class Item:
-    def __init__(self, name, sell_in, quality):
-        self.name = name
-        self.sell_in = sell_in
-        self.quality = quality
-
-    def __repr__(self):
-        return "%s, %s, %s" % (self.name, self.sell_in, self.quality)

+ 0 - 8
sandbox/gilded_rose/test_gilded_rose.py

@@ -1,8 +0,0 @@
-from gilded_rose import GildedRose, Item
-
-
-def test_foo():
-    items = [Item("foo", 0, 0)]
-    gilded_rose = GildedRose(items)
-    gilded_rose.update_quality()
-    assert "fixme" == items[0].name

+ 0 - 30
sandbox/gilded_rose/texttest_fixture.py

@@ -1,30 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import print_function
-
-from gilded_rose import *
-
-if __name__ == "__main__":
-    print ("OMGHAI!")
-    items = [
-             Item(name="+5 Dexterity Vest", sell_in=10, quality=20),
-             Item(name="Aged Brie", sell_in=2, quality=0),
-             Item(name="Elixir of the Mongoose", sell_in=5, quality=7),
-             Item(name="Sulfuras, Hand of Ragnaros", sell_in=0, quality=80),
-             Item(name="Sulfuras, Hand of Ragnaros", sell_in=-1, quality=80),
-             Item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=15, quality=20),
-             Item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=10, quality=49),
-             Item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=5, quality=49),
-             Item(name="Conjured Mana Cake", sell_in=3, quality=6),  # <-- :O
-            ]
-
-    days = 2
-    import sys
-    if len(sys.argv) > 1:
-        days = int(sys.argv[1]) + 1
-    for day in range(days):
-        print("-------- day %s --------" % day)
-        print("name, sellIn, quality")
-        for item in items:
-            print(item)
-        print("")
-        GildedRose(items).update_quality()

+ 0 - 8
sandbox/test_ohno.py

@@ -1,8 +0,0 @@
-from sandbox import ohno
-
-
-def test_simple():
-    board = ohno.Board(4)
-    board.set_initial([[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]])
-    solved = board.solve()
-    assert len(solved) == 1

+ 0 - 209
sandbox/test_relationship.py

@@ -1,209 +0,0 @@
-from sandbox import relationship
-
-relations_first_grade_female = [
-    (("1.2.3.4.5", "1.2.3.4", "w"), "Mutter"),
-    (("1.2.3.4.5", "1.2.3", "w"), "Großmutter"),
-    (("1.2.3.4.5", "1.2", "w"), "Ur-Großmutter"),
-    (("1.2.3.4.5", "1", "w"), "Ur-Ur-Großmutter"),
-    (("1.2.3.4.5", "1.2.3.4.5.6", "w"), "Tochter"),
-    (("1.2.3.4.5", "1.2.3.4.5.6.7", "w"), "Enkelin"),
-    (("1.2.3.4.5", "1.2.3.4.5.6.7.8", "w"), "Ur-Enkelin"),
-    (("1.2.3.4.5", "1.2.3.4.5.6.7.8.9", "w"), "Ur-Ur-Enkelin"),
-]
-
-relations_second_grade_female = [
-    (("1.2.3.4.5", "1.2.3.x", "w"), "Tante"),
-    (("1.2.3.4.5", "1.2.x", "w"), "Großtante"),
-    (("1.2.3.4.5", "1.x", "w"), "Ur-Großtante"),
-    (("1.2.3.4.5", "x", "w"), "Ur-Ur-Großtante"),
-    (("1.2.3.4.5", "1.2.3.4.x", "w"), "Schwester"),
-    (("1.2.3.4.5", "1.2.3.4.x.6", "w"), "Nichte"),
-    (("1.2.3.4.5", "1.2.3.4.x.6.7", "w"), "Großnichte"),
-    (("1.2.3.4.5", "1.2.3.4.x.6.7.8", "w"), "Ur-Großnichte"),
-    (("1.2.3.4.5", "1.2.3.4.x.6.7.8.9", "w"), "Ur-Ur-Großnichte"),
-]
-
-relations_higher_grade_female = [
-    (("1.2.3.4.5", "1.2.3.x", "w"), "Tante"),
-    (("1.2.3.4.5", "1.2.x.x", "w"), "Tante 2. Grades"),
-    (("1.2.3.4.5", "1.x.x.x", "w"), "Tante 3. Grades"),
-    (("1.2.3.4.5", "x.x.x.x", "w"), "Tante 4. Grades"),
-    (("1.2.3.4.5", "1.2.x", "w"), "Großtante"),
-    (("1.2.3.4.5", "1.x.x", "w"), "Großtante 2. Grades"),
-    (("1.2.3.4.5", "x.x.x", "w"), "Großtante 3. Grades"),
-    (("1.2.3.4.5", "1.x", "w"), "Ur-Großtante"),
-    (("1.2.3.4.5", "x.x", "w"), "Ur-Großtante 2. Grades"),
-    (("1.2.3.4.5", "1.2.3.4.x.x", "w"), "Nichte"),
-    (("1.2.3.4.5", "1.2.3.x.x.x", "w"), "Nichte 2. Grades"),
-    (("1.2.3.4.5", "1.2.x.x.x.x", "w"), "Nichte 3. Grades"),
-    (("1.2.3.4.5", "1.x.x.x.x.x", "w"), "Nichte 4. Grades"),
-    (("1.2.3.4.5", "1.2.3.4.x.x.x", "w"), "Großnichte"),
-    (("1.2.3.4.5", "1.2.3.x.x.x.x", "w"), "Großnichte 2. Grades"),
-    (("1.2.3.4.5", "1.2.x.x.x.x.x", "w"), "Großnichte 3. Grades"),
-    (("1.2.3.4.5", "1.x.x.x.x.x.x", "w"), "Großnichte 4. Grades"),
-    (("1.2.3.4.5", "1.2.3.4.x.x.x.x", "w"), "Ur-Großnichte"),
-    (("1.2.3.4.5", "1.2.3.x.x.x.x.x", "w"), "Ur-Großnichte 2. Grades"),
-    (("1.2.3.4.5", "1.2.x.x.x.x.x.x", "w"), "Ur-Großnichte 3. Grades"),
-    (("1.2.3.4.5", "1.x.x.x.x.x.x.x", "w"), "Ur-Großnichte 4. Grades"),
-    (("1.2.3.4.5", "1.2.3.4.x.x.x.x.x", "w"), "Ur-Ur-Großnichte"),
-    (("1.2.3.4.5", "1.2.3.x.x.x.x.x.x", "w"), "Ur-Ur-Großnichte 2. Grades"),
-]
-
-relations_special_grade_female = [
-    (("1.2.3.4.5", "1.2.3.4.x", "w"), "Schwester"),
-    (("1.2.3.4.5", "1.2.3.x.x", "w"), "Cousine"),
-    (("1.2.3.4.5", "1.2.x.x.x", "w"), "Cousine 2. Grades"),
-    (("1.2.3.4.5", "1.x.x.x.x", "w"), "Cousine 3. Grades"),
-]
-
-relations_first_grade_male = [
-    (("1.2.3.4.5", "1.2.3.4", "m"), "Vater"),
-    (("1.2.3.4.5", "1.2.3", "m"), "Großvater"),
-    (("1.2.3.4.5", "1.2", "m"), "Ur-Großvater"),
-    (("1.2.3.4.5", "1", "m"), "Ur-Ur-Großvater"),
-    (("1.2.3.4.5", "1.2.3.4.5.6", "m"), "Sohn"),
-    (("1.2.3.4.5", "1.2.3.4.5.6.7", "m"), "Enkel"),
-    (("1.2.3.4.5", "1.2.3.4.5.6.7.8", "m"), "Ur-Enkel"),
-    (("1.2.3.4.5", "1.2.3.4.5.6.7.8.9", "m"), "Ur-Ur-Enkel"),
-]
-
-relations_second_grade_male = [
-    (("1.2.3.4.5", "1.2.3.x", "m"), "Onkel"),
-    (("1.2.3.4.5", "1.2.x", "m"), "Großonkel"),
-    (("1.2.3.4.5", "1.x", "m"), "Ur-Großonkel"),
-    (("1.2.3.4.5", "x", "m"), "Ur-Ur-Großonkel"),
-    (("1.2.3.4.5", "1.2.3.4.x", "m"), "Bruder"),
-    (("1.2.3.4.5", "1.2.3.4.x.6", "m"), "Neffe"),
-    (("1.2.3.4.5", "1.2.3.4.x.6.7", "m"), "Großneffe"),
-    (("1.2.3.4.5", "1.2.3.4.x.6.7.8", "m"), "Ur-Großneffe"),
-    (("1.2.3.4.5", "1.2.3.4.x.6.7.8.9", "m"), "Ur-Ur-Großneffe"),
-]
-
-relations_higher_grade_male = [
-    (("1.2.3.4.5", "1.2.3.x", "m"), "Onkel"),
-    (("1.2.3.4.5", "1.2.x.x", "m"), "Onkel 2. Grades"),
-    (("1.2.3.4.5", "1.x.x.x", "m"), "Onkel 3. Grades"),
-    (("1.2.3.4.5", "x.x.x.x", "m"), "Onkel 4. Grades"),
-    (("1.2.3.4.5", "1.2.x", "m"), "Großonkel"),
-    (("1.2.3.4.5", "1.x.x", "m"), "Großonkel 2. Grades"),
-    (("1.2.3.4.5", "x.x.x", "m"), "Großonkel 3. Grades"),
-    (("1.2.3.4.5", "1.x", "m"), "Ur-Großonkel"),
-    (("1.2.3.4.5", "x.x", "m"), "Ur-Großonkel 2. Grades"),
-    (("1.2.3.4.5", "1.2.3.4.x.x", "m"), "Neffe"),
-    (("1.2.3.4.5", "1.2.3.x.x.x", "m"), "Neffe 2. Grades"),
-    (("1.2.3.4.5", "1.2.x.x.x.x", "m"), "Neffe 3. Grades"),
-    (("1.2.3.4.5", "1.x.x.x.x.x", "m"), "Neffe 4. Grades"),
-    (("1.2.3.4.5", "1.2.3.4.x.x.x", "m"), "Großneffe"),
-    (("1.2.3.4.5", "1.2.3.x.x.x.x", "m"), "Großneffe 2. Grades"),
-    (("1.2.3.4.5", "1.2.x.x.x.x.x", "m"), "Großneffe 3. Grades"),
-    (("1.2.3.4.5", "1.x.x.x.x.x.x", "m"), "Großneffe 4. Grades"),
-    (("1.2.3.4.5", "1.2.3.4.x.x.x.x", "m"), "Ur-Großneffe"),
-    (("1.2.3.4.5", "1.2.3.x.x.x.x.x", "m"), "Ur-Großneffe 2. Grades"),
-    (("1.2.3.4.5", "1.2.x.x.x.x.x.x", "m"), "Ur-Großneffe 3. Grades"),
-    (("1.2.3.4.5", "1.x.x.x.x.x.x.x", "m"), "Ur-Großneffe 4. Grades"),
-    (("1.2.3.4.5", "1.2.3.4.x.x.x.x.x", "m"), "Ur-Ur-Großneffe"),
-    (("1.2.3.4.5", "1.2.3.x.x.x.x.x.x", "m"), "Ur-Ur-Großneffe 2. Grades"),
-]
-
-relations_special_grade_male = [
-    (("1.2.3.4.5", "1.2.3.4.x", "m"), "Bruder"),
-    (("1.2.3.4.5", "1.2.3.x.x", "m"), "Cousin"),
-    (("1.2.3.4.5", "1.2.x.x.x", "m"), "Cousin 2. Grades"),
-    (("1.2.3.4.5", "1.x.x.x.x", "m"), "Cousin 3. Grades"),
-]
-
-relations_higher_grade_distance = [
-    (("1.2.3.4.5", "1.2.3.4.5.6", "w"), "Tochter", 1),
-    (("1.2.3.4.5", "1.2.3.4.5.6.7", "w"), "Enkelin", 2),
-    (("1.2.3.4.5", "1", "w"), "Ur-Ur-Großmutter", 4),
-    (("1.2.3.4.5", "1.2.3.x", "w"), "Tante", 3),
-    (("1.2.3.4.5", "1.2.x.x", "w"), "Tante 2. Grades", 5),
-    (("1.2.3.4.5", "1.x.x.x", "w"), "Tante 3. Grades", 7),
-    (("1.2.3.4.5", "x.x.x.x", "w"), "Tante 4. Grades", 9),
-    (("1.2.3.4.5", "1.2.x", "w"), "Großtante", 4),
-    (("1.2.3.4.5", "1.x.x", "w"), "Großtante 2. Grades", 6),
-    (("1.2.3.4.5", "x.x.x", "w"), "Großtante 3. Grades", 8),
-    (("1.2.3.4.5", "1.x", "w"), "Ur-Großtante", 5),
-    (("1.2.3.4.5", "x.x", "w"), "Ur-Großtante 2. Grades", 7),
-    (("1.2.3.4.5", "1.2.3.4.x.x", "w"), "Nichte", 3),
-    (("1.2.3.4.5", "1.2.3.x.x.x", "w"), "Nichte 2. Grades", 5),
-    (("1.2.3.4.5", "1.2.x.x.x.x", "w"), "Nichte 3. Grades", 7),
-    (("1.2.3.4.5", "1.x.x.x.x.x", "w"), "Nichte 4. Grades", 9),
-    (("1.2.3.4.5", "1.2.3.4.x.x.x", "w"), "Großnichte", 4),
-    (("1.2.3.4.5", "1.2.3.x.x.x.x", "w"), "Großnichte 2. Grades", 6),
-    (("1.2.3.4.5", "1.2.x.x.x.x.x", "w"), "Großnichte 3. Grades", 8),
-    (("1.2.3.4.5", "1.x.x.x.x.x.x", "w"), "Großnichte 4. Grades", 10),
-    (("1.2.3.4.5", "1.2.3.4.x.x.x.x", "w"), "Ur-Großnichte", 5),
-    (("1.2.3.4.5", "1.2.3.x.x.x.x.x", "w"), "Ur-Großnichte 2. Grades", 7),
-    (("1.2.3.4.5", "1.2.x.x.x.x.x.x", "w"), "Ur-Großnichte 3. Grades", 9),
-    (("1.2.3.4.5", "1.x.x.x.x.x.x.x", "w"), "Ur-Großnichte 4. Grades", 11),
-    (("1.2.3.4.5", "1.2.3.4.x.x.x.x.x", "w"), "Ur-Ur-Großnichte", 6),
-    (("1.2.3.4.5", "1.2.3.x.x.x.x.x.x", "w"), "Ur-Ur-Großnichte 2. Grades", 8),
-]
-
-burghard = [
-    ("Harald", "1.4.6.3.4", "m"),
-    ("Alice", "1.4.6.3.4.1", "w"),
-    ("Janina", "1.4.6.3.4.2", "w"),
-    ("Theresa", "1.4.6.3.4.2.1", "w"),
-    ("Valentin", "1.4.6.3.4.2.2", "m"),
-    ("Freya", "1.4.6.3.4.3", "w"),
-]
-
-burghard_freya = [("Freya", "1.4.6.3.4.3", "w", "Tochter", "Harald", "1.4.6.3.4", "m", "Vater", 1)]
-
-burghard_all = [("Harald", "1.4.6.3.4", "m", "ich", "Harald", "1.4.6.3.4", "m", "ich", 0)]
-
-
-def relations(relations_list):
-    for rel, title in relations_list:
-        result = relationship.relationship_name(*rel)
-        assert result == title
-
-
-def test_first_grade_female():
-    relations(relations_first_grade_female)
-
-
-def test_second_grade_female():
-    relations(relations_second_grade_female)
-
-
-def test_higher_grade_female():
-    relations(relations_higher_grade_female)
-
-
-def test_special_grade_female():
-    relations(relations_special_grade_female)
-
-
-def test_first_grade_male():
-    relations(relations_first_grade_male)
-
-
-def test_second_grade_male():
-    relations(relations_second_grade_male)
-
-
-def test_higher_grade_male():
-    relations(relations_higher_grade_male)
-
-
-def test_special_grade_male():
-    relations(relations_special_grade_male)
-
-
-def test_distance():
-    for rel, title, distance in relations_higher_grade_distance:
-        result = relationship.relationship_distance(rel[0], rel[1])
-        assert result == distance, title
-
-
-def test_relations_list():
-    result = relationship.relationship_list(burghard, 5)
-    assert result[0] == burghard_freya[0]
-
-
-def test_relations_list_all():
-    result = relationship.relationship_list_all(burghard)
-    assert result[0] == burghard_all[0]

+ 0 - 147
sandbox/test_sudoku_solver.py

@@ -1,147 +0,0 @@
-from sandbox import sudoku_solver
-
-board_1 = [
-    ".1.82....",
-    "...3.6...",
-    "54..7....",
-    "..2...95.",
-    "7.52..1.4",
-    ".89...2..",
-    "....8..79",
-    "...5.3...",
-    "...792.3.",
-]
-
-solution_1 = [
-    "317825496",
-    "298346715",
-    "546971328",
-    "432618957",
-    "765239184",
-    "189457263",
-    "623184579",
-    "971563842",
-    "854792631",
-]
-
-board_2 = [
-    "16...7.9.",
-    ".281.967.",
-    ".....82..",
-    "...7....4",
-    "....6....",
-    "5....3...",
-    "..75.....",
-    ".869.173.",
-    ".4.3...86",
-]
-
-solution_2 = [
-    "163427598",
-    "428159673",
-    "759638241",
-    "632795814",
-    "891264357",
-    "574813962",
-    "317586429",
-    "286941735",
-    "945372186",
-]
-
-board_3 = [
-    "..1..8763",
-    "8..9.....",
-    "....1..5.",
-    ".8....4..",
-    "1.54.3...",
-    ".6....2..",
-    "....6..2.",
-    "4..8.....",
-    "..6..1378",
-]
-
-solution_3 = [
-    "941258763",
-    "857936142",
-    "632714859",
-    "789625431",
-    "125483697",
-    "364179285",
-    "518367924",
-    "473892516",
-    "296541378",
-]
-
-empty = ["." * 9 for i in range(9)]
-
-
-def test_simple():
-    board = sudoku_solver.Board()
-    board.set_initial(board_1)
-    row = board.get_row(0)
-    assert row == board_1[0]
-    col = board.get_col(0)
-    assert col == "..5.7...."
-    block = board.get_block(0, 0)
-    assert block == [".1.", "...", "54."]
-    block = board.get_block(4, 6)
-    assert block == ["95.", "1.4", "2.."]
-
-
-def test_simple_set():
-    board = sudoku_solver.Board()
-    board.set_initial(board_1)
-    board.set_cell(5, 7, "6")
-    row = board.get_row(5)
-    assert row == ".89...26."
-
-
-def test_possibilities():
-    board = sudoku_solver.Board()
-    board.set_initial(board_1)
-    p = board.get_possibilities(1, 4)
-    assert p == {"1", "4", "5"}
-
-
-def test_all_possibilities():
-    board = sudoku_solver.Board()
-    board.set_initial(board_1)
-    p = board.get_all_possibilities()
-    assert p[1][4] == {"1", "4", "5"}
-
-
-def test_unique_cell():
-    board = sudoku_solver.Board()
-    board.set_initial(board_1)
-    solving_steps = [
-        (5, 7, "6"),
-        (4, 7, "8"),
-        (4, 5, "9"),
-        (2, 5, "1"),
-        (2, 3, "9"),
-        (2, 7, "2"),
-        (6, 5, "4"),
-        (0, 5, "5"),
-        (1, 4, "4"),
-    ]
-    for x, y, v in solving_steps:
-        cell = board.get_unique_cell()
-        assert cell == (x, y)
-        board.set_cell(x, y, v)
-
-
-def test_solve():
-    board = sudoku_solver.Board()
-    board.set_initial(board_2)
-    b = board.solve()
-    assert b == solution_2
-
-    board = sudoku_solver.Board()
-    board.set_initial(board_1)
-    b = board.solve()
-    assert b == solution_1
-
-    board = sudoku_solver.Board()
-    board.set_initial(board_3)
-    b = board.solve()
-    assert b == solution_3