Example #1
0
def test_add_with_parent_service_and_invalid_property():
    mock = ArgumentsMock(entity="service", action = "add", account="101321", servicedata = "{ \"name\" : \"CsDatabase\" }")
    result_parent = atomia.main(mock)
    if (isinstance(result_parent, AtomiaService)):
        mock = ArgumentsMock(entity="service", action = "add", account="101321", parent = result_parent.logical_id, servicedata = "{ \"name\" : \"CsMySqlDatabase\", \"properties\" : { \"DatabaseMame\" : \"testpy45\", \"CharacterSet\" : \"utf8\", \"Collation\" : \"utf8_general_ci\"}}")
        with pytest.raises(urllib2.HTTPError):
            atomia.main(mock)
        mock = ArgumentsMock(entity="service", action = "delete", account="101321", service = result_parent.logical_id)
        atomia.main(mock)
    else:
        assert False
Example #2
0
def test_add_with_parent_service_and_missing_properties():
    mock = ArgumentsMock(entity="service", action = "add", account="101321", servicedata = "{ \"name\" : \"CsDatabase\" }")
    result_parent = atomia.main(mock)
    if (isinstance(result_parent, AtomiaService)):
        mock = ArgumentsMock(entity="service", action = "add", account="101321", parent = result_parent.logical_id, servicedata = "{ \"name\" : \"CsMySqlDatabase\" }")
        with pytest.raises(urllib2.HTTPError):
            atomia.main(mock)
        mock = ArgumentsMock(entity="service", action = "delete", account="101321", service = result_parent.logical_id)
        atomia.main(mock)
    else:
        assert False
Example #3
0
def test_add_with_parent_service():
    mock = ArgumentsMock(entity="service", action = "add", account="101321", servicedata = "{ \"name\" : \"CsDatabase\" }")
    result_parent = atomia.main(mock)
    if (isinstance(result_parent, AtomiaService)):
        mock = ArgumentsMock(entity="service", action = "add", account="101321", parent = result_parent.logical_id, servicedata = "{ \"name\" : \"CsMySqlDatabase\", \"properties\" : { \"DatabaseName\" : \"testpy46\", \"CharacterSet\" : \"utf8\", \"Collation\" : \"utf8_general_ci\"}}")
        result = atomia.main(mock)
        assert isinstance(result, AtomiaService)
        mock = ArgumentsMock(entity="service", action = "delete", account="101321", service = result_parent.logical_id)
        atomia.main(mock)
    else:
        assert False    
Example #4
0
def test_delete_service_locator():
    mock = ArgumentsMock(entity="service", action = "add", account="101321", servicedata = "{ \"name\" : \"CsDatabase\" }")
    add_result_parent = atomia.main(mock)
    if (isinstance(add_result_parent, AtomiaService)):
        mock = ArgumentsMock(entity="service", action = "add", account="101321", parent = add_result_parent.logical_id, servicedata = "{ \"name\" : \"CsMySqlDatabase\", \"properties\" : { \"DatabaseName\" : \"testpy45\", \"CharacterSet\" : \"utf8\", \"Collation\" : \"utf8_general_ci\"}}")
        add_result = atomia.main(mock)
        if (isinstance(add_result, AtomiaService)):
            delete_mock = ArgumentsMock(entity="service", action = "delete", account="101321", path="[{\"CsDatabase\" : \"" + add_result_parent.logical_id + "\"}, { \"CsMySqlDatabase\" : { \"DatabaseName\" : \"testpy45\"} } ]")
            assert atomia.main(delete_mock)

            mock = ArgumentsMock(entity="service", action = "delete", account="101321", service = add_result_parent.logical_id)
            atomia.main(mock)
        else:
            assert False
    else:
        assert False
Example #5
0
def test_modify_with_parent_service_and_missing_properties():
    mock = ArgumentsMock(entity="service", action = "add", account="101321", servicedata = "{ \"name\" : \"CsDatabase\" }")
    result_parent = atomia.main(mock)
    if (isinstance(result_parent, AtomiaService)):
        mock = ArgumentsMock(entity="service", action = "add", account="101321", parent = result_parent.logical_id, servicedata = "{ \"name\" : \"CsMySqlDatabase\", \"properties\" : { \"DatabaseName\" : \"testpy45\", \"CharacterSet\" : \"utf8\", \"Collation\" : \"utf8_general_ci\"}}")
        add_result = atomia.main(mock)
        if isinstance(add_result, AtomiaService):
            modify_result = ArgumentsMock(entity="service", action = "modify", account="101321", service = add_result.logical_id)
            with pytest.raises(Exception):
                atomia.main(modify_result)
        else:
            assert False
        mock = ArgumentsMock(entity="service", action = "delete", account="101321", service = result_parent.logical_id)
        atomia.main(mock)
    else:
        assert False      
