Esempio n. 1
0
def test_pathbuilder_equals():
    pb1 = output.create(build="hello", config="world")
    pb2 = output.create(build="hello", config="world")
    assert pb1 == pb2, "Identical pathbuilder objects should be equal to each other!"
    pb3 = "invalid"
    assert not pb1.__eq__(pb3), "None pathbuilder objects should not be equal!"
    pb4 = pb1.clone(build="goodbye")
    assert pb1 != pb4, "None equal pathbuilder objects should not be equal!"
Esempio n. 2
0
def test_pathbuilder_equals():
    pb1 = output.create(build="hello", config="world")
    pb2 = output.create(build="hello", config="world")
    assert pb1 == pb2, "Identical pathbuilder objects should be equal to each other!"
    pb3 = "invalid"
    assert not pb1.__eq__(pb3), "None pathbuilder objects should not be equal!"
    pb4 = pb1.clone(build="goodbye")
    assert pb1 != pb4, "None equal pathbuilder objects should not be equal!"
Esempio n. 3
0
def test_pathbuilder_get_path():
    pb = output.create(build="b")
    assert pb.path, "Could not get path from pb with only build param!"
    pb2 = output.create(build="b", tagtype="t")
    assert pb.path == pb2.path, "first path part should wins!"
    with pytest.raises(ValueError):
        pb._getpath(allow_partial=False)
    pb3 = __get_pathbuilder()
    pb3.tagsize = None
    __validate_pathbuilder_params(pb3, tagsize=None)
    with pytest.raises(ValueError):
        print(pb3._getpath(allow_partial=False))
Esempio n. 4
0
def test_pathbuilder_get_path():
    pb = output.create(build="b")
    assert pb.path, "Could not get path from pb with only build param!"
    pb2 = output.create(build="b", tagtype="t")
    assert pb.path == pb2.path, "first path part should wins!"
    with pytest.raises(ValueError):
        pb._getpath(allow_partial=False)
    pb3 = __get_pathbuilder()
    pb3.tagsize = None
    __validate_pathbuilder_params(pb3, tagsize=None)
    with pytest.raises(ValueError):
        print(pb3._getpath(allow_partial=False))
Esempio n. 5
0
def test_capture_configs():
    cids = [477944]
    configs = {
        "chrome": {
            "enabled": True,
            "capabilities": {
                "platform": "Windows 7",
                "browserName": "chrome"
            }
        },
        "chrome_beta": {
            "enabled": True,
            "capabilities": {
                "platform": "Windows 7",
                "browserName": "chrome",
                "version": "beta"
            }
        }}
    adsizes = ["medium_rectangle"]
    adtypes = ["iframe"]

    pb = output.create(build="capture_test")
    cm = capture.CaptureManager(domain="www.placelocal.com")
    errors = cm._capture_tags_for_configs(cids=cids, pathbuilder=pb,
                                          configs=configs,
                                          tagsizes=adsizes, tagtypes=adtypes,
                                          capture_existing=True)
    '''There should be two SEVERE error like:
    'http://fonts.googleapis.com/css?family=[object+Object]... Failed to load
    '''
    assert errors
    assert len(errors) == 2, "There should be two errors!"
    assert errors[0]['level'] == 'SEVERE'
    assert "http://fonts.googleapis.com" in str(errors[0]['message'])
Esempio n. 6
0
def test_capture_tag():
    """
    Verify that we can capture iframe and script tags
    :return:
    """
    pb = output.create(build="capture_tag_test", config="testconfig", cid="testcid",
                       tagsize="skyscraper", tagtype="iframe")
    tags = {"skyscraper": {
        "iframe": "<iframe>iframe tag for skyscraper</iframe>",
        "script": "<script>script tag for skyscraper</script>",
    }}
    capabilities = {
        "platform": "Windows 7",
        "browserName": "chrome"
    }
    driver = webdriver.setup_webdriver(capabilities)
    result = capture.__capture_tag(pathbuilder=pb, tags_per_campaign=tags,
                                   driver=driver,
                                   capture_existing=True)
    driver.quit()
    assert result is not None, "Could not capture tags!"
    assert result is not False, "Tag capture skipped!"
    assert len(result) == 0, "Errors while capturing tags!"
    assert os.path.exists(pb.tagimage), "tagimage was not captured!"
    assert os.path.exists(pb.taghtml), "taghtml was not captured!"
    pb.rmbuild()
