def test_copy():
    """
    checks if another copy is made or not.
    If the original List is empty, copy of empty String will be returned.
    :return:
    """
    dna_list = DNAList("COPYTEST")
    print(dna_list.copy())
    pass
def test_snip():
    """
    checks if the start and end index lies within the range of list.
    If the index is greater than the list size, Index out of Bounds assetion is thrown.
    :return: None
    """
    dna_list = DNAList("SNIPTEST")
    dna_list.snip(0, 4)
    print(dna_list)
    pass
def test_splice():
    """
    checks if the index is valid in the list.
    If other list is empty, nothing is added in the index.
    If the index is greater than the list size, Index out of Bounds assetion is thrown.
    :return: None
    """
    dna_list = DNAList("SPLICETEST")
    other = DNAList(" Yayy ")
    dna_list.splice(5, other)
    print(dna_list)
    pass
def test_append():
    """
    Allows only character to be appended at the end of the string.
    If String is tried to be appended it will give an assertion.
    If the list is empty, a blank list is created.
    :return: None
    """
    dnaAppend = DNAList()
    print(dnaAppend)
    dnaAppend.append("A")
    print(dnaAppend)
    # dnaAppend.append("Aditi")
    # print(dnaAppend)
    dnaAppend.append(8)
    print(dnaAppend)
    dnaAppend.append('@')
    print(dnaAppend)
    dnaAppend.append(None)
    print(dnaAppend)
def test_join():
    """
    Another list is appended to the current list.
    It is added to the end of the list.
    If another list is empty, nothing is added.
    if the current list is empty, another list still can be added to it.

    :return:None
    """
    dna_list = DNAList("JOINTEST")
    dna_list.join(DNAList("I AM Joining"))
    print(dna_list)
    dna_list.join(DNAList(""))
    print(dna_list)
def test_replace():
    """
    If the other list is empty, nothing is replaced.
    If repstr String is not found, nothing is replaced.
    If The String is found, it is replaced.
    :return: None
    """
    dna_list = DNAList("HIIAMAAMIT")
    other = DNAList("ADITI")
    dna_list.replace("Jaisinghani", other)
    print(dna_list)
    dna_list.replace("AMIT", other)
    print(dna_list)
    pass
def test_init():
    """
    We have handled scenarios for init where
    if data is None, nothing is passed.
    if empty constructor is given, string is passed.
    :return: None
    """
    dna = DNAList(None)
    print(dna)
    dna = DNAList("")
    print(dna)

    dna = DNAList("AMit")
    print(dna)

    dna = DNAList("A")
    print(dna)

    dna = DNAList("@")
    print(dna)

    dna = DNAList()
    print(dna)