Example #6
0
def test_modify_no_service():
    mock = ArgumentsMock(entity="service", action = "modify", account="101321")
    with pytest.raises(atomia.InputError):
        atomia.main(mock)
Example #7
0
def test_find_existing_parent_service_id_with_invalid_relative_path():
    mock = ArgumentsMock(entity="service", action = "find", account="101321", parent = "d83805a8-c4a3-4e17-96af-4c9f0c1679d2", query = "{ \"name\" : \"ApacheWebSite\", \"path\" : \"foo\" }" )
    with pytest.raises(Exception):
        atomia.main(mock)
Example #8
0
def test_list_existing_service_description():
    mock = ArgumentsMock(entity="service", action = "list", path="[{\"CsBase\" : \"d83805a8-c4a3-4e17-96af-4c9f0c1679d2\" }, {\"CsWindowsWebsite\" : {\"Hostname\":\"python43.org\"} } ]", account="101321")
    assert isinstance(atomia.main(mock), list) and len(atomia.main(mock)) > 0
Example #9
0
def test_list_non_existing_service_description():
    mock = ArgumentsMock(entity="service", action = "list", path="[{\"CsBase\" : {\"foo\" : \"bar\"}} ]", account="101321")
    with pytest.raises(Exception):
        atomia.main(mock)
Example #10
0
def test_list_non_existing_service_id():
    mock = ArgumentsMock(entity="service", action = "list", parent = "00000000-0000-0000-0000-000000000000")
    with pytest.raises(Exception):
        atomia.main(mock)
Example #11
0
def test_find_existing_parent_service_locator_with_multiple_parents():
    mock = ArgumentsMock(entity="service", action = "find", account="101321", path="[{\"CsBase\" : \"d83805a8-c4a3-4e17-96af-4c9f0c1679d2\"}, {\"CsWindowsWebsite\" : { \"InitEmail\" : \"true\"}}]", query = "{ \"name\" : \"DnsZoneRecord\", \"path\" : \"DnsZone\" }" )
    with pytest.raises(Exception):
        atomia.main(mock)
Example #12
0
def test_show_no_service():
    mock = ArgumentsMock(entity="service", action = "show")
    with pytest.raises(Exception):
        atomia.main(mock)
Example #13
0
def test_add_no_parent_service():
    mock = ArgumentsMock(entity="service", action = "add", account="101321", servicedata = "{ \"name\" : \"CsDatabase\" }")
    result = atomia.main(mock)
    assert isinstance(result, AtomiaService)
    mock = ArgumentsMock(entity="service", action = "delete", account="101321", service = result.logical_id)
    atomia.main(mock)
Example #14
0
def test_add_missing_parent_service():
    mock = ArgumentsMock(entity="service", action = "add", account="101321", servicedata = "{ \"name\" : \"CsMySqlDatabase\", \"properties\" : { \"DatabaseName\" : \"testpy45\", \"CharacterSet\" : \"utf8\", \"Collation\" : \"utf8_general_ci\"}}")
    with pytest.raises(urllib2.HTTPError):
        atomia.main(mock)
Example #15
0
def test_find_no_parent_root_service():
    mock = ArgumentsMock(entity="service", action = "find", account="101321", query = "{ \"name\" : \"CsBase\" }" )
    assert isinstance(atomia.main(mock), list) and len(atomia.main(mock)) > 0  
Example #16
0
def test_find_no_parent():
    mock = ArgumentsMock(entity="service", action = "find", account="101321", query = "{ \"name\" : \"DnsZoneRecord\", \"path\" : \"CsBase/CsWindowsWebsite/DnsZone\" }" )
    assert isinstance(atomia.main(mock), list) and len(atomia.main(mock)) > 0
Example #17
0
def test_find_existing_parent_service_locator():
    mock = ArgumentsMock(entity="service", action = "find", account="101321", path="[{\"CsBase\" : \"d83805a8-c4a3-4e17-96af-4c9f0c1679d2\"}, {\"CsWindowsWebsite\" : { \"Hostname\" : \"python44.org\"}}]", query = "{ \"name\" : \"DnsZoneRecord\", \"path\" : \"DnsZone\" }" )
    assert isinstance(atomia.main(mock), list) and len(atomia.main(mock)) > 0
Example #18
0
def test_modify_missing_parent_service():
    mock = ArgumentsMock(entity="service", action = "add", account="101321", servicedata = "{ \"name\" : \"CsMySqlDatabase\", \"properties\" : { \"Collation\" : \"utf8_unicode_ci\"}}")
    with pytest.raises(urllib2.HTTPError):
        atomia.main(mock)
Example #19
0
def test_show_existing_service_description():
    mock = ArgumentsMock(entity="service", action = "show", path="[{\"DomainRegContact\" : {\"Id\" : \"138\"}} ]", account="101321")
    assert isinstance(atomia.main(mock), AtomiaService)
Example #20
0
def test_find_existing_parent_service_id_with_relative_path_and_properties():
    mock = ArgumentsMock(entity="service", action = "find", account="101321", parent = "d83805a8-c4a3-4e17-96af-4c9f0c1679d2", query = "{ \"name\" : \"ApacheWebSite\", \"path\" : \"CsLinuxWebsite\", \"properties\" : { \"PhpVersion\" : \"5.2\"} }" )
    assert isinstance(atomia.main(mock), list) and len(atomia.main(mock)) > 0
Example #21
0
def test_show_existing_service_id():
    mock = ArgumentsMock(entity="service", action = "show", service = "4fe9b823-0020-4e33-abd9-a2de6a1480af", account="101321")
    assert isinstance(atomia.main(mock), AtomiaService)
Example #22
0
def test_delete_no_service():
    mock = ArgumentsMock(entity="service", action = "delete", account="101321")
    with pytest.raises(Exception):
        atomia.main(mock)
Example #23
0
def test_list_no_service():
    mock = ArgumentsMock(entity="service", action = "list", account="101321")
    assert isinstance(atomia.main(mock), list)
Example #24
0
def test_delete_invalid_service_id():
    mock = ArgumentsMock(entity="service", action = "delete", account="101321", service = "00000000-0000-0000-0000-000000000000")
    with pytest.raises(Exception):
        atomia.main(mock)
Example #25
0
def test_list_existing_service_id():
    mock = ArgumentsMock(entity="service", action = "list", parent = "d83805a8-c4a3-4e17-96af-4c9f0c1679d2", account="101321")
    assert isinstance(atomia.main(mock), list) and len(atomia.main(mock)) > 0 
Example #26
0
def test_delete_non_existing_service_locator_path():
    mock = ArgumentsMock(entity="service", action = "delete", account="101321", path="[{\"CsBase\" : \"d83805a8-c4a3-4e17-96af-4c9f0c1679d2\"}, {\"CsMySqlDatabase\" : { \"DatabaseName\" : \"python44.org\"}}]")
    with pytest.raises(Exception):
        atomia.main(mock)
Example #27
0
def test_list_non_existing_service_description_2():
    mock = ArgumentsMock(entity="service", action = "list", path="[{\"CsBase\" : \"d83805a8-c4a3-4e17-96af-4c9f0c1679d2\" }, {\"CsLinuxWebsite\" : { \"foo\" : \"bar\" } } ]", account="101321")
    with pytest.raises(Exception):
        atomia.main(mock)
Example #28
0
def test_delete_service_id():
    mock = ArgumentsMock(entity="service", action = "add", account="101321", servicedata = "{ \"name\" : \"CsDatabase\" }")
    add_result = atomia.main(mock)
    mock = ArgumentsMock(entity="service", action = "delete", account="101321", service = add_result.logical_id)
    assert atomia.main(mock)
Example #29
0
def test_list_existing_service_description_2():
    mock = ArgumentsMock(entity="service", action = "list", path="[{\"CsBase\" : \"d83805a8-c4a3-4e17-96af-4c9f0c1679d2\" }, {\"CsLinuxWebsite\" : \"584e20b8-756f-49e4-b426-a58b835a873e\"} ]", account="101321")
    assert isinstance(atomia.main(mock), list) and len(atomia.main(mock)) > 0
Example #30
0
def test_find_existing_parent_service_id():
    mock = ArgumentsMock(entity="service", action = "find", account="101321", parent = "d83805a8-c4a3-4e17-96af-4c9f0c1679d2", query = "{ \"name\" : \"CsLinuxWebsite\" }" )
    assert isinstance(atomia.main(mock), list) and len(atomia.main(mock)) > 0