Skip to content

Commit

Permalink
split up to test and library
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-sapletta-com committed Dec 10, 2023
1 parent 5176a7a commit ea2f2af
Show file tree
Hide file tree
Showing 17 changed files with 17 additions and 306 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ python.dialoget.com is a test framework for multilanguage source code, based on
pip install --upgrade pip
pip install requests
pip install behave
pip install setuptools
chmod +x test.sh
```

Expand All @@ -18,7 +19,7 @@ with one bash script
or each script in command line

```bash
cd test
cd test/dialoget
python3 update_repo_on_github.py
python3 update_repo_on_github2.py
python3 create_repo_on_org_github.py
Expand Down
4 changes: 0 additions & 4 deletions data/env.py

This file was deleted.

15 changes: 0 additions & 15 deletions data/map.py

This file was deleted.

6 changes: 0 additions & 6 deletions data/prompt.py

This file was deleted.

5 changes: 0 additions & 5 deletions data/user.py

This file was deleted.

10 changes: 0 additions & 10 deletions setup.py

This file was deleted.

28 changes: 0 additions & 28 deletions src/create_repo_on_org_github.py

This file was deleted.

79 changes: 10 additions & 69 deletions lib/dialoget.py → src/dialoget.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import sys
sys.path.append('../')
import os
#from functools import wraps
import functools
import csv
from datetime import datetime


# root path to the project
#ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
ROOT_PATH=''
LOG_FILE='log.csv'
ERROR_FILE='error.csv'
# ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
ROOT_PATH = ''
LOG_FILE = 'log.csv'
ERROR_FILE = 'error.csv'
LOG_PATH = os.path.join(ROOT_PATH, LOG_FILE)
ERROR_PATH = os.path.join(ROOT_PATH, ERROR_FILE)


def dialoget(template, logs_path=''):
USER_ERROR = os.path.abspath( os.path.join(logs_path,ERROR_PATH) )
USER_LOGS = os.path.abspath( os.path.join(logs_path,LOG_PATH) )
USER_ERROR = os.path.abspath(os.path.join(logs_path, ERROR_PATH))
USER_LOGS = os.path.abspath(os.path.join(logs_path, LOG_PATH))

def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
Expand Down Expand Up @@ -50,8 +48,10 @@ def wrapper(*args, **kwargs):
return func(*args, **kwargs)

return wrapper

return decorator


def log_to_csv(file_name, log_dict):
# Write log message or error to a CSV file
with open(file_name, mode='a', newline='') as file:
Expand All @@ -60,62 +60,3 @@ def log_to_csv(file_name, log_dict):
writer.writeheader()
writer.writerow(log_dict)


"""
def dialoget(template):
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
# Assuming the function returns a dictionary of replacements
replacements = func(*args, **kwargs)
# Replace placeholders in the template with actual values
filled_template = template.format(**replacements)
# Print or use the filled template string
print(filled_template) # or you can return it, if needed
# Return the result of the function, if it's necessary.
return replacements
return wrapper
return decorator
# This is the decorator factory that accepts arguments
def dialoget2(sentence="Sentence"):
# This is the actual decorator
def decorator(func):
call_count = 0
@functools.wraps(func)
def wrapper(*args, **kwargs):
nonlocal call_count
call_count += 1
print(f"The sentence: {sentence} {func.__name__} has been called {call_count} times")
return func(*args, **kwargs)
return wrapper
return decorator
# Usage example with decorator arguments
def nfunc(func):
# This will hold the number of times the function has been called
call_count = 0
@wraps(func) # Use this to preserve the original function's metadata
def wrapper(*args, **kwargs):
nonlocal call_count
call_count += 1
print(f"Function {func.__name__} has been called {call_count} times")
return func(*args, **kwargs)
return wrapper
"""
26 changes: 0 additions & 26 deletions src/update_repo_on_github.py

This file was deleted.

69 changes: 0 additions & 69 deletions src/update_repo_on_github2.py

This file was deleted.

5 changes: 0 additions & 5 deletions test.bat

This file was deleted.

5 changes: 0 additions & 5 deletions test.sh

This file was deleted.

21 changes: 0 additions & 21 deletions test/apitee/update_repo_on_github.py

This file was deleted.

21 changes: 0 additions & 21 deletions test/apitee/update_repo_on_github2.py

This file was deleted.

15 changes: 0 additions & 15 deletions test/behave/update_repo_on_github2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,3 @@ def step_impl(context):
@then('they see a welcome message')
def step_impl(context):
assert context.browser.shows_welcome_message()

#print(FromEnv)
#api_token="API token"
#repo_name="Repository"
#org_name="GitHub Organization"
f'Connect to the github API {GITHUB_API_URL} with {api_token}'
f'Update a {repo_name} on {org_name}'
f'with a {description}'
f'on the {domain}'
result = update_repo_on_github2(api_token, org_name, repo_name, description, domain, GITHUB_API_URL)
#print(result)
print(result == 200)


# f'Connect to {Github,github_url,GITHUB_API_URL} by {"API token",api_token,GITHUB_API_TOKEN}'
Empty file added test/dialoget.py
Empty file.
Loading

0 comments on commit ea2f2af

Please sign in to comment.