Esempio n. 7
0
def test_capture_tag():
    """
    Verify that we can capture iframe and script tags
    :return:
    """
    pb = output.create(build="capture_tag_test",
                       config="testconfig",
                       cid="testcid",
                       tagsize="skyscraper",
                       tagtype="iframe")
    tags = {
        "skyscraper": {
            "iframe": "<iframe>iframe tag for skyscraper</iframe>",
            "script": "<script>script tag for skyscraper</script>",
        }
    }
    capabilities = {"platform": "Windows 7", "browserName": "chrome"}
    driver = webdriver.setup_webdriver(capabilities)
    result = capture.__capture_tag(pathbuilder=pb,
                                   tags_per_campaign=tags,
                                   driver=driver,
                                   capture_existing=True)
    driver.quit()
    assert result is not None, "Could not capture tags!"
    assert result is not False, "Tag capture skipped!"
    assert len(result) == 0, "Errors while capturing tags!"
    assert os.path.exists(pb.tagimage), "tagimage was not captured!"
    assert os.path.exists(pb.taghtml), "taghtml was not captured!"
    pb.rmbuild()
Esempio n. 8
0
def test_capture_configs():
    cids = [477944]
    configs = {
        "chrome": {
            "enabled": True,
            "capabilities": {
                "platform": "Windows 7",
                "browserName": "chrome"
            }
        },
        "chrome_beta": {
            "enabled": True,
            "capabilities": {
                "platform": "Windows 7",
                "browserName": "chrome",
                "version": "beta"
            }
        }}
    adsizes = ["medium_rectangle"]
    adtypes = ["iframe"]

    pb = output.create(build="capture_test")
    errors = capture.__capture_tags_for_configs(cids=cids, pathbuilder=pb,
                                                configs=configs,
                                                tagsizes=adsizes, tagtypes=adtypes,
                                                capture_existing=True)
    assert errors, "There should be at least one error!"
    pb.rmbuild()
Esempio n. 9
0
def test_capture_configs():
    cids = [477944]
    configs = {
        "chrome": {
            "enabled": True,
            "capabilities": {
                "platform": "Windows 7",
                "browserName": "chrome"
            }
        },
        "chrome_beta": {
            "enabled": True,
            "capabilities": {
                "platform": "Windows 7",
                "browserName": "chrome",
                "version": "beta"
            }
        }
    }
    adsizes = ["medium_rectangle"]
    adtypes = ["iframe"]

    pb = output.create(build="capture_test")
    errors = capture.__capture_tags_for_configs(cids=cids,
                                                pathbuilder=pb,
                                                configs=configs,
                                                tagsizes=adsizes,
                                                tagtypes=adtypes,
                                                capture_existing=True)
    assert errors, "There should be at least one error!"
    pb.rmbuild()
Esempio n. 10
0
def test_pathbuilder_tag_filenames():
    pb = output.create(build="b",
                       config="c",
                       cid="c",
                       tagsize="s",
                       tagtype="t")
    assert pb.taghtml, "Could not get taghtml!"
    assert pb.tagimage, "Could not get tagimage!"
Esempio n. 11
0
def test_pathbuilder_basepath():
    testpath = TESTPATH
    build = "basepath_test"
    pb = output.create(basepath=testpath, build=build)
    assert pb.path == os.path.join(testpath, build)
    assert not os.path.exists(pb.path), "path should not exist yet!"
    created_path = pb.create(allow_partial=True)
    assert os.path.exists(created_path), "failed to create path!"
    assert __rmbuild_and_validate(pb), "rmbuild should have returned true!"
Esempio n. 12
0
def test_pathbuilder_basepath():
    testpath = TESTPATH
    build = "basepath_test"
    pb = output.create(basepath=testpath,
                       build=build)
    assert pb.path == os.path.join(testpath, build)
    assert not os.path.exists(pb.path), "path should not exist yet!"
    created_path = pb.create(allow_partial=True)
    assert os.path.exists(created_path), "failed to create path!"
    assert __rmbuild_and_validate(pb), "rmbuild should have returned true!"
Esempio n. 13
0
def __get_pathbuilder(build="testbuild",
                      config="testconfig",
                      cid=131313,
                      tagsize="testsize",
                      tagtype="testtype"):
    return output.create(config=config,
                         cid=cid,
                         tagsize=tagsize,
                         build=build,
                         tagtype=tagtype)