Esempio n. 8
0
def snip_Tester():
    test = DNAList('AACCGGTT')
    test.snip(1, 4)
    print('Indices in range' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(1, 8)
    print('Index is not in range' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(0, 7)
    print('Snip using boundary indices' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(1, 1)
    print('Illegal passing of arguments' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(1, -4)
    print('Negative value of arguments' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(4, 1)
    print('i1 is greater than i2 ' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(3, 3)
    print('i1 equal to i2 ' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(0, 0)
    print('i1 and i2 equals to 0' + " " + test.__str__())
Esempio n. 9
0
def splice_Tester():
    test = DNAList('AACCGGTT')
    tester = DNAList('ACGT')
    test.splice(1, tester)
    print('Testing when index is not in range' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    tester = DNAList('ACGT')
    test.splice(7, tester)
    print('splice at last index' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    tester = DNAList('ACGT')
    test.splice(3, tester)
    print('splice at middle index' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    tester = DNAList('ACGT')
    test.splice(0, tester)
    print('splice at the first index' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    tester = DNAList('ACGT')
    test.splice(-1, tester)
    print('Negative index' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    tester = DNAList('')
    test.splice(1, tester)
    print('if the list is empty ' + " " + test.__str__())
Esempio n. 10
0
def init_tester():
    tester = DNAList("")
    print("Testing Passing Empty String" + " " + tester.__str__())
    tester = DNAList("AACCGGTT")
    print("Passing String" + " " + tester.__str__())
Esempio n. 11
0
def join_Tester():
    tester = DNAList("AACCGGTT")
    tester2 = DNAList("")
    tester.join(tester2)
    print('Join When List is Null' + " " + tester.__str__())
    tester = DNAList('AACCGGTT')
    tester2 = DNAList("AAA")
    tester.join(tester2)
    print('Joining at the end of the list' + " " + tester.__str__())
Esempio n. 12
0
def str_Tester():
    test = DNAList("AACCTTGG")
    print('Testing the str method....' + " " + test.__str__())
    test = DNAList("")
    print('Testing if list is empty' + " " + test.__str__())
Esempio n. 13
0
def test2():
    """
    The second test function
    """
    print("TEST CASE 2")

    dna = DNAList()
    # checks for test case of copy cannot copy when gene list is empty
    dna.copy()

    # checks the append function if empty string is appended it wont append the empty String
    dna.append("")

    # if the item is None it also won't be appended in the gene list
    dna.append(None)

    # items with values will be appended in the gene list
    dna.append("A")
    dna.append("B")
    dna.append("C")
    print("After append method ", dna)

    normList = DNAList()
    # empty list wont be appended in the gene list
    dna.join(normList)

    newother = DNAList()
    newother.append("H")
    newother.append("I")
    newother.append("J")
    newother.append("K")

    # will append the elements in the front if index is 0
    dna.splice(0, newother)
    print("After splice method at index 0 ", dna)
    # will not append the gene list if the list passed in the function is empty
    dna.splice(0, normList)

    newotherlist = DNAList()
    newotherlist.append("W")
    newotherlist.append("Q")
    newotherlist.append("R")

    # will not replace if the given object is of list is empty
    dna.replace("BCD", normList)
    #cannot replace if string to be replaced is None or empty
    dna.replace("", newotherlist)
    dna.replace(None, newotherlist)

    # replaces the starting value of the gene list with other list
    # replace any substring with any other list of elements provided
    dna.replace("H", newotherlist)
def test_str():
    "Prints List value."
    dna_list = DNAList("PRINTTEST")
    print(dna_list)
    pass
Esempio n. 15
0
def replace_Tester():
    test = DNAList('AACCGGTT')
    r = DNAList('TTGGCC')
    test.replace('AA', r)
    print('Normal case' + " " + test.__str__())
    test = DNAList('')
    r = DNAList('TTGGCC')
    test.replace('AA', r)
    print('List 1 is empty' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    r = DNAList('')
    test.replace('AA', r)
    print('List 2 is empty' + " " + test.__str__())
Esempio n. 16
0
def test1():
    """
    This is a simple test case which checks all the functions
    :return:
    """
    print("TEST CASE 1")
    dna = DNAList()

    # items with values will be appended in the gene list
    dna.append("A")
    dna.append("B")
    dna.append("C")

    print("After append method ", dna)

    other = DNAList()
    other.append("D")
    other.append("E")
    other.append("F")
    other.append("G")

    # list with values will be appended in the gene list
    dna.join(other)
    print("After join method with the list provided", dna)

    # if gene list is not empty then it will copy the current items in the list in a new list
    newList = dna.copy()
    print("After copy method", newList)

    newother = DNAList()
    newother.append("H")
    newother.append("I")
    newother.append("J")
    newother.append("K")

    # list with elements after the index will be added in the list
    dna.splice(4, newother)
    print("After splice method at index 4 ", dna)

    # index of elements specified will be removed from the list
    dna.snip(4, 5)
    print("After snip method with index 4 and 5 ", dna)

    newotherlist = DNAList()
    newotherlist.append("W")
    newotherlist.append("Q")
    newotherlist.append("R")

    # the string given will be replaced with the list given
    dna.replace("BCD", newotherlist)
    print("After replace method with string BCD", dna)
    print()
Esempio n. 17
0
def append_tester():
    tester = DNAList('ACGT')
    tester.append("")
    print('Passing Empty string' + " " + tester.__str__())
    tester.append("%^&^@")
    print('Passing IllegalCharacters ' + " " + tester.__str__())
    tester = DNAList("")
    tester.append("A")
    print('Appending When List is Null' + " " + tester.__str__())
Esempio n. 18
0
    TESTCASE_COUNT += 1
    if string1 == string2:
        print("Test case " + str(TESTCASE_COUNT) + " passed.")
    else:
        print("Test case " + str(TESTCASE_COUNT) + " failed. Expected: " +
              str(string1) + " . Actual: " + str(string2) + '.')


print("Begin tests...")

# Test basic DNAList construction and __str__ function
print("Testing basic DNAList construction:")

# Test normal list construction
# Test case 1
list1 = DNAList('GCCATT')
test('GCCATT', str(list1))

# Test case 2
list2 = DNAList('ATCGACG')
test('ATCGACG', str(list2))

# Test empty list construction
# Test case 3
list_empty = DNAList()
test('', str(list_empty))

# Test append function
print("Testing append function:")

# Test appending legal item
Esempio n. 19
0
def copy_Tester():
    test = DNAList("AACCTTGG")
    test.copy()
    print('Normal Case' + " " + test.__str__())
    test = DNAList("")
    print('Copy of empty list' + " " + test.__str__())