Ejemplo n.º 1
0
def test_load_creates_correct_list_of_software():
    #arrange
    softwareList = []
    softwareList.append(Software("MS Word", (13,2,1)))
    softwareList.append(Software("MS Excel", (13,4,2)))
    softwareList.append(Software("AngularJS", (1,7,1)))
    softwareList.append(Software("Angular", (8,1,13)))

    assert load_software_from_file(TEST_FILE_LOCATION) == softwareList
Ejemplo n.º 2
0
def test_gt_compares_by_fist_looking_at_Major_then_Minor_then_Patch():
    assert Software("a", (1, randint(0, 100), randint(0, 100))) > Software(
        "b", (0, randint(0, 100), randint(0, 100)))
    assert Software("a", (1, 12, randint(0, 100))) > Software(
        "b", (1, 11, randint(0, 100)))
    assert Software("a", (5, 7, 12)) > Software("b", (5, 7, 2))

    #Just to make sure it is not always returning true
    assert not Software("a", (5, 7, 4)) > Software("b", (5, 7, 18))
Ejemplo n.º 3
0
def load_software_from_file(fileName):
    with open(fileName) as file:
        data = json.load(file)

        softwareList = []
        for softwareJsonLine in data:
            software = Software(softwareJsonLine['name'],
                                parse_version(softwareJsonLine['version']))

            softwareList.append(software)

        return softwareList
Ejemplo n.º 4
0
def test_construtor_accepts_a_name_and_version_tuple():
    software = Software("name", (1, 2, 4))
    assert software.name == "name"
    assert software.majorVersion == 1
    assert software.minorVersion == 2
    assert software.patch == 4
Ejemplo n.º 5
0
def test_toJson_returns_software_as_dict():
    software = Software("a", (2, 4, 5))
    expectedDict = {'name': "a", 'version': "2.4.5"}

    assert software.toJson() == expectedDict
Ejemplo n.º 6
0
def test_eq():
    assert Software("a", (5, 7, 1)) == Software("a", (5, 7, 1))
    assert not Software("a", (6, 7, 1)) == Software("a", (5, 7, 1))
    assert not Software("a", (5, 7, 1)) == Software("b", (5, 7, 1))
    assert not Software("a", (5, 7, 1)) == Software("a", (5, 3, 1))
    assert not Software("a", (5, 7, 1)) == Software("a", (5, 7, 6))
Ejemplo n.º 7
0
def test_gt_when_equal_returns_false():
    assert not Software("a", (5, 7, 1)) > Software("b", (5, 7, 1))