Esempio n. 14
0
def test_compare_configs():
    """
    def compare_configs(pathbuilder, configs):
    :return:
    """
    testpath = settings.Test.TEST_ASSETS_DIR
    build = "testbuild"
    cid = 477944
    pb = output.create(basepath=testpath, build=build, cid=cid, tagsize="medium_rectangle", tagtype="iframe")
    __test_compare_configs_internal(pb, configs=["chrome", "chrome_beta"], expected_result=0)
    __test_compare_configs_internal(pb, configs=["chrome", "firefox"], expected_result=214)
Esempio n. 15
0
def test_output_create_invalid():
    with pytest.raises(TypeError):
        # Must specify build
        output.create(config="invalidtest")

    with pytest.raises(ValueError):
        output.create_from_path(dirpath="invalid/path")

    with pytest.raises(ValueError):
        output.create_from_path(dirpath=33)

    with pytest.raises(ValueError):
        # Valid path but not enough parts
        output.create_from_path(dirpath="/tmp/")

    with pytest.raises(ValueError):
        output.PathBuilder(parts=[])

    with pytest.raises(ValueError):
        output.PathBuilder(parts=["too", "few", "parts"])

    with pytest.raises(ValueError):
        output.PathBuilder(parts=[1, 2, 3, 4, 5], basepath="")
Esempio n. 16
0
def test_output_create_invalid():
    with pytest.raises(TypeError):
        # Must specify build
        output.create(config="invalidtest")

    with pytest.raises(ValueError):
        output.create_from_path(dirpath="invalid/path")

    with pytest.raises(ValueError):
        output.create_from_path(dirpath=33)

    with pytest.raises(ValueError):
        # Valid path but not enough parts
        output.create_from_path(dirpath="/tmp/")

    with pytest.raises(ValueError):
        output.PathBuilder(parts=[])

    with pytest.raises(ValueError):
        output.PathBuilder(parts=["too", "few", "parts"])

    with pytest.raises(ValueError):
        output.PathBuilder(parts=[1, 2, 3, 4, 5], basepath="")
Esempio n. 17
0
def test_compare():
    """
    def compare(pb, cids=None, sizes=settings.DEFAULT.tagsizes,
            types=settings.DEFAULT.tagtypes,
            comparison="latest",
            configs=None):
    :return:
    """
    testpath = settings.Test.TEST_ASSETS_DIR
    build = "testcompare"
    cids = [477944]
    comparison = "latest"
    pb = output.create(build=build, basepath=testpath)
    result = compare.compare(pb=pb, cids=cids, comparison=comparison)
    assert result.result[settings.ImageErrorLevel.INVALID] == 0, "There should be 0 invalid results!"
    assert len(result.result) > 0, "There should be some results!"
    pb.rmbuild()
Esempio n. 18
0
def test_pathbuilder_clone():
    pb1 = output.create(build="clonebuild", config="cloneconfig", cid="clonecid",
                        tagsize="clonesize", tagtype="clonetype")
    pb2 = pb1.clone()
    assert pb1.path == pb2.path, "Clones should equal each other in path!"
    assert str(pb1) == str(pb2), "Clones should equal each other in str()!"
    assert pb1 == pb2, "Clones should be equal to each other!"

    pb3 = pb1.clone(build="clonebuild2")
    assert pb1.build != pb3.build, \
        "Cloned build should have been overwritten to clonebuild2!"
    assert pb1.tagtype == pb3.tagtype, "Clones should have the same tagtype!"

    basepath = os.path.join(TESTPATH, "clonebase")
    pb4 = pb1.clone(basepath=basepath)
    assert basepath in str(pb4.path), "basepath should be part of the cloned path!"
    pb5 = pb4.clone()
    assert basepath in str(pb5.path), "basepath should be part of the cloned path!"
Esempio n. 19
0
def test_compare():
    """
    def compare(pb, cids=None, sizes=settings.DEFAULT.tagsizes,
            types=settings.DEFAULT.tagtypes,
            comparison="latest",
            configs=None):
    :return:
    """
    testpath = settings.Test.TEST_ASSETS_DIR
    build = "testcompare"
    cids = [477944]
    comparison = "latest"
    pb = output.create(build=build, basepath=testpath)
    result = compare.compare(pb=pb, cids=cids, comparison=comparison)
    assert result.result[settings.ImageErrorLevel.INVALID] == 0, \
        "There should be 0 invalid results!"
    assert len(result.result) > 0, "There should be some results!"
    pb.rmbuild()
