def test_with_hosts(self):
     hostname_array = [
         "foo.example.com",
         "bar.example.com",
         "baz.example.com"
     ]
     hosts = Hosts(hostname_array)
     assert type(hosts.next()) is str
     assert type(hosts.next()) is str
     assert type(hosts.next()) is str
     assert type(hosts.next()) is str
     assert type(hosts.next()) is str
def putInQueue(event, context):
    # For demo purposes, this function is invoked manually
    # Also for demo purposes, we will use a static list here
    # We need to figure out a way to put stuff in the queue regularly
    target_list = [
        "www.mozilla.org",
        "infosec.mozilla.org",
    ]
    hosts = Hosts(target_list)
    target = Target(hosts.next())
    SQS_CLIENT.send_message(QueueUrl=os.getenv('SQS_URL'),
                            MessageBody="manual|" + target.name)
    def test_with_hosts_for_host_fixing(self):
        hostname_array = [
            "foo.example.com",
            "bar.example.com",
            "baz.example.com",
            "foo2.example.com",
            "bar2.example.com",
            "baz2.example.com"
        ]
        hosts = Hosts(hostname_array)

        # Make 6 selections from next()
        selected_hosts = []
        selected_hosts.append(hosts.next())
        selected_hosts.append(hosts.next())
        selected_hosts.append(hosts.next())
        selected_hosts.append(hosts.next())
        selected_hosts.append(hosts.next())
        selected_hosts.append(hosts.next())

        # check the len of a uniq'd selection to
        # make sure we're not stuck on the same host
        assert len(list(set(selected_hosts))) > 1
 def test_with_no_hosts(self):
     hosts = Hosts()
     assert hosts.next() is None