Ejemplo n.º 1
0
def test_if_file_doesnt_exists_then_will_it_create(func, id):
    full_name = os.path.join(PACKAGE_DIR, id + ".txt")
    if full_name not in func:
        create = open(full_name, 'a+')
    assert full_name in get_files()
Ejemplo n.º 2
0
import pytest
from Mail_Tracker import update_item_info
from Mail_Tracker import get_files
import os


PACKAGE_DIR = os.path.expanduser('~/.packages/')

# - test 1: Checking if file id exists in file list
# for the test, you need to use an actual file in list


@pytest.mark.parametrize(('func', 'id'), [
    (get_files(), '9000003299'),
])

def test_check_if_file_actually_exists(func, id):
    full_name = os.path.join(PACKAGE_DIR, id + ".txt")
    assert full_name in func


# - test 2: If file exists, then can it read into the lines of the file
# for this test, we need an actual id in the file list

@pytest.mark.parametrize(('func', 'id'), [
    (get_files(), '9000003299')
])


def test_check_if_file_exists_then_can_we_read_into_it(func, id):
    full_name = os.path.join(PACKAGE_DIR, id + ".txt")
Ejemplo n.º 3
0
def test_if_file_exists_then_will_it_delete(func, id):
    full_name = os.path.join(PACKAGE_DIR, id + ".txt")
    if full_name in func:
        os.remove(full_name)
    assert full_name not in get_files()
Ejemplo n.º 4
0

@pytest.mark.parametrize(('expected', 'func_input'),
                         [("Its a list", delete(['1, 2, 3, 4'])),
                          ("Its a singular number", delete('3'))])
def test_if_package_is_singular_or_list(func_input, expected):
    assert expected == func_input


# - test 2: Checking if the id is even in the file list


@pytest.mark.parametrize(
    ('func', 'id'),
    [
        (get_files(), '903299'),
        # (get_files(), '600000')
    ])
def test_if_file_in_files(func, id):
    full_name = os.path.join(PACKAGE_DIR, id + ".txt")
    assert full_name not in func


# - test 3: Checking if the id is in the file list, then can it delete it
# test only works once with actual ids, otherwise it fails


@pytest.mark.parametrize(
    ('func', 'id'),
    [
        (get_files(), '1234'),
Ejemplo n.º 5
0
def test_if_file_doesnt_exists_then_will_it_create(func, id):
    full_name = os.path.join(PACKAGE_DIR, id + ".txt")
    if full_name not in func:
        create = open(full_name, 'a+')
    assert full_name in get_files()
Ejemplo n.º 6
0
import pytest
from Mail_Tracker import update_item_info
from Mail_Tracker import get_files
import os

PACKAGE_DIR = os.path.expanduser('~/.packages/')

# - test 1: Checking if file id exists in file list
# for the test, you need to use an actual file in list


@pytest.mark.parametrize(('func', 'id'), [
    (get_files(), '9000003299'),
])
def test_check_if_file_actually_exists(func, id):
    full_name = os.path.join(PACKAGE_DIR, id + ".txt")
    assert full_name in func


# - test 2: If file exists, then can it read into the lines of the file
# for this test, we need an actual id in the file list


@pytest.mark.parametrize(('func', 'id'), [(get_files(), '9000003299')])
def test_check_if_file_exists_then_can_we_read_into_it(func, id):
    full_name = os.path.join(PACKAGE_DIR, id + ".txt")
    lines = open(full_name, 'r').readlines()
    assert lines > 0


# - test 3: if file doesnt exist, does it make a new one?