Esempio n. 20
0
def test_compare_configs():
    """
    def compare_configs(pathbuilder, configs):
    :return:
    """
    testpath = settings.Test.TEST_ASSETS_DIR
    build = "testbuild"
    cid = 477944
    pb = output.create(basepath=testpath,
                       build=build,
                       cid=cid,
                       tagsize="medium_rectangle",
                       tagtype="iframe")
    __test_compare_configs_internal(pb,
                                    configs=["chrome", "chrome_beta"],
                                    expected_result=0)
    __test_compare_configs_internal(pb,
                                    configs=["chrome", "firefox"],
                                    expected_result=214)
Esempio n. 21
0
    def run(self):
        self.logger.info(
            'Got %s campaigns from config: %s', len(self.cids), self.cids)

        if self.args.resubmit:
            self.submit_campaigns()

        if self.args.skip_capture:
            self.logger.info('Skipping capture due to config option!')
            return

        # TODO: build should be a param on the object
        if not self.args.compare_build:
            build = output.generate_build_string(prefix=self.args.test_config)
            pb = output.create(build, basepath=OUTPUT_BASEDIR)
            self.capture_tags(pb=pb)
        else:
            build = self.args.compare_build

        self.compare_builds(build)
Esempio n. 22
0
def test_capture_tag_remote():
    """
    Verify that we can capture iframe and script tags
    :return:
    """
    pb = output.create(
        build="capture_tag_test", config="testconfig", cid="testcid",
        tagsize="skyscraper", tagtype="iframe")
    tags = {"skyscraper": {
        "iframe": "<iframe>iframe tag for skyscraper</iframe>",
        "script": "<script>script tag for skyscraper</script>",
    }}

    capabilities = {
        "platform": "Windows 7",
        "browserName": "chrome"
    }

    remote_capture = TagCapture.from_caps(capabilities)
    __test_capture_tag(remote_capture, pb, tags)
Esempio n. 23
0
def test_pathbuilder_clone():
    pb1 = output.create(build="clonebuild",
                        config="cloneconfig",
                        cid="clonecid",
                        tagsize="clonesize",
                        tagtype="clonetype")
    pb2 = pb1.clone()
    assert pb1.path == pb2.path, "Clones should equal each other in path!"
    assert str(pb1) == str(pb2), "Clones should equal each other in str()!"
    assert pb1 == pb2, "Clones should be equal to each other!"

    pb3 = pb1.clone(build="clonebuild2")
    assert pb1.build != pb3.build, \
        "Cloned build should have been overwritten to clonebuild2!"
    assert pb1.tagtype == pb3.tagtype, "Clones should have the same tagtype!"

    basepath = os.path.join(TESTPATH, "clonebase")
    pb4 = pb1.clone(basepath=basepath)
    assert basepath in str(
        pb4.path), "basepath should be part of the cloned path!"
    pb5 = pb4.clone()
    assert basepath in str(
        pb5.path), "basepath should be part of the cloned path!"
Esempio n. 24
0
def test_to_str():
    pathbuilder = output.create(build="testbuild")
    assert str(pathbuilder) == "testbuild"
Esempio n. 25
0
def test_pathbuilder_rmbuild_invalid():
    pb = output.create(build="invalid")
    result = __rmbuild_and_validate(pb)
    assert not result, "There should have been nothing to remove!"
Esempio n. 26
0
def test_to_str():
    pathbuilder = output.create(build="testbuild")
    assert str(pathbuilder) == "testbuild"
Esempio n. 27
0
def __get_pathbuilder(build="testbuild", config="testconfig", cid=131313,
                      tagsize="testsize",
                      tagtype="testtype"):
    return output.create(config=config, cid=cid, tagsize=tagsize,
                         build=build, tagtype=tagtype)
Esempio n. 28
0
def test_pathbuilder_rmbuild_invalid():
    pb = output.create(build="invalid")
    result = __rmbuild_and_validate(pb)
    assert not result, "There should have been nothing to remove!"
Esempio n. 29
0
def test_pathbuilder_tag_filenames():
    pb = output.create(build="b", config="c", cid="c",
                       tagsize="s", tagtype="t")
    assert pb.taghtml, "Could not get taghtml!"
    assert pb.tagimage, "Could not get tagimage!"