From 9dec62602533408c72bd0ad5ff358973e3b266b1 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Sun, 5 Nov 2023 12:07:43 +0200 Subject: [PATCH] Add a simple feature test to test path uniqueness. --- features/path.feature | 7 +++++++ features/steps/path_steps.py | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 features/path.feature create mode 100644 features/steps/path_steps.py diff --git a/features/path.feature b/features/path.feature new file mode 100644 index 0000000..d490384 --- /dev/null +++ b/features/path.feature @@ -0,0 +1,7 @@ +Feature: Adding an unique path + + Scenario: Adding an new unique path + Given a path "/media" + When I add the path to the database + Then the path should be added successfully + diff --git a/features/steps/path_steps.py b/features/steps/path_steps.py new file mode 100644 index 0000000..891a691 --- /dev/null +++ b/features/steps/path_steps.py @@ -0,0 +1,24 @@ +from behave import given, when, then +from peewee import IntegrityError +from tui_rsync.models.models import create_tables +from tui_rsync.models.models import Path + +@given('a path "{path_str}"') +def given_path(context, path_str): + create_tables() + context.path_str = path_str + +@when('I add the path to the database') +def add_path(context): + try: + context.path = Path.create(path=context.path_str) + except IntegrityError: + context.exception_raised = True + else: + context.exception_raised = False + +@then('the path should be added successfully') +def path_has_added(context): + assert context.path.path == context.path_str + assert context.exception_raised